com.novell.ecb.secretstore
Class CreateSecret

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

public class CreateSecret
extends SecretBean

Provides the functionality for creating a Secret.

This bean can also be used for modifying the value and the enhancedProtectionPassword for an existing Secret in the Secret Store. This bean overwrites the existing secret value. To avoid overwriting existing secret value, set the flag SSFlag.IN_CHECK_ID_COLLISION.

Required Input Properties:
SecretInstance - A SecretInstance object that represents the Secret to be created or modified.
value - The value for the secret. No value is set by default.
sharedValue - A SharedValue object representing a SharedSecret's value. Default value is null.
NOTE: If both value and sharedValue are set then, sharedValue is used for a sharedSecret; otherwise value is used. For an ordinary Secret, value is a required input property.
 
Optional Input Properties:
enhancedProtectionPassword - Password for creating an enhanced protected secret.
flags - The flags for the operation. By default, no flag is set. The flag, SSFlags.IN_CHECK_ID_COLLISION is defined to enable name collision checking while creating a Secret and set its value.
Output Property:
None

Version:
1.0
See Also:
SharedValue, Serialized Form

Constructor Summary
CreateSecret()
          Constructs a CreateSecret command bean.
CreateSecret(SecretInstance secretInstance)
          Constructs a CreateSecret command bean and sets the SecretInstance to be used.
 
Method Summary
 void execute()
          Executes this command bean for creating Secret.
 SSFlags getFlags()
          Returns the flags set.
 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 setFlags(SSFlags flags)
          Sets the flags to be used while setting the value of Secret.
 void setSecretValue(byte[] value)
          Sets the value of the Secret.
 void setSharedValue(SharedValue value)
          Sets the value of the SharedSecret.
 
Methods inherited from class com.novell.ecb.secretstore.SecretBean
getSecretInstance, setSecretInstance
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CreateSecret

public CreateSecret()
Constructs a CreateSecret command bean.


CreateSecret

public CreateSecret(SecretInstance secretInstance)
Constructs a CreateSecret command bean and sets the SecretInstance to be used.

Parameters:
secretInstance - A SecretInstance object that represents the Secret to be created or modified.
Method Detail

setFlags

public void setFlags(SSFlags flags)
Sets the flags to be used while setting the value of Secret.

No flag is set by default. Currently, only IN_CHECK_ID_COLLISION flag is defined for this operation. If this flag is set, secret is created with name collision checking.

Parameters:
flags - Flags for the operation.
See Also:
SSFlags.IN_CHECK_ID_COLLISION

getFlags

public SSFlags getFlags()
Returns the flags set.

Returns:
SSFlags The flags set.

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 as it gets populated inside the SecretInstance object.

Parameters:
epPassword - Enhanced protection password 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 as it gets populated inside the SecretInstance object.

Parameters:
epPassword - Enhanced protection password for the Secret.

setSecretValue

public void setSecretValue(byte[] value)
Sets the value of the Secret. Format for the value of a SharedSecret is specified in SharedValue object. This format is taken care by SharedValue object and setSharedValue() could be used.
Using this method for setting the value of a SharedSecret does not guarantee that ReadSecret bean would be able to return a proper SharedValue object.

Parameters:
value - Byte array containing the value of the Secret.
See Also:
SharedValue

setSharedValue

public void setSharedValue(SharedValue value)
Sets the value of the SharedSecret. Using this method for setting the value of a SharedSecret avoids the overhead of maintaining the format specified for Shared Secrets.
Using this method for setting the SharedSecret value guarantees that ReadSecret bean would be able to return a proper SharedValue object.

Parameters:
value - SharedValue object representing the value 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.

There is no output property to reset.


execute

public void execute()
             throws CommandException
Executes this command bean for creating Secret.

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

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


     // Get the SecretInstance from GetSecretInstance bean
   SecretInstance si = getSI.getSecretInstance();
   try
     {
         // Instantiate the command bean
       CreateSecret createSecret = new CreateSecret(si);
         // Set the input properties of the command bean
         // Set the value of the Secret
       createSecret.setSecretValue("someValue".getBytes());
         // EnhancedProtection password can be set in this bean
         // or in GetSecretInstance bean itself.
         // Call the execute method of the command bean
       createSecret.execute();
         // There is no output property to query
     }
     catch(CommandException e)
      {
         // TODO: Handle exception
      }
 

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


     // Get the SecretInstance from GetSecretInstance bean.
     // Depending on the secretID, GetSecretInstance bean creates 
     // the instance of SecretInstance or SharedSecretInstance.
   SecretInstance si = getSI.getSecretInstance();
   try
     {
         // Instantiate the command bean
       CreateSecret createSecret = new CreateSecret(si);
       SharedValue val = new SharedSecret();
       val.addValue("username","bob");
       val.addValue("password","password");
         // Set the input properties of the command bean
         // Set the value of the SharedSecret
       createSecret.setSharedValue(val);
         // EnhancedProtection password can be set in this bean
         // or in GetSecretInstance bean itself.
         // Call the execute method of the command bean
       createSecret.execute();
         // There is no output property to query
     }
     catch(CommandException e)
      {
         // TODO: Handle exception
      }
 
See Also:
GetSecretInstance


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