|
Localization Class Structure
and Utilities
|
Localization support can be added to the SpaceKit by creating a message class for the particular language to support. The class name is "SpaceMessage" followed
by the language mnemonic with hyphens removed and capitalized. For example, the class name for "en-us" is "SpaceMessageENUS" and is an implemention of the "SpaceMessage" interface.
The class contains one method get()
with a single int argument specifying the message number. Error codes are considered message numbers.
The class must be defined in the $CLASSPATH for the Java virtual machine.
A Localization Class Example |
|
This is the implementation of the "en-us" language as distributed with the Blocks SpaceKit for Java:
public class SpaceMessageENUS implements SpaceMessage {
//------------------------------------------------------------------------------
// lookup message
//------------------------------------------------------------------------------
public String get(int messageCode) {
if(messageCode == 421) return("service not available");
if(messageCode == 450) return("requested action not taken");
if(messageCode == 451) return("requested action aborted");
if(messageCode == 454) return("temporary authentication failure");
if(messageCode == 500) return("general syntax error");
if(messageCode == 501) return("missing NUL separator");
if(messageCode == 504) return("parameter not implemented");
if(messageCode == 530) return("authentication required");
if(messageCode == 534) return("authentication mechanism insufficient");
if(messageCode == 535) return("authentication failure");
if(messageCode == 537) return("action not authorized for user");
if(messageCode == 538) return("authentication mechanism requires encryption");
if(messageCode == 550) return("requested action not taken");
if(messageCode == 553) return("parameter invalid");
if(messageCode == 554) return("transaction failed");
return(null);
}
}
Utilities
SpaceKeyOtp: OTP Key Generation |
|
Each user defined in a user properties file contains an authorization key associated with the authorization mechanism. The SpaceKeyOtp utility arguments are algorithm, passphrase (not included in the user properties file), seed and count:
java SpaceKeyOtp sha1 secretpassphrase rwcsqa0120696 9911
The key is sent to standard output:
Next » Reference.
Copyright © 2000 Invisible Worlds. All Rights Reserved.