Class BaseAuthenticationPlugin
- java.lang.Object
-
- com.portwise.mvpnms.authentication.BaseAuthenticationPlugin
-
- All Implemented Interfaces:
AuthenticationMechanismInterface
- Direct Known Subclasses:
ExampleChallenge
,UsernamePasswordMechanism
public abstract class BaseAuthenticationPlugin extends java.lang.Object implements AuthenticationMechanismInterface
This class can be used as a base for the authentication method plug-ins. It contains a number of convenience methods that are useful when developing custom plug-ins.
-
-
Field Summary
Fields Modifier and Type Field Description protected static CoreLogger
sLogger
-
Fields inherited from interface com.portwise.mvpnms.authentication.AuthenticationMechanismInterface
ARG, AUTHENTICATED, AUTHORIZATION_PARAMETER, CA_STATUS_DISABLED, CA_STATUS_REVOKED, CERT_ERROR_MESSAGE, CERTIFICATE_ATTRIBUTE_MAPPING, CHALLENGE, CVC_FAILED_USER_CERTIFICATE, DO_PARAMETER, DOMAIN, IMAGE_DATA_URI, INVALID_CA_CERTIFICATE, INVALID_CREDENTIALS, INVALID_CRL, INVALID_USER_CERTIFICATE, MESSAGE, NO_CERTIFICATE, NO_PASSWORD, NO_USERNAME, NOT_AUTHENTICATED, NOT_AVAILABLE_SERVICE, NOT_BOUND_USER_CERTIFICATE, NOT_MAPPED_NO_UNIQUE_USER_FOUND, NOT_MAPPED_SUBJECT_DN_IN_CERT, NOT_MAPPED_USER_CERTIFICATE, PASSWORD, RADIUS_REPLY_MESSAGE, REVOKED_USER_CERTIFICATE, SERVER_INDEX, SHARED_SECRET, STATE, SVC_FAILED_USER_CERTIFICATE, TMP_MSG_BOX_URI, TVC_FAILED_CA_CERTIFICATE_EXPIRED, TVC_FAILED_CA_CERTIFICATE_NOT_YET_VALID, TVC_FAILED_USER_CERTIFICATE_EXPIRED, TVC_FAILED_USER_CERTIFICATE_NOT_YET_VALID, URL, USER_ATTRIBUTE_MAPPING, USERNAME, VENDOR
-
-
Constructor Summary
Constructors Constructor Description BaseAuthenticationPlugin()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addSessionAttribute(java.lang.String sessionId, java.lang.String attributeName, java.lang.String attributeValue)
Adds an attribute to the specified session.protected static byte[]
base64decode(java.lang.String data)
Decodes the specified Base64 string into a byte array.protected void
clearSessionAttributes(java.lang.String sessionId)
Removes all attributes from the session.protected AuthenticationMechanismConfiguration
getConfiguration()
Returns the authentication method configuration for this plug-in.protected java.util.Vector
getConfigurationAttributeNameList()
protected java.lang.String
getConfigurationAttributeValue(java.lang.String attributeName)
Returns the value of the specified attribute in the configuration.protected AuthenticationMechanismHandler
getHandler()
Returns the authentication method handler for this plug-in.protected java.lang.String
getNewSessionId()
Returns a new session identifier from the Policy Service session component.protected static java.lang.String
getRequestParameterValue(AuthenticationRequest request, java.lang.String parameterName)
Returns the value of the specified parameter in the request.protected java.util.Vector
getSessionAttributeNameList(java.lang.String sessionId)
Returns a vector of the attribute names contained in the session.protected java.lang.String
getSessionAttributeValue(java.lang.String sessionId, java.lang.String attributeName)
Returns the value for the specified attribute contained in the session.protected static java.lang.Object
getUserAttributeValue(java.lang.String userId, java.lang.String attributeName)
TODO Description and purpose of method.protected static java.lang.String
getUsername(java.lang.String sessionId)
Returns the username for the specified session.boolean
init(AuthenticationMechanismConfiguration configuration, AuthenticationMechanismHandler handler)
Initialization of the authentication method.-
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.portwise.mvpnms.authentication.AuthenticationMechanismInterface
authenticate, exit, getName, needsReloading
-
-
-
-
Field Detail
-
sLogger
protected static CoreLogger sLogger
-
-
Method Detail
-
init
public boolean init(AuthenticationMechanismConfiguration configuration, AuthenticationMechanismHandler handler)
Initialization of the authentication method. The configuration is progressed to the authentication method as well as the handler which can assist the authentication method for instance with session and logging issues. The init() method of sub classes should call this method.- Specified by:
init
in interfaceAuthenticationMechanismInterface
- Parameters:
configuration
- The configuration handler.handler
- The authentication method handler.- Returns:
- The authentication method should return true if it is ready to receive authentication requests. It should return false, if the authentication method already in this call can determine that it will be unable to perform authentication requests, e.g. if for instance a configuration parameter is missing.
-
getConfiguration
protected AuthenticationMechanismConfiguration getConfiguration()
Returns the authentication method configuration for this plug-in. Theinit(AuthenticationMechanismConfiguration, AuthenticationMechanismHandler)
method must have been called prior to calling this method.- Returns:
- The authentication method configuration for this plug-in.
-
getHandler
protected AuthenticationMechanismHandler getHandler()
Returns the authentication method handler for this plug-in. Theinit(AuthenticationMechanismConfiguration, AuthenticationMechanismHandler)
method must have been called prior to calling this method.- Returns:
- The authentication method handler for this plug-in.
-
getConfigurationAttributeNameList
protected java.util.Vector getConfigurationAttributeNameList()
-
getConfigurationAttributeValue
protected java.lang.String getConfigurationAttributeValue(java.lang.String attributeName)
Returns the value of the specified attribute in the configuration.- Parameters:
methodConfigurationList
- The authentication method configuration list.attributeName
- The attribute name to get the value for.- Returns:
- The configuration value.
-
getRequestParameterValue
protected static java.lang.String getRequestParameterValue(AuthenticationRequest request, java.lang.String parameterName)
Returns the value of the specified parameter in the request.- Parameters:
name
- Name of parameter in request objectrequest
- Request object- Returns:
- Value of parameter 'name'
-
getSessionAttributeNameList
protected java.util.Vector getSessionAttributeNameList(java.lang.String sessionId)
Returns a vector of the attribute names contained in the session. The returned vector is never null, but may contain zero elements.- Parameters:
sessionId
- The session ID.- Returns:
- A list of attribute names (strings).
-
getSessionAttributeValue
protected java.lang.String getSessionAttributeValue(java.lang.String sessionId, java.lang.String attributeName)
Returns the value for the specified attribute contained in the session.- Parameters:
sessionID
- The Session ID.attributeName
- The name of attribute.- Returns:
- The value of the attribute.
-
addSessionAttribute
protected void addSessionAttribute(java.lang.String sessionId, java.lang.String attributeName, java.lang.String attributeValue)
Adds an attribute to the specified session.- Parameters:
sessionId
- The session ID.attributeName
- The name of the attribute to add.attributeValue
- The value of the attribute to add.
-
clearSessionAttributes
protected void clearSessionAttributes(java.lang.String sessionId)
Removes all attributes from the session.- Parameters:
sessionId
- The session ID.
-
getNewSessionId
protected java.lang.String getNewSessionId()
Returns a new session identifier from the Policy Service session component. This is needed to be done if the user lacks a session and the authentication method needs to store certain data for the user during a "Challenge" return.- Returns:
- The session ID, may be null when the maximum concurrent session limit is reached.
-
getUsername
protected static java.lang.String getUsername(java.lang.String sessionId)
Returns the username for the specified session. Null is returned if the session doesn't exist.- Parameters:
sessionId
- The session ID.- Returns:
- The username or null.
-
getUserAttributeValue
protected static java.lang.Object getUserAttributeValue(java.lang.String userId, java.lang.String attributeName)
TODO Description and purpose of method. String or Vector of Strings (multi-value) (from LDAP)- Parameters:
userId
-- Returns:
-
base64decode
protected static byte[] base64decode(java.lang.String data)
Decodes the specified Base64 string into a byte array.- Parameters:
data
- The Base64 string to decode.- Returns:
- A decoded byte array.
-
-