com.continuent.tungsten.common.security
Class PasswordManager

java.lang.Object
  extended by com.continuent.tungsten.common.security.PasswordManager

public class PasswordManager
extends java.lang.Object

Class managing passwords in a file. Retrieves, Creates, deletes, updates

Version:
1.0
Author:
Ludovic Launer

Nested Class Summary
static class PasswordManager.ClientApplicationType
           
 
Constructor Summary
PasswordManager(AuthenticationInfo authenticationInfo, PasswordManager.ClientApplicationType clientApplicationType)
          Creates a new PasswordManager object
PasswordManager(java.lang.String securityPropertiesFileLocation)
          Creates a new PasswordManager object
PasswordManager(java.lang.String securityPropertiesFileLocation, PasswordManager.ClientApplicationType clientApplicationType)
          Creates a new PasswordManager object Loads Security related properties from a file.
 
Method Summary
 boolean authenticateUser(java.lang.String username, java.lang.String candidatePassword)
          Tries to authenticate a user with a given password
 void deleteUser(java.lang.String username)
          Delete a user from the password file
 java.lang.String getApplicationSpecificUsername(java.lang.String username)
          Refactor a username prior to adding it into the list.
 AuthenticationInfo getAuthenticationInfo()
           
 java.lang.String getClearTextPasswordForUser(java.lang.String username)
          Get clear text password for a username: decrypts password if needed
 PasswordManager.ClientApplicationType getClientApplicationType()
           
 java.lang.String getEncryptedPasswordForUser(java.lang.String username)
          Get Encrypted (or "as it is") password for a user
 TungstenProperties loadPasswordsAsTungstenProperties()
          Passwords loaded from file as TungstenProperties.
 void setClientApplicationType(PasswordManager.ClientApplicationType clientApplicationType)
           
 void setPasswordForUser(java.lang.String username, java.lang.String password)
          Set and store the password for a given user.
 void try_createAuthenticationInfoFiles()
          When possible, tries to create files needed by the Password Manager.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PasswordManager

public PasswordManager(java.lang.String securityPropertiesFileLocation)
                throws ConfigurationException
Creates a new PasswordManager object

Parameters:
securityPropertiesFileLocation - location of the security.properties file. If set to null will look for the default file.
Throws:
ConfigurationException

PasswordManager

public PasswordManager(java.lang.String securityPropertiesFileLocation,
                       PasswordManager.ClientApplicationType clientApplicationType)
                throws ConfigurationException
Creates a new PasswordManager object Loads Security related properties from a file. File location = {clusterhome}/conf/security.properties

Parameters:
securityPropertiesFileLocation - location of the security.properties file. If set to null will look for the default file.
clientApplicationType - Type of client application. Used to retrieve application specific information (password, ...)
Throws:
ConfigurationException

PasswordManager

public PasswordManager(AuthenticationInfo authenticationInfo,
                       PasswordManager.ClientApplicationType clientApplicationType)
Creates a new PasswordManager object

Parameters:
authenticationInfo - the AuthenticationInfo object from which to retrieve properties
clientApplicationType - Type of client application. Used to retrieve application specific information (password, ...)
Method Detail

loadPasswordsAsTungstenProperties

public TungstenProperties loadPasswordsAsTungstenProperties()
                                                     throws ServerRuntimeException
Passwords loaded from file as TungstenProperties. Example: getPasswordsAsTungstenProperties.get(username);

Returns:
TungstenProperties class containing the passwords
Throws:
ServerRuntimeException

getClearTextPasswordForUser

public java.lang.String getClearTextPasswordForUser(java.lang.String username)
                                             throws ConfigurationException
Get clear text password for a username: decrypts password if needed

Parameters:
username - the username for which to get the password
Throws:
ConfigurationException

getEncryptedPasswordForUser

public java.lang.String getEncryptedPasswordForUser(java.lang.String username)
                                             throws ConfigurationException
Get Encrypted (or "as it is") password for a user

Parameters:
username - the username for which to get the password
Throws:
ConfigurationException

authenticateUser

public boolean authenticateUser(java.lang.String username,
                                java.lang.String candidatePassword)
                         throws ConfigurationException
Tries to authenticate a user with a given password

Parameters:
username -
candidatePassword -
Returns:
true if the user was successfully authenticated, false otherwise.
Throws:
ConfigurationException

setPasswordForUser

public void setPasswordForUser(java.lang.String username,
                               java.lang.String password)
                        throws ServerRuntimeException
Set and store the password for a given user. The password is encryted if authenticationInfo requires so

Parameters:
username -
password -
Throws:
ServerRuntimeException

deleteUser

public void deleteUser(java.lang.String username)
                throws ServerRuntimeException
Delete a user from the password file

Parameters:
username - the username to be deleted from the password file
Throws:
ServerRuntimeException

getApplicationSpecificUsername

public java.lang.String getApplicationSpecificUsername(java.lang.String username)
Refactor a username prior to adding it into the list. Takes into account application specific configuration and add prefix to link username to an application

Parameters:
username - the username to refactor for the current application
Returns:
username with the application specific suffix

try_createAuthenticationInfoFiles

public void try_createAuthenticationInfoFiles()
                                       throws ConfigurationException
When possible, tries to create files needed by the Password Manager. Best effort: not successs guaranted

Throws:
ConfigurationException

getAuthenticationInfo

public AuthenticationInfo getAuthenticationInfo()

getClientApplicationType

public PasswordManager.ClientApplicationType getClientApplicationType()

setClientApplicationType

public void setClientApplicationType(PasswordManager.ClientApplicationType clientApplicationType)