com.novell.ecb.secretstore
Class GetSecretInstance

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

public class GetSecretInstance
extends SecretStoreBean

Constructs a SecretInstance or SharedSecretInstance object depending on the secretID specified.

The master password or the enhanced protection password can also be specified so that the user need not provide these values for the other beans.

Required Input Properties:
ssInstance - A SecretStoreInstance object that represents the SecretStore of the user.
secretID - Secret identifier for the SecretInstance object.
OR
secretType - SecretType for the SharedSecret.
secretName - SecretName for the SharedSecret.
NOTE: Either secretID should be set or secretType and secretName should be set together. If all are set, secretID is used. If only secretType and secretName are set Secret identifier is constructed as [secretType]:[secretname]. The length of the SeceretID cannot exceed 255 displayable characters.
 
Optional Input Properties:
masterPassword - The MasterPassword for the SecretStore
useMasterPassword - Determines whether to use master password while creating secrets. It is a boolean property.
enhancedProtectionPassword - Password for enhanced protected secret.
 
Output Properties:
SecretInstance - SecretInstance or SharedSecretInstance object as per the secret identifier specified.

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

Field Summary
 
Fields inherited from class com.novell.ecb.secretstore.SecretStoreBean
MAX_BUFFER_SIZE
 
Constructor Summary
GetSecretInstance()
          Constructs a GetSecretInstance command bean.
GetSecretInstance(SecretStoreInstance ssInstance)
          Constructs a GetSecretInstance command bean and sets the SecretStoreInstance to be used.
GetSecretInstance(SecretStoreInstance ssInstance, java.lang.String secretID)
          Constructs a GetSecretInstance command bean and sets the SecretStoreInstance to be used and SecretID for which SecretInstance is to be created.
 
Method Summary
 void execute()
          Executes this command bean for getting a SecretInstance object.
 java.lang.String getSecretID()
          Returns the secretID for which SecretInstance is to be created.
 SecretInstance getSecretInstance()
          Returns the SecretInstance or SharedSecretInstance object representing the Secret identified by the given SecretID in the SecretStore.
 java.lang.String getSecretName()
          Returns the name of the SharedSecret to be instantiated.
 java.lang.String getSecretType()
          Returns the type of the SharedSecret to be instantiated.
 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 setEnhancedProtectionPassword(char[] epPassword)
          Sets the enhanced protection password property.
 void setEnhancedProtectionPassword(java.lang.String epPassword)
          Deprecated. Replaced by setEnhancedProtectionPassword(char[]).
 void setMasterPassword(char[] password)
          Sets the master password of the SecretStore.
 void setMasterPassword(java.lang.String password)
          Deprecated. Replaced by setMasterPassword(char[]).
 void setSecretID(java.lang.String secretID)
          Sets the secretID for which SecretInstance is to be created.
 void setSecretName(java.lang.String secretName)
          Sets the name of the SharedSecret to be instantiated.
 void setSecretType(java.lang.String secretType)
          Sets the type of the SharedSecret to be instantiated.
 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

GetSecretInstance

public GetSecretInstance()
Constructs a GetSecretInstance command bean.


GetSecretInstance

public GetSecretInstance(SecretStoreInstance ssInstance)
Constructs a GetSecretInstance command bean and sets the SecretStoreInstance to be used.

Parameters:
ssInstance - A SecretStoreInstance object that represents the SecretStore of the target object.

GetSecretInstance

public GetSecretInstance(SecretStoreInstance ssInstance,
                         java.lang.String secretID)
Constructs a GetSecretInstance command bean and sets the SecretStoreInstance to be used and SecretID for which SecretInstance is to be created.

Parameters:
ssInstance - A SecretStoreInstance object that represents the SecretStore of the target object.
secretID - Secret identifier for the SecretInstance object.
Method Detail

setSecretID

public void setSecretID(java.lang.String secretID)
Sets the secretID for which SecretInstance is to be created.

Parameters:
secretID - Secret identifier for the SecretInstance object.

getSecretID

public java.lang.String getSecretID()
Returns the secretID for which SecretInstance is to be created.

Returns:
String SecretID Secret identifier for the SecretInstance object.

setEnhancedProtectionPassword

public void setEnhancedProtectionPassword(java.lang.String epPassword)
Deprecated. Replaced by setEnhancedProtectionPassword(char[]).

Sets the enhanced protection password property.

Once this password is set, it is not required to set it again if the same SecretInstance object is used.

Parameters:
epPassword - EnhancedProtectionPassword for the Secret.

setEnhancedProtectionPassword

public void setEnhancedProtectionPassword(char[] epPassword)
Sets the enhanced protection password property.

Once this password is set, it is not required to set it again if the same SecretInstance object is used.

Parameters:
epPassword - EnhancedProtectionPassword for the Secret.

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 EnumerateSecrets 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 EnumerateSecrets 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, SecretInstance is created with a reference to master password.

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

getUseMasterPassword

public boolean getUseMasterPassword()
Returns the useMasterPassword property value.

Returns:
boolean useMasterPassword property value.

setSecretType

public void setSecretType(java.lang.String secretType)
Sets the type of the SharedSecret to be instantiated.

Parameters:
secretType - Type of the SharedSecret.

getSecretType

public java.lang.String getSecretType()
Returns the type of the SharedSecret to be instantiated.

Returns:
String Type of the SharedSecret.

setSecretName

public void setSecretName(java.lang.String secretName)
Sets the name of the SharedSecret to be instantiated.

Parameters:
secretName - Name of the SharedSecret.

getSecretName

public java.lang.String getSecretName()
Returns the name of the SharedSecret to be instantiated.

Returns:
String Name of the SharedSecret.

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, secretInstance, to its default value i.e. Null.


execute

public void execute()
             throws CommandException
Executes this command bean for getting a SecretInstance object.

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

Example 1: Shows how to use GetSecretInstance bean for an ordinary Secret.


     // Get the SecretStoreInstance created by the CreateSecretStoreInstance bean.
   SecretStoreInstance ssi = createSSI.getSecretStoreInstance();
     // Instantiate the command bean
   GetSecretInstance getSI = new GetSecretInstance(ssi);
   SecretInstance si = null;
   try
     {
         // Set the input properties of the command bean
       getSI.setSecretID("myApp1");
         // To maintain a reference to already set master password
         // useMasterPassword can set to true.
         // Any of master password and enhanced protection password can
         // be used to read a Secret. However, it is recommended to use
         // enhanced protection password for reading an enhanced protected
         // Secret.
         // getSI.setUseMasterPassword(true);
       getSI.setEnhancedProtectionPassword("epPassword".toCharArray());
         // Call the execute method of the command bean
       getSI.execute();
         // Query the output properties of the command bean
       si = getSI.getSecretInstance();
         // Do any further opertions on SecretInstance
       ...
       ... 
     }
     catch(CommandException e)
      {
         // TODO: Handle exception
      }
 

Example 2: Shows how to use GetSecretInstance bean for a SharedSecret.


     // Get the SecretStoreInstance created by the CreateSecretStoreInstance bean.
   SecretStoreInstance ssi = createSSI.getSecretStoreInstance();
     // Instantiate the command bean
   GetSecretInstance getSI = new GetSecretInstance(ssi);
   SecretInstance si = null;
   try
     {
         // Set the input properties of the command bean
         // For Shared Secret set secretID as follows
       getSI.setSecretID("SS_App:mySharedApp1");
         // OR set secretType and secretName separately
         // getSI.setSecretType(SecretType.APPICATION);
         // getSI.setSecretName("mySharedApp1");
         // Setting something as follows would result in creating
         // an instance with "apps:myApp" as secretID.
         // getSI.setSecretType("apps");
         // getSI.setSecretName("myApp");
         // To maintain a reference to already set master password
         // useMasterPassword can set to true.
         // Any of master password and enhanced protection password can
         // be used to read a Secret. However, it is recommended to use
         // enhanced protection password for reading an enhanced protected
         // Secret.
         // getSI.setUseMasterPassword(true);
       getSI.setEnhancedProtectionPassword("epPassword".toCharArray());
         // Call the execute method of the command bean
       getSI.execute();
         // Query the output properties of the command bean
       si = getSI.getSecretInstance();
         // Do any further opertions on SecretInstance
       ...
       ... 
     }
     catch(CommandException e)
      {
         // TODO: Handle exception
      }
 
See Also:
CreateSecretStoreInstance

getSecretInstance

public SecretInstance getSecretInstance()
Returns the SecretInstance or SharedSecretInstance object representing the Secret identified by the given SecretID in the SecretStore.

Returns:
SecretInstance SecretInstance or SharedSecretInstance object for the specified SecretID.


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