com.novell.ecb.secretstore
Class SyncSecret

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

public class SyncSecret
extends SecretBean

Synchronizes the two Secrets in the SecretStore.

It synchronizes two existing Secrets and does not create a Secret if any of the Secrets does not exist.
The target Secret will be modified if the timestamp for the source Secret is more recent; otherwise no change occurs.
If source Secret is enhancedProtected, enhancedProtection password must be provided.

Required Input Properties:
sourceSecret - A SecretInstance object that represents the source SecretInstance to be used for synchronization.
targetSecret - A target SecretInstance object.
 
Optional Input Properties:
enhancedProtectionPassword - Password for enhanced protected secret. It is needed if the source Secret is enhanced protected with a password.
 
Output Property:
isSynced - True if the targetSecret was modified, False if not.

Version:
1.0
See Also:
UpdateSecret, Serialized Form

Constructor Summary
SyncSecret()
          Constructs a SyncSecret command bean.
SyncSecret(SecretInstance sourceSecret)
          Constructs a SyncSecret command bean and sets the source SecretInstance to be synchronized with.
SyncSecret(SecretInstance sourceSecret, SecretInstance targetSecret)
          Constructs a SyncSecret command bean and sets the source SecretInstance and target SecretInstance to be synchronized.
 
Method Summary
 void execute()
          Executes this command bean for synchronizing the two Secrets.
 SecretInstance getTargetSecret()
          Returns the target SecretInstance.
 boolean isReady()
          Tests whether the required input properties are set and the bean is in "initialized" state.
 boolean isSynced()
          Returns True, if target secret gets modified.
 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 setTargetSecret(SecretInstance targetSecret)
          Sets the target SecretInstance to be synchronized.
 
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

SyncSecret

public SyncSecret()
Constructs a SyncSecret command bean.


SyncSecret

public SyncSecret(SecretInstance sourceSecret)
Constructs a SyncSecret command bean and sets the source SecretInstance to be synchronized with.

Parameters:
sourceSecret - A SecretInstance object that represents the source SecretInstance to be used for synchronization.

SyncSecret

public SyncSecret(SecretInstance sourceSecret,
                  SecretInstance targetSecret)
Constructs a SyncSecret command bean and sets the source SecretInstance and target SecretInstance to be synchronized.

Parameters:
sourceSecret - A SecretInstance object that represents the source SecretInstance to be used for synchronization.
targetSecret - A target SecretInstance object.
Method Detail

setTargetSecret

public void setTargetSecret(SecretInstance targetSecret)
Sets the target SecretInstance to be synchronized.

Parameters:
targetSecret - A target SecretInstance object.

getTargetSecret

public SecretInstance getTargetSecret()
Returns the target SecretInstance.

Returns:
SecretInstance The target SecretInstance object.

setEnhancedProtectionPassword

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

Sets the enhanced protection password property.

If this password is already set by GetSecretInstance bean, it is not required to set it again as it gets populated inside the SecretInstance object.

Parameters:
epPassword - EnhancedProtectionPassword for the Secret.

setEnhancedProtectionPassword

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

If this password is already set by GetSecretInstance bean, it is not required to set it again as it gets populated inside the SecretInstance object.

Parameters:
epPassword - EnhancedProtectionPassword for the Secret.

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


execute

public void execute()
             throws CommandException
Executes this command bean for synchronizing the two Secrets.

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

Example: Shows how to use SyncSecret bean.


     // Get the SecretInstance from GetSecretInstance or EnumerateSecrets bean.
   SecretInstance si = getSI.getSecretInstance();
   try
     {
         // Instantiate the command bean
       SyncSecret sync = new SyncSecret(si);
         // Set the input properties of the command bean
       getSI.setSecretID("myApp2");
       getSI.execute();
       targetSI = getSI.getSecretInstance();
       sync.setTargetSecret(targetSI);
         // If source Secret is enhanced protected, enhancedProtection
         // password must be set. This can be set in GetSecretInstance also.
       sync.setEnhancedProtectionPassword("epPassword".toCharArray());
         // Call the execute method of the command bean
       sync.execute();
         // Query the output properties of the command bean
         if (sync.isSynced())
            {
              // Do something
            }
         else
            {
              // Try again or do something else
            }
      }
     catch(CommandException e)
      {
         // TODO: Handle exception
      }
 
See Also:
GetSecretInstance, EnumerateSecrets

isSynced

public boolean isSynced()
Returns True, if target secret gets modified.

Returns:
boolean True if target secret is modified; False otherwise.


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