org.idoox.security.pstore
Class PStore

java.lang.Object
  extended byorg.idoox.security.pstore.PStore

public abstract class PStore
extends java.lang.Object

Represents protected storage of security related detabases, methods that allows to get singletons of underlaying UserStore and KeyStore implementations.

Since:
3.0
Component:
Security-Specific

Constructor Summary
protected PStore(java.lang.String password)
          This constructor must be implemented by extenders.
 
Method Summary
 void destroy()
          Releases allocated resources during Wasp destroy.
static PStore getInstance(java.lang.String password)
          returns default instance of protected storage takes parameters from properties.
abstract  KeyStore getKeyStore()
          returns instance of the KeyStore class
protected static KeyStore getKeyStore(java.lang.String password)
          Gets KeyStore instance using security Config property "keystore.impl".
protected static KeyStoreSource getKeyStoreSource()
          Gets KeyStoreSource instance (can be called if the KeyStore/PStore instance needs KeyStoreSource).
abstract  UserStore getUserStore()
          returns instance of the UserStore class
protected static UserStore getUserStore(java.lang.String password)
          Gets UserStore instance using security Config property "userstore.impl".
protected static UserStoreSource getUserStoreSource()
          Gets UserStoreSource instance (can be called if the UserStore/PStore instance needs UserStoreSource).
protected static void registerAdditionalPropertySerializers(UserStore userStore)
          Registers additional property serializers for given userstore.
static void setAdditionalPropertySerializers(java.lang.String[] keys, PropertySerializer[] serializers)
          Sets additional property serializers that are registered to userstore part of protected store.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PStore

protected PStore(java.lang.String password)
          throws BadPasswordException
This constructor must be implemented by extenders.

Parameters:
password - password to unlock the protected storage
Throws:
BadPasswordException - wrong password
Method Detail

getInstance

public static PStore getInstance(java.lang.String password)
                          throws BadPasswordException
returns default instance of protected storage takes parameters from properties.

The instance of protected store is only one for whole Java VM. It must be first unlocked using correct password and it is than available to the rest of the Java VM even without password specification.

Parameters:
password - password to unlock the protected storage
Returns:
instance of PStore
Throws:
BadPasswordException

getKeyStore

public abstract KeyStore getKeyStore()
returns instance of the KeyStore class

Returns:
instance of the KeyStore

getUserStore

public abstract UserStore getUserStore()
returns instance of the UserStore class

Returns:
instance of the UserStore

getKeyStoreSource

protected static KeyStoreSource getKeyStoreSource()
                                           throws java.lang.Exception
Gets KeyStoreSource instance (can be called if the KeyStore/PStore instance needs KeyStoreSource). User store source is received using Java Reflection API and security Config class.
  1. It is first checked, if the "pstore.source" security config property is set. If yes, it is supposed that it contains implementation class of the KeyStoreSource.
  2. If (1) does not apply, the property "pstore.keysource" should contain implementation class of the KeyStoreSource.
Now it has a full name of the implementation class, which is instantiated using reflection API.

Returns:
key store source instance
Throws:
java.lang.Exception - cannot construct/initialize key store source
Since:
4.0
See Also:
Config

getUserStoreSource

protected static UserStoreSource getUserStoreSource()
                                             throws java.lang.Exception
Gets UserStoreSource instance (can be called if the UserStore/PStore instance needs UserStoreSource). User store source is received using Java Reflection API and security Config class.
  1. It is first checked, if "pstore.source" security config property is set. If yes, it is supposed that it contains implementation class of the UserStoreSource.
  2. If (1) does not apply, the property "pstore.usersource" should contain implementation class of the UserStoreSource.
Now it has a full name of the implementation class, which is instantiated using reflection API.

Returns:
user store source instance
Throws:
java.lang.Exception - cannot construct/initialize user store source
Since:
4.0
See Also:
Config

getUserStore

protected static UserStore getUserStore(java.lang.String password)
                                 throws java.lang.Exception
Gets UserStore instance using security Config property "userstore.impl". If Config does not contain the "userstore.impl" property, code>null value is returned.

Parameters:
password - password used to unlock user store
Returns:
user store instance
Throws:
java.lang.Exception - cannot construct/initialize user store
Since:
4.0
See Also:
Config

getKeyStore

protected static KeyStore getKeyStore(java.lang.String password)
                               throws java.lang.Exception
Gets KeyStore instance using security Config property "keystore.impl". If propertiess do not contain the "keystore.impl" property, code>null value is returned.

Parameters:
password - password used to unlock key store
Returns:
key store instance, null if the "keystore.impl" property was not found
Throws:
java.lang.Exception - cannot construct/initialize key store
Since:
4.0
See Also:
Config

registerAdditionalPropertySerializers

protected static void registerAdditionalPropertySerializers(UserStore userStore)
Registers additional property serializers for given userstore. This method can be called by extenders as a part of their initialization.

Parameters:
userStore - property serializers are added to this user
Since:
4.0

setAdditionalPropertySerializers

public static void setAdditionalPropertySerializers(java.lang.String[] keys,
                                                    PropertySerializer[] serializers)
Sets additional property serializers that are registered to userstore part of protected store.

Parameters:
serializers - serializers to register automatically. This method can be called only before first invocation of the getInstance method.
keys - keys for which to register associated serializer
Throws:
java.lang.SecurityException - getInstance method has been already invoked
Since:
4.0

destroy

public void destroy()
Releases allocated resources during Wasp destroy. A custom implementation could override it in order to deallocate its resources.

Since:
4.7