Package adams.core.base
Class BasePassword
- java.lang.Object
-
- adams.core.base.BaseObject
-
- adams.core.base.AbstractBaseString
-
- adams.core.base.BasePassword
-
- All Implemented Interfaces:
CloneHandler<BaseObject>
,Serializable
,Comparable
public class BasePassword extends AbstractBaseString
Wrapper for a String object to be editable in the GOE. Used for entering passwords which get Base64 encoded.
This not an attempt to keep passwords safe in any way, merely of obscuring them slightly.- Version:
- $Revision$
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static String
BASE64_END
the indicator of base64 encoding (end).static String
BASE64_START
the indicator of base64 encoding (start).static String
ERROR
the error constant, if decoding failed.static String
MASK_CHAR
the character to mask the password with.-
Fields inherited from class adams.core.base.BaseObject
m_Internal, m_Properties, SUFFIX_DISPLAY, SUFFIX_VALUE
-
-
Constructor Summary
Constructors Constructor Description BasePassword()
Initializes the string with length 0.BasePassword(String s)
Initializes the object with the string to parse.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected String
decode(String base64)
Turns the base64 encoded string into plain text.protected String
encode(String raw)
Encodes the given string in base64.String
getMaskedValue()
Returns the current string value masked with MASK_CHAR.String
getTipText()
Returns a tool tip for the GUI editor (ignored if null is returned).String
getValue()
Returns the current string value.boolean
isValid(String value)
Checks whether the string value is a valid presentation for this class.void
setValue(String value)
Sets the string value.String
stringValue()
Returns the backquoted String value.-
Methods inherited from class adams.core.base.AbstractBaseString
convert, initialize, isEmpty, length
-
Methods inherited from class adams.core.base.BaseObject
compareTo, equals, getClone, getInternal, getTemplates, getUnicode, hasFavoritesSupport, hashCode, isValidUnicode, newInstance, setUnicode, toObjectArray, toObjectArray, toString, toStringArray, toStringList
-
-
-
-
Field Detail
-
BASE64_START
public static final String BASE64_START
the indicator of base64 encoding (start).- See Also:
- Constant Field Values
-
BASE64_END
public static final String BASE64_END
the indicator of base64 encoding (end).- See Also:
- Constant Field Values
-
ERROR
public static final String ERROR
the error constant, if decoding failed.- See Also:
- Constant Field Values
-
MASK_CHAR
public static final String MASK_CHAR
the character to mask the password with.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
BasePassword
public BasePassword()
Initializes the string with length 0.
-
BasePassword
public BasePassword(String s)
Initializes the object with the string to parse.- Parameters:
s
- the string to parse
-
-
Method Detail
-
decode
protected String decode(String base64)
Turns the base64 encoded string into plain text. Expects the string to be surrounded by BASE64_START and BASE64_END- Parameters:
base64
- the encoded string- Returns:
- the decoded string, null in case of an error
- See Also:
BASE64_START
,BASE64_END
-
encode
protected String encode(String raw)
Encodes the given string in base64.- Parameters:
raw
- the string to encode- Returns:
- the encoded string
-
isValid
public boolean isValid(String value)
Checks whether the string value is a valid presentation for this class.- Overrides:
isValid
in classAbstractBaseString
- Parameters:
value
- the string value to check- Returns:
- always true if not base64 encoded, otherwise the base64 string must be properly surrounded
- See Also:
BASE64_START
,BASE64_END
-
setValue
public void setValue(String value)
Sets the string value.- Overrides:
setValue
in classAbstractBaseString
- Parameters:
value
- the string value, clear text or base64 encoded
-
getValue
public String getValue()
Returns the current string value.- Overrides:
getValue
in classAbstractBaseString
- Returns:
- the string value, clear text
-
getMaskedValue
public String getMaskedValue()
Returns the current string value masked with MASK_CHAR.- Returns:
- the masked password
- See Also:
MASK_CHAR
-
stringValue
public String stringValue()
Returns the backquoted String value.- Overrides:
stringValue
in classAbstractBaseString
- Returns:
- the base64 encoded string value
-
getTipText
public String getTipText()
Returns a tool tip for the GUI editor (ignored if null is returned).- Specified by:
getTipText
in classAbstractBaseString
- Returns:
- the tool tip
-
-