com.novell.nds.dirxml.shimhost
Class NamedPasswords

java.lang.Object
  extended by com.novell.nds.dirxml.shimhost.NamedPasswords
All Implemented Interfaces:
ConfigElement

public class NamedPasswords
extends Object
implements ConfigElement

Class encapsulating named password behavior for hosting shims. This primarily exists to support named password references in shim configuration parameters.


Nested Class Summary
 class NamedPasswords.NamedPassword
          Class encapsulating a named password.
 
Field Summary
static String ATTR_SECURE
          Name for XML attribute 'secure'.
static String TAG_DESCRIPTION
          Tag name for XML element 'description'.
static String TAG_KEY
          Tag name for XML element 'key'.
static String TAG_NAMED_PASSWORD
          Tag name for XML element 'named-password'.
static String TAG_NAMED_PASSWORDS
          Tag name for XML element 'named-passwords'.
static String TAG_PASSWORD
          Tag name for XML element 'password'.
static String VAL_FALSE
          "false"
static String VAL_TRUE
          "true"
 
Constructor Summary
NamedPasswords()
          Construct an empty NamedPasswords instance.
NamedPasswords(Element namedPasswords, boolean secure)
          Construct a NamedPasswords instance from an XML representation.
 
Method Summary
 NamedPasswords.NamedPassword getNamedPassword(String key)
          Get a NamedPassword object by name.
 boolean hasBeenModified()
          Return true if this instance has been modified.
 Iterator iterator()
          Return an Iterator that will return all the NamedPassword objects in this instance.
 NamedPasswords.NamedPassword newNamedPassword(String key)
          Create a new named password entry if one doesn't already exist with the passed name.
 NamedPasswords.NamedPassword removeNamedPassword(String key)
          Remote named password entry if it exists in this instance.
 void resetModified()
          Reset the modified flag for this instance such that hasBeenModified() will return false.
 void setConfigPassword(char[] configPassword)
          Set a password for use by contained NamedPassword instance for setting and returning clear-text passwords.
 Element toXML(Node parent)
          Construct an XML representation of this instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TAG_NAMED_PASSWORDS

public static final String TAG_NAMED_PASSWORDS
Tag name for XML element 'named-passwords'.

See Also:
Constant Field Values

TAG_NAMED_PASSWORD

public static final String TAG_NAMED_PASSWORD
Tag name for XML element 'named-password'.

See Also:
Constant Field Values

TAG_KEY

public static final String TAG_KEY
Tag name for XML element 'key'.

See Also:
Constant Field Values

TAG_DESCRIPTION

public static final String TAG_DESCRIPTION
Tag name for XML element 'description'.

See Also:
Constant Field Values

TAG_PASSWORD

public static final String TAG_PASSWORD
Tag name for XML element 'password'.

See Also:
Constant Field Values

ATTR_SECURE

public static final String ATTR_SECURE
Name for XML attribute 'secure'.

See Also:
Constant Field Values

VAL_TRUE

public static final String VAL_TRUE
"true"

See Also:
Constant Field Values

VAL_FALSE

public static final String VAL_FALSE
"false"

See Also:
Constant Field Values
Constructor Detail

NamedPasswords

public NamedPasswords()
Construct an empty NamedPasswords instance.


NamedPasswords

public NamedPasswords(Element namedPasswords,
                      boolean secure)
               throws XMLException
Construct a NamedPasswords instance from an XML representation.

Parameters:
namedPasswords - <named-passwords> element containing the XML representation.
secure - true if enclosing XML specifies passwords are encrypted
Throws:
XMLException - if the XML representation is incorrect
Method Detail

setConfigPassword

public void setConfigPassword(char[] configPassword)
Set a password for use by contained NamedPassword instance for setting and returning clear-text passwords.

Parameters:
configPassword - password characters or null

hasBeenModified

public boolean hasBeenModified()
Return true if this instance has been modified.

The instance is considered to have been modified if a change was made that affects the persistent representation since:

  1. The instance was constructed from an XML representation.
  2. resetModified() was last called

Specified by:
hasBeenModified in interface ConfigElement
Returns:
true or false
See Also:
resetModified(), toXML(org.w3c.dom.Node)

resetModified

public void resetModified()
Reset the modified flag for this instance such that hasBeenModified() will return false.

Specified by:
resetModified in interface ConfigElement
See Also:
hasBeenModified()

toXML

public Element toXML(Node parent)
Construct an XML representation of this instance.

Note that the act of creating an XML representation does not reset this instance's modified flag. It must be reset by calling resetModified().

Specified by:
toXML in interface ConfigElement
Parameters:
parent - Node under which to build the XML representation
Returns:
construct <named-passwords> Element
See Also:
hasBeenModified(), resetModified()

iterator

public Iterator iterator()
Return an Iterator that will return all the NamedPassword objects in this instance.

Returns:
Iterator

getNamedPassword

public NamedPasswords.NamedPassword getNamedPassword(String key)
Get a NamedPassword object by name.

Parameters:
key - name of password
Returns:
NamedPassword object or null

newNamedPassword

public NamedPasswords.NamedPassword newNamedPassword(String key)
                                              throws IllegalArgumentException
Create a new named password entry if one doesn't already exist with the passed name.

Parameters:
key - name of named password
Returns:
created or existing NamedPassword instance
Throws:
IllegalArgumentException - if key is null or empty

removeNamedPassword

public NamedPasswords.NamedPassword removeNamedPassword(String key)
Remote named password entry if it exists in this instance.

Parameters:
key - name of named password
Returns:
removed NamedPassword instance, or null