Class AMAuthConfigUtils
- java.lang.Object
-
- com.sun.identity.authentication.config.AMAuthConfigUtils
-
public class AMAuthConfigUtils extends Object
Authentication Configuration Utility.
-
-
Field Summary
Fields Modifier and Type Field Description static StringATTR_NAMEprotected static StringATTR_VALUE_NODEprotected static StringATTR_VALUE_PAIR_NODEprotected static StringbundleNameprotected static StringCLIENT_KEYprotected static StringMODULE_KEYprotected static StringNAMED_CONFIGURATIONprotected static StringNAMED_CONFIGURATION_IDprotected static StringORG_KEYprotected static StringROLE_KEYprotected static StringSERVICE_KEYprotected static StringSERVICE_NAMEprotected static StringSERVICE_VERSIONprotected static StringUSER_KEY
-
Constructor Summary
Constructors Constructor Description AMAuthConfigUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringauthConfigurationEntryToXMLString(List entries)Converts a List ofAuthConfigurationEntryto XML representation according to following DTD.static StringconvertToXMLString(List configs)Converts a List of authentication configuration to XML string representation according to following DTD.static voidcreateNamedConfig(String configName, int priority, Map attributeDataMap, String orgName, SSOToken token)Creates an authentication configuration iniPlanetAMAuthConfigurationservice.static MapgetAllAuthModules(SSOToken token)Returns all supported authentication modulesstatic MapgetAllAuthModules(String orgDN, SSOToken token)Returns all supported authentication modules in an Organization If there are not modules configured at the Organization level then the authentication modules set at Global level will be returned.static SetgetAllNamedConfig(String orgName, SSOToken token)Returns all the authentication configurations defined iniPlanetAMAuthConfigurationservice.static StringgetAuthConfigName(AuthContext.IndexType indexType, String indexName, String organizationDN, String clientType)Returns the authentication configuration name given theAuthContext.IndexTypeandindexName.static StringgetAuthConfigName(String organizationDN, String clientType)Returns the authentication configuration name for the organization based authentication.static StringgetAuthLevelAttribute(Map attrs, String module)Returns authentication level attribute name for module name.static StringgetControlFlagAsString(AppConfigurationEntry.LoginModuleControlFlag controlFlag)Get the string representation of theAppConfigurationEntry.LoginModuleControlFlag.static SetgetGlobalAuthenticators(SSOToken token)Returns the global authenticators.static StringgetModuleName(String className)Returns module name from complete class name.static StringgetModuleServiceName(String module)Returns SM service name based on module namestatic Map<String,Set<String>>getNamedConfig(String configName, String orgName, SSOToken token)Returns the authentication configuration defined iniPlanetAMAuthConfigurationservice as XML string.static StringgetNewModuleServiceName(String module)static ServiceSchemagetServiceSchema(SSOToken token)Returns service schema object for the authentication configuration subschema.static AppConfigurationEntry[]parseValues(String xmlValue)Parses the string value for the authentication configuration based on the attribute DTD and return an array ofAppConfigurationEntrywhich could be used to retrieve module name, flag and options.static voidremoveNamedConfig(String configName, String orgName, SSOToken token)Removes an authentication configuration defined iniPlanetAMAuthConfigurationservice.static voidreplaceNamedConfig(String configName, int priority, Map attributeDataMap, String orgName, SSOToken token)Replaces an existing authentication configuration defined iniPlanetAMAuthConfigurationservice.static ListxmlToAuthConfigurationEntry(String xmlValue)Parses the string value for the authentication configuration based on the attribute DTD and return a List ofAuthConfigurationEntrywhich could be used to retrieve module name, flag and options.
-
-
-
Field Detail
-
SERVICE_NAME
protected static final String SERVICE_NAME
- See Also:
- Constant Field Values
-
NAMED_CONFIGURATION
protected static final String NAMED_CONFIGURATION
- See Also:
- Constant Field Values
-
NAMED_CONFIGURATION_ID
protected static final String NAMED_CONFIGURATION_ID
- See Also:
- Constant Field Values
-
SERVICE_VERSION
protected static final String SERVICE_VERSION
- See Also:
- Constant Field Values
-
ATTR_VALUE_PAIR_NODE
protected static final String ATTR_VALUE_PAIR_NODE
- See Also:
- Constant Field Values
-
ATTR_VALUE_NODE
protected static final String ATTR_VALUE_NODE
- See Also:
- Constant Field Values
-
ATTR_NAME
public static final String ATTR_NAME
- See Also:
- Constant Field Values
-
MODULE_KEY
protected static final String MODULE_KEY
- See Also:
- Constant Field Values
-
USER_KEY
protected static final String USER_KEY
- See Also:
- Constant Field Values
-
ORG_KEY
protected static final String ORG_KEY
- See Also:
- Constant Field Values
-
SERVICE_KEY
protected static final String SERVICE_KEY
- See Also:
- Constant Field Values
-
ROLE_KEY
protected static final String ROLE_KEY
- See Also:
- Constant Field Values
-
CLIENT_KEY
protected static final String CLIENT_KEY
- See Also:
- Constant Field Values
-
bundleName
protected static String bundleName
-
-
Method Detail
-
parseValues
public static AppConfigurationEntry[] parseValues(String xmlValue)
Parses the string value for the authentication configuration based on the attribute DTD and return an array ofAppConfigurationEntrywhich could be used to retrieve module name, flag and options. Empty array ofAppConfigurationEntrywill be returned if the XML value could not be parsed.- Parameters:
xmlValue- XML string value for the authentication configuration.- Returns:
- Array of
AppConfigurationEntryeach contains module name, flag and options.
-
getAuthConfigName
public static String getAuthConfigName(AuthContext.IndexType indexType, String indexName, String organizationDN, String clientType) throws AMConfigurationException
Returns the authentication configuration name given theAuthContext.IndexTypeandindexName. The authentication configuration name will be used as theconfigNameforgetAppConfigurationEntry()function inAMConfiguration.- Parameters:
indexType- TheAuthContext.IndexType, one of the following values:AuthContext.IndexType.MODULE_INSTANCE,AuthContext.IndexType.SERVICE,AuthContext.IndexType.ROLEorAuthContext.IndexType.USER.indexName- The corresponding index value for theIndexType, forROLEandUSER, DNs must be passed in.organizationDN- DN for the login organization.clientType- Client type, examplegenericHTML.- Returns:
- Corresponding authentication configuration name.
- Throws:
AMConfigurationException- ifindexTypeis not supported.
-
getAuthConfigName
public static String getAuthConfigName(String organizationDN, String clientType)
Returns the authentication configuration name for the organization based authentication. The authentication configuration name will be used as theconfigNameforgetAppConfigurationEntry(). function inAMConfiguration.- Parameters:
organizationDN- DN for the login organization.clientType-- Returns:
- Corresponding authentication configuration name.
-
convertToXMLString
public static String convertToXMLString(List configs)
Converts a List of authentication configuration to XML string representation according to following DTD.<!-- AttributeValuePair defines the values used to specify authentication configuration information. --> <!ELEMENT AttributeValuePair (Value*) > <!-- Value defines one authentication configuration --> <!ELEMENT Value (#PCDATA) >- Parameters:
configs- List of configurations to be processed, each value consists of following parts separated by blank space:module_nameflagoption1,option2.- Returns:
- XML representation of the configuration .
-
createNamedConfig
public static void createNamedConfig(String configName, int priority, Map attributeDataMap, String orgName, SSOToken token) throws SMSException, SSOException, AMConfigurationException
Creates an authentication configuration iniPlanetAMAuthConfigurationservice. This method will be used by console to manage configurations for different services.- Parameters:
configName- Name of the authentication configuration.priority- Priority of this authentication configuration.attributeDataMap- Map of authentication service attributes.orgName- Organization DN.token- Single sign on token.- Throws:
SMSException- if failed to store the configuration because of SM Exception.SSOException- if single sign on token is not valid.AMConfigurationException- if theconfigNameis null.
-
replaceNamedConfig
public static void replaceNamedConfig(String configName, int priority, Map attributeDataMap, String orgName, SSOToken token) throws SMSException, SSOException, AMConfigurationException
Replaces an existing authentication configuration defined iniPlanetAMAuthConfigurationservice. This method will be used by console to manage configurations for different services.- Parameters:
configName- Name of the authentication configuration.priority- Priority of the configuration.attributeDataMap- Map of authentication service attributes.orgName- Organization DN.token- Single sign on token.- Throws:
SMSException- if failed to set the configuration because of SM Exception.SSOException- if single sign on token is not valid.AMConfigurationException- ifconfigNameis null or not defined.
-
removeNamedConfig
public static void removeNamedConfig(String configName, String orgName, SSOToken token) throws SMSException, SSOException, AMConfigurationException
Removes an authentication configuration defined iniPlanetAMAuthConfigurationservice. This method will be used by console to manage configurations for different services.- Parameters:
configName- Name of the authentication configuration.orgName- Organization DN.token- Single Sign On token.- Throws:
SMSException- if failed to delete the configuration because of SM Exception.SSOException- if single sign on token is not valid.AMConfigurationException- ifconfigNameis null or not defined .
-
getAllNamedConfig
public static Set getAllNamedConfig(String orgName, SSOToken token) throws SMSException, SSOException
Returns all the authentication configurations defined iniPlanetAMAuthConfigurationservice. This method will be used by console to manage configurations for different services.- Parameters:
orgName- Organization DN.token- Single Sign On token.- Returns:
- Set which contains all the configuration names
- Throws:
SMSException- if failed to get configurations because of SM Exception.SSOException- if single sign on token is not valid.
-
getNamedConfig
public static Map<String,Set<String>> getNamedConfig(String configName, String orgName, SSOToken token) throws SMSException, SSOException, AMConfigurationException
Returns the authentication configuration defined iniPlanetAMAuthConfigurationservice as XML string. This method will be used by console to manage configurations for different services.Here is a sample XML string for an authentication configuration
<AttributeValuePair>
This means user need to pass a required LDAP Login module, then an optional RADIUS Login module.
<Value>com.sun.identity.authentication.modules.LDAP required debug=true</Value>
<Value>com.sun.identity.authentication.modules.RADIUS optional</Value> </AttributeValuePair>- Parameters:
configName- Name of the authentication configuration.orgName- Organization DN.token- Single Sign On token.- Returns:
- Map containing authentication service attributes.
- Throws:
SMSException- if failed to get the configuration because of SM Exception.SSOException- if single sign on token is not valid.AMConfigurationException- ifconfigNameis null or not defined.
-
getModuleName
public static String getModuleName(String className)
Returns module name from complete class name.- Parameters:
className- Class name, examplecom.sun.identity.authentication.modules.ldap.LDAP.- Returns:
- module name, e.g. "LDAP"
-
getModuleServiceName
public static String getModuleServiceName(String module)
Returns SM service name based on module name- Parameters:
module- Login module name, e.g. "LDAP"- Returns:
- Service name for the login module, example
iPlanetAMAuthLDAPService
-
getAuthLevelAttribute
public static String getAuthLevelAttribute(Map attrs, String module)
Returns authentication level attribute name for module name.- Parameters:
attrs- parameter map of the module service.module- Login module name, e.g. "LDAP".- Returns:
- attribute name for authentication level
example
iplanet-am-auth-ldap-auth-levelorsunIdentityServerLDAPAuthLevel.
-
getServiceSchema
public static ServiceSchema getServiceSchema(SSOToken token) throws AMConfigurationException
Returns service schema object for the authentication configuration subschema.- Parameters:
token- Single Sign On token.- Returns:
- Service Schema.
- Throws:
AMConfigurationException- if there are errors accessing authentication configuration.
-
getAllAuthModules
public static Map getAllAuthModules(SSOToken token)
Returns all supported authentication modules- Parameters:
token- Single Sign On token to be using for accessing configuration information.- Returns:
- Map contains all modules, key is the module name (e.g. LDAP),
value is the complete class name (example
com.sun.identity.authentication.modules.ldap.LDAP)
-
getAllAuthModules
public static Map getAllAuthModules(String orgDN, SSOToken token)
Returns all supported authentication modules in an Organization If there are not modules configured at the Organization level then the authentication modules set at Global level will be returned.- Parameters:
orgDN- organization DN.token- single sign on token.- Returns:
- Map contains all modules, key is the module name (e.g. LDAP),
value is the complete class name (e.g.
com.sun.identity.authentication.modules.ldap.LDAP)
-
xmlToAuthConfigurationEntry
public static List xmlToAuthConfigurationEntry(String xmlValue)
Parses the string value for the authentication configuration based on the attribute DTD and return a List ofAuthConfigurationEntrywhich could be used to retrieve module name, flag and options. Empty List will be returned if the XML value could not be parsed.- Parameters:
xmlValue- XML value for the authentication configuration.- Returns:
- List of
AuthConfigurationEntrycontains module name, flag and options.
-
authConfigurationEntryToXMLString
public static String authConfigurationEntryToXMLString(List entries)
Converts a List ofAuthConfigurationEntryto XML representation according to following DTD.<!-- AttributeValuePair defines the values used to specify authentication configuration information. --> <!ELEMENT AttributeValuePair (Value*) > <!-- Value defines one authentication configuration --> <!ELEMENT Value (#PCDATA) >- Parameters:
entries- List ofAuthConfigurationEntryto be processed.- Returns:
- XML representation of the configuration.
-
getGlobalAuthenticators
public static Set getGlobalAuthenticators(SSOToken token)
Returns the global authenticators.- Parameters:
token- Single sign on token to access configuration information.- Returns:
- the global Authenticators.
-
getControlFlagAsString
public static String getControlFlagAsString(AppConfigurationEntry.LoginModuleControlFlag controlFlag)
Get the string representation of theAppConfigurationEntry.LoginModuleControlFlag.- Parameters:
controlFlag- TheAppConfigurationEntry.LoginModuleControlFlag- Returns:
- A string representing the
AppConfigurationEntry.LoginModuleControlFlag.
-
-