Cumulus4j API
(1.2.0)

org.cumulus4j.keymanager.api
Class DefaultKeyManagerAPI

java.lang.Object
  extended by org.cumulus4j.keymanager.api.internal.AbstractKeyManagerAPI
      extended by org.cumulus4j.keymanager.api.DefaultKeyManagerAPI
All Implemented Interfaces:
KeyManagerAPI

public class DefaultKeyManagerAPI
extends AbstractKeyManagerAPI

Implementation of KeyManagerAPI that delegates to a specific implementation.

Instantiate an instance of this class and then use the KeyManagerAPI interface everywhere to reference it.

When using dependency injection, there should be no reference to this class at all except for the configuration of the dependency injection.

Author:
Marco หงุ่ยตระกูล-Schulze - marco at nightlabs dot de

Field Summary
 
Fields inherited from class org.cumulus4j.keymanager.api.internal.AbstractKeyManagerAPI
FILE_URL_PREFIX
 
Constructor Summary
DefaultKeyManagerAPI()
           
 
Method Summary
 void deleteUser(String userName)
          Delete a user.
 KeyManagerAPIConfiguration getConfiguration()
          Get the current configuration of this KeyManagerAPI.
 CryptoSession getCryptoSession(String appServerBaseURL)
           Get a session for a certain application server.
 DateDependentKeyStrategyInitResult initDateDependentKeyStrategy(DateDependentKeyStrategyInitParam param)
          Initialise a new key-store with the DateDependentKeyStrategy.
 void putUser(String userName, char[] password)
          Create a new user or change an existing user's password.
 void setConfiguration(KeyManagerAPIConfiguration configuration)
           Set the configuration for this KeyManagerAPI instance.
 
Methods inherited from class org.cumulus4j.keymanager.api.internal.AbstractKeyManagerAPI
equals, getAuthPassword, getAuthUserName, getConf, getKeyManagerBaseURL, getKeyStoreID
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultKeyManagerAPI

public DefaultKeyManagerAPI()
Method Detail

setConfiguration

public void setConfiguration(KeyManagerAPIConfiguration configuration)
                      throws IllegalArgumentException,
                             KeyManagerAPIInstantiationException
Description copied from interface: KeyManagerAPI

Set the configuration for this KeyManagerAPI instance.

Before a KeyManagerAPI instance can actually be used, it first needs to be configured. The configuration passed to this method will be marked read-only.

Specified by:
setConfiguration in interface KeyManagerAPI
Overrides:
setConfiguration in class AbstractKeyManagerAPI
Parameters:
configuration - the configuration (which will be marked read-only by this operation). Must not be null.
Throws:
IllegalArgumentException - if the configuration is null or incomplete (e.g. configuration.keyStoreID being null).
KeyManagerAPIInstantiationException - if the actual implementation cannot be instantiated.

getConfiguration

public KeyManagerAPIConfiguration getConfiguration()
Description copied from interface: KeyManagerAPI
Get the current configuration of this KeyManagerAPI. If KeyManagerAPI.setConfiguration(KeyManagerAPIConfiguration) was not yet called, this is null.

Specified by:
getConfiguration in interface KeyManagerAPI
Overrides:
getConfiguration in class AbstractKeyManagerAPI
Returns:
the KeyManagerAPIConfiguration (or null, if not yet configured).

initDateDependentKeyStrategy

public DateDependentKeyStrategyInitResult initDateDependentKeyStrategy(DateDependentKeyStrategyInitParam param)
                                                                throws KeyStoreNotEmptyException,
                                                                       IOException
Description copied from interface: KeyManagerAPI
Initialise a new key-store with the DateDependentKeyStrategy.

Parameters:
param - the settings controlling the details of how to initialise it. Must not be null.
Returns:
Throws:
KeyStoreNotEmptyException
IOException

putUser

public void putUser(String userName,
                    char[] password)
             throws AuthenticationException,
                    IOException
Description copied from interface: KeyManagerAPI
Create a new user or change an existing user's password. If the password of the current user is modified, this instance of KeyManagerAPI will be updated with a new configuration, automatically. Other instances of KeyManagerAPI - even in the same JVM - are not updated, though.

Parameters:
userName - the name of the new user.
password - the password of the new user.
Throws:
AuthenticationException - if the authUserName or the authPassword is incorrect.
IOException - if the communication with the key-store (either local key-store-file or remote key-server) fails.

deleteUser

public void deleteUser(String userName)
                throws AuthenticationException,
                       CannotDeleteLastUserException,
                       IOException
Description copied from interface: KeyManagerAPI
Delete a user. If the specified user does not exist, this method is a no-op. Note, that the current user can delete himself. In this case, a 2nd call to this method would cause an AuthenticationException.

Parameters:
userName - the name of the user to be deleted.
Throws:
AuthenticationException - if the authUserName or the authPassword is incorrect.
CannotDeleteLastUserException - if you attempted to delete the last user (which would render the key-store to be totally unreadable).
IOException - if the communication with the key-store (either local key-store-file or remote key-server) fails.

getCryptoSession

public CryptoSession getCryptoSession(String appServerBaseURL)
                               throws AuthenticationException,
                                      IOException
Description copied from interface: KeyManagerAPI

Get a session for a certain application server.

Parameters:
appServerBaseURL - the base-url of the app-server-key-manager-channel (must not be null). This is the part of the URL before the "/KeyManagerChannel" - e.g. if the REST URL of the KeyManagerChannel-service is "https://serverUsingCumulus4j.mydomain.org/org.cumulus4j.keymanager.back.webapp/KeyManagerChannel", then this must be "https://serverUsingCumulus4j.mydomain.org/org.cumulus4j.keymanager.back.webapp".
Returns:
the session; never null.
Throws:
AuthenticationException - if the authUserName or the authPassword is incorrect.
IOException - if the communication with the key-store (either local key-store-file or remote key-server) fails.

Cumulus4j API
(1.2.0)

Copyright © 2013 NightLabs Consulting GmbH. All Rights Reserved.