com.novell.ecb.secretstore
Class EnumerateSecrets

java.lang.Object
  |
  +--com.novell.ecb.secretstore.SecretStoreBean
        |
        +--com.novell.ecb.secretstore.EnumerateSecrets
All Implemented Interfaces:
Command, java.io.Serializable

public class EnumerateSecrets
extends SecretStoreBean

Enumerates the Secrets present in the SecretStore.

Only the Secrets whose SecretIDs match the filter expression are enumerated depending on the buffer size used. By default, empty string is used as filter expression and all Secrets are enumerated.

Secret identifiers are enumerated as an array of Strings and Secrets are enumerated as an array of SecretInstance and SharedSecretInstance objects. SharedSecretInstance objects are created for the SharedSecrets.

Required Input Properties:
ssInstance - A SecretStoreInstance object that represents the SecretStore whose Secrets are to be enumerated.
 
Optional Input Properties:
filter - Filter expressions for filtering the secret identifiers.
flags - The flags for the operation. Currently, no flag is defined for this operation. Property is provided here for future use.
maxLen - The maximum buffer length in bytes that can be used to retrieve the secret identifiers.
createSecrets - Determines whether to create secret objects corresponding to secretIDs. It is a boolean property.
masterPassword - Master Password for the SecretStore.
useMasterPassword - Determines whether to use master password while creating secrets. It is a boolean property.
 
Output Properties:
SecretIDs - The SecretIDs in the SecretStore of the user.
 
Optional Output Properties:
SecretInstances -The SecretInstance and SharedSecretInstance objects; to get this property, createSecrets property must be set to true.

Version:
1.0
See Also:
SecretInstance, SharedSecretInstance, Serialized Form

Field Summary
 
Fields inherited from class com.novell.ecb.secretstore.SecretStoreBean
MAX_BUFFER_SIZE
 
Constructor Summary
EnumerateSecrets()
          Constructs an EnumerateSecrets command bean.
EnumerateSecrets(SecretStoreInstance ssInstance)
          Constructs an EnumerateSecrets command bean and sets the SecretStoreInstance to be used by this bean.
EnumerateSecrets(SecretStoreInstance ssInstance, SSFlags flags, java.lang.String filter, int maxLen)
          Constructs an EnumerateSecrets command bean and sets the SecretStoreInstance, flags, filter, and maximum buffer size to be used by the bean.
 
Method Summary
 void execute()
          Executes this command bean for enumerating Secrets and SecretIDs in the SecretStore.
 boolean getCreateSecrets()
          Returns the createSecrets property value.
 java.lang.String getFilter()
          Returns the filter set.
 SSFlags getFlags()
          Returns the flags set.
 int getMaxLen()
          Returns the maximum buffer size set.
 java.lang.String[] getSecretIDs()
          Returns a string array of secretIDs.
 SecretInstance[] getSecretInstances()
          Returns an array of SecretInstance and/or SharedSecretInstance objects.
 boolean getUseMasterPassword()
          Returns the useMasterPassword property value.
 boolean isReady()
          Tests whether the required input properties are set and the bean is in "initialized" state.
 void reset()
          Resets the output properties to the values they had before the execute method was called.
 void setCreateSecrets(boolean createSecrets)
          Sets the createSecrets property.
 void setFilter(java.lang.String filter)
          Sets the filter to be used for selecting the Secrets for enumeration.
 void setFlags(SSFlags flags)
          Sets the flags to be used while enumerating the Secrets.
 void setMasterPassword(char[] password)
          Sets the master password of the SecretStore.
 void setMasterPassword(java.lang.String password)
          Deprecated. Replaced by setMasterPassword(char[]).
 void setMaxLen(int length)
          Sets the maximum buffer size in bytes to be used while enumerating the Secrets.
 void setUseMasterPassword(boolean useMP)
          Sets the useMasterPassword property.
 
Methods inherited from class com.novell.ecb.secretstore.SecretStoreBean
getSecretStoreInstance, setSecretStoreInstance
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EnumerateSecrets

public EnumerateSecrets()
Constructs an EnumerateSecrets command bean.


EnumerateSecrets

public EnumerateSecrets(SecretStoreInstance ssInstance)
Constructs an EnumerateSecrets command bean and sets the SecretStoreInstance to be used by this bean.

Parameters:
ssInstance - A SecretStoreInstance object that represents the SecretStore whose Secrets are to be enumerated.

EnumerateSecrets

public EnumerateSecrets(SecretStoreInstance ssInstance,
                        SSFlags flags,
                        java.lang.String filter,
                        int maxLen)
Constructs an EnumerateSecrets command bean and sets the SecretStoreInstance, flags, filter, and maximum buffer size to be used by the bean.

Parameters:
ssInstance - A SecretStoreInstance object that represents the SecretStore whose Secrets are to be enumerated.
flags - Flags for the operation. Currently, no flag is defined for this operation. Property is provided here for future use.
filter - Filter expression for filtering the secret identifiers.
maxLen - The maximum buffer length in bytes that can be used to retrieve the secret identifiers.
Method Detail

setFlags

public void setFlags(SSFlags flags)
Sets the flags to be used while enumerating the Secrets.

Parameters:
flags - Flags for the operation. Currently, no flag is defined for this operation. Property is provided here for future use.

getFlags

public SSFlags getFlags()
Returns the flags set.

Returns:
SSFlags The flags set.

setFilter

public void setFilter(java.lang.String filter)
Sets the filter to be used for selecting the Secrets for enumeration. All the Secrets containing the filter string in their identifiers are enumerated. Empty or null string can be used for selecting all the Secrets.

Parameters:
filter - Filter expression for selecting the Secrets for enumeration.

getFilter

public java.lang.String getFilter()
Returns the filter set.

Returns:
String The filter set for enumerating the Secrets.

setMaxLen

public void setMaxLen(int length)
Sets the maximum buffer size in bytes to be used while enumerating the Secrets.

Parameters:
length - The maximum buffer size. The default buffer size is SecretStoreBean.MAX_BUFFER_SIZE. If a negative length is passed to this method, default value is set.

getMaxLen

public int getMaxLen()
Returns the maximum buffer size set.

Returns:
int The maximum buffer size in bytes.

setCreateSecrets

public void setCreateSecrets(boolean createSecrets)
Sets the createSecrets property.

By default, this bean enumerates only secretIDs. To enumerate SecretInstance objects, createSecrets must be set to true.

Parameters:
createSecrets - Set to true to enumerate SecretInstance objects; else, only the secretIDs are enumerated.

getCreateSecrets

public boolean getCreateSecrets()
Returns the createSecrets property value.

Returns:
boolean True if SecretInstance objects are enumerated; else, returns False.

setMasterPassword

public void setMasterPassword(java.lang.String password)
Deprecated. Replaced by setMasterPassword(char[]).

Sets the master password of the SecretStore. Setting this property is not required, if master password is already set by CreateSecretStoreInstance or GetSecretInstance or UnlockSecretStore or ModifyMasterPassword bean.

Parameters:
password - The master password. If password is a non-null and non-empty string, useMasterPassword property is set to true automatically, when this bean is executed.

setMasterPassword

public void setMasterPassword(char[] password)
Sets the master password of the SecretStore. Setting this property is not required, if master password is already set by CreateSecretStoreInstance or GetSecretInstance or UnlockSecretStore or ModifyMasterPassword bean.

Parameters:
password - The master password. If password is a non-null and non-empty string, useMasterPassword property is set to true automatically, when this bean is executed.

setUseMasterPassword

public void setUseMasterPassword(boolean useMP)
Sets the useMasterPassword property. If this property is set to true, SecretInstances are created with a reference to master password.

Parameters:
useMP - The boolean flag to create SecretInstances with a reference to master password. Setting this property is required only if master password is set by other beans and SecretInstances are to be created with a reference to master password.

getUseMasterPassword

public boolean getUseMasterPassword()
Returns the useMasterPassword property value.

Returns:
boolean useMasterPassword property value.

isReady

public boolean isReady()
Tests whether the required input properties are set and the bean is in "initialized" state.

If the user does not set a value for optional input property, default value is used. Therefore, these properties do not affect the readiness of the bean. However, bean will not be in ready state if any of the required input properties is not set.

Returns:
boolean True if the bean is in initialized state; else, returns False.

reset

public void reset()
Resets the output properties to the values they had before the execute method was called.

Sets the output property, secrets and secretIDs to their default values i.e. Null.


execute

public void execute()
             throws CommandException
Executes this command bean for enumerating Secrets and SecretIDs in the SecretStore.

Throws:
CommandException - Thrown if the bean fails to execute.

Example: Shows how to use EnumerateSecrets bean.


     // Get the SecretStoreInstance created by the CreateSecretStoreInstance bean.
   SecretStoreInstance ssi = createSSI.getSecretStoreInstance();
   try
     {
         // Instantiate the command bean
       EnumerateSecrets enumerator = new EnumerateSecrets(ssi);
         // Set the input properties of the command bean
         // enumerate all the Secrets
       enumerator.setFilter("*");
         // Set the buffer size to list only a few Secrets
         // by default max size is used, which is practically 
         // sufficient to list all the Secrets.
       enumerator.setMaxLen(1024);
         // Master password for the SecretStore can be set here also,
         // if not set earlier.
       enumerator.setMasterPassword("masterpassword".toCharArray());
         // If master password is already set, setUseMasterPassword() 
         // would also have the same effect.
         // createSecrets can be set to true if further opertions are
         // to be performed on all the secrets.
       enumerator.setCreateSecrets(true);
         // Call the execute method of the command bean
       enumerator.execute();
         // Query the output properties of the command bean
       SecretInstance secrets[] = enumerator.getSecretInstances();
       String secretIDs[] = enumerator.getSecretIDs();
         // Do any further operations on the Secrets
       ...
       ...

     }
     catch(CommandException e)
      {
         // TODO: Handle exception
      }
 
See Also:
CreateSecretStoreInstance

getSecretIDs

public java.lang.String[] getSecretIDs()
Returns a string array of secretIDs.

Returns:
String[] String array of secretIDs.

getSecretInstances

public SecretInstance[] getSecretInstances()
Returns an array of SecretInstance and/or SharedSecretInstance objects.

To get this property, createSecrets property must be set to true before executing the bean.

Returns:
SecretInstance[] Array of SecretInstance and/or SharedSecretInstance objects. SharedSecretInstance objects are created for SharedSecrets.


Copyright © 2001-2003 Novell, Inc. All Rights Reserved.