com.novell.ecb.secretstore
Class SyncSecretStore

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

public class SyncSecretStore
extends SecretStoreBean

Synchronizes Secrets of two SecretStores.

If the sourceStore has a secret that the targetStore does not have, then the targetStore is updated with that secret. If the sourceStore has a secret that the targetStore has, then the last modified timestamp for both secrets is examined. If the Secret in the source SecretStore has a timestamp that is more recent than the timestamp for the Secret in the target SecretStore, then the Secret in the target SecretStore is updated with the Secret in the source SecretStore. In the case that the timestamp for a Secret in the source SecretStore is either less recent or equal to the timestamp for a corresponding Secret in the target SecretStore, no update will occur to that Secret.

Note:Only those secrets that are not locked and that do not have an enhanced protection password associated with them are synchronized. You will have to manually synchronize secrets that are protected with an enhanced protection password or that are locked.

Required Input Properties:
sourceSecIns - A SecretStoreInstance object that represents the SecretStore of the source object.
targetSecIns - A target SecretStoreInstance object.
 
Optional Input Properties:
filter - Filter expression for filtering the secret identifiers that are returned; default value is empty string.
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.
 
Output Property:
NumSecretsSynced - Number of secrets synchronized.

Version:
1.0
See Also:
UpdateSecretStore, Serialized Form

Field Summary
 
Fields inherited from class com.novell.ecb.secretstore.SecretStoreBean
MAX_BUFFER_SIZE
 
Constructor Summary
SyncSecretStore()
          Constructs a SyncSecretStore Command bean.
SyncSecretStore(SecretStoreInstance sourceSecIns)
          Constructs a SyncSecretStore Command bean and sets the source SecretStoreInstance that is to be synchronized.
SyncSecretStore(SecretStoreInstance sourceSecIns, SecretStoreInstance targetSecIns)
          Constructs a SyncSecretStore Command bean and sets the source and target SecretStoreInstance objects to be synchronized.
 
Method Summary
 void execute()
          Executes this command bean for synchronizing the two SecretStores.
 java.lang.String getFilter()
          Returns the filter expression.
 SSFlags getFlags()
          Returns the flags set.
 int getMaxLen()
          Returns the maximum buffer size set.
 int getNumSecretsSynced()
          Returns the number of Secrets synchronized.
 SecretStoreInstance getTargetSecretStore()
          Returns the target SecretStore for the sync operation.
 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 setFilter(java.lang.String filter)
          Sets the filter to be used for selecting the Secrets for synchronization.
 void setFlags(SSFlags flags)
          Sets the flags to be used while synchronizing the Secrets.
 void setMaxLen(int length)
          Sets the maximum buffer size in bytes to be used while performing the sync operation.
 void setTargetSecretStore(SecretStoreInstance targetSecIns)
          Sets the target SecretStore for the sync operation.
 
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

SyncSecretStore

public SyncSecretStore()
Constructs a SyncSecretStore Command bean.


SyncSecretStore

public SyncSecretStore(SecretStoreInstance sourceSecIns)
Constructs a SyncSecretStore Command bean and sets the source SecretStoreInstance that is to be synchronized.

Parameters:
sourceSecIns - A SecretStoreInstance object that represents the SecretStore of the source object.

SyncSecretStore

public SyncSecretStore(SecretStoreInstance sourceSecIns,
                       SecretStoreInstance targetSecIns)
Constructs a SyncSecretStore Command bean and sets the source and target SecretStoreInstance objects to be synchronized.

Parameters:
sourceSecIns - A SecretStoreInstance object that represents the SecretStore of the source object.
targetSecIns - A target SecretStoreInstance object.
Method Detail

setTargetSecretStore

public void setTargetSecretStore(SecretStoreInstance targetSecIns)
Sets the target SecretStore for the sync operation.

Parameters:
targetSecIns - A target SecretStoreInstance object.

getTargetSecretStore

public SecretStoreInstance getTargetSecretStore()
Returns the target SecretStore for the sync operation.

Returns:
SecretStoreInstance The target SecretStoreInstance object.

setFlags

public void setFlags(SSFlags flags)
Sets the flags to be used while synchronizing 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 synchronization. All the Secrets containing the filter string in their identifiers are synchronized. Empty or null string can be used for selecting all the Secrets.

Parameters:
filter - Filter for selecting the Secrets for synchronization.

getFilter

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

Returns:
String The filter expression set for selecting the Secrets for synchronization.

setMaxLen

public void setMaxLen(int length)
Sets the maximum buffer size in bytes to be used while performing the sync operation.

Parameters:
length - The maximum buffer size in bytes. 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.

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


execute

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

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

Example: Shows how to use SyncSecretStore bean.


     // Get the SecretStoreInstance created by the CreateSecretStoreInstance bean.
   SecretStoreInstance ssi = createSSI.getSecretStoreInstance();
   try
     {
         // Instantiate the command bean
       SyncSecretStore syncSS = new SyncSecretStore(ssi);
         // Set the input properties of the command bean
         // Create the target SecretStoreInstance and set the target
       syncSS.setTargetSecretStore(targetSSI);
         // Set filter to sync selected Secrets
       syncSS.setFilter("a*");
         // To limit the number of Secrets being synced buffer size can be set
       syncSS.setMaxLen(1024);
         // Call the execute method of the command bean
       syncSS.execute();
         // Query the output properties of the command bean
       int numSynced = syncSS.getNumSecretsSynced();
         // Do any further operations
       ...
       ...
      }
     catch(CommandException e)
      {
         // TODO: Handle exception
      }
 
See Also:
CreateSecretStoreInstance

getNumSecretsSynced

public int getNumSecretsSynced()
Returns the number of Secrets synchronized.

Returns:
int The number of Secrets synchronized.


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