This section contains the following topics:
Configuration of All Custom Classes
Custom Classes for Authentication and Authorization
Create a Custom Authentication Scheme
The following configuration information applies to all custom authentication schemes and active expressions implemented with the Java Authentication API and Java Authorization API:
com.myorg.sdk.myclass
When SiteMinder calls the methods in an instance of your custom class, it passes the specified parameters. The class name is not passed. The parameters are passed as a single string. If the string contains multiple parameters, the parameters can be delimited in any way that the custom class requires.
The basic steps for implementing and deploying custom authentication or authorization classes are as follows:
All custom authentication and authorization classes use the same library file—smjavaapi. This library file is included with the Policy Server. You do not have to modify this library file. You simply reference it when you are configuring your custom authentication or authorization class.
Custom authentication and authorization objects may sometimes need to communicate request-specific information between themselves, such as to preserve state between object instances. These objects can share information through AppSpecificContext, which is retrieved through ApiContext. ApiContext is one of the common classes that is passed to both authentication and authorization objects.
Information shared through AppSpecificContext has request-only scope. For example, a custom object running in the context of an authentication request cannot exchange information with an object running in the context of an authorization request.
The following classes are used by both the Authentication API and the Authorization API. The services that these classes provide include:
The following table summarizes the common classes:
Class |
Description |
---|---|
APIContext |
Allows logging, tracing, and error messages to be sent to the Policy Server. |
AppSpecificContext |
Provides methods that allow custom authentication and authorization objects to share information. |
SmJavaApiException |
Provides exception functionality to custom authentication and authorization objects. |
UserContext |
Allows a custom object to set and retrieve information about a user in a user directory. The information includes user attributes and directory attributes associated with the user. The methods for setting and retrieving user directory attributes are available only if isUserContext() returns true. |
Authentication schemes provide a way to collect a user’s credentials and determine the user’s identity.
The Policy Server includes a variety of standard authentication schemes. These schemes range from basic user name/password authentication and HTML forms-based authentication to digital certificate and token authentication.
If the standard authentication schemes included with the Policy Server do not provide the kind of authentication functionality required at your site, you can use the Java Authentication API to create a custom authentication scheme.
The base interface in the Java Authentication API is SmAuthScheme. All custom authentication schemes created with the Java Authentication API must implement this interface.
SiteMinder calls the following methods in the base interface SmAuthScheme:
Method |
Description |
---|---|
authenticate() |
Performs the custom authentication and returns the authentication result. SiteMinder calls this method at least twice—to establish user context and to authenticate the user’s credentials. |
init() |
Performs any initialization procedures that the authentication scheme requires. SiteMinder calls this method once for each authentication scheme instance, when the authentication scheme is loaded. |
query() |
Provides SiteMinder with either of the following kinds of information, depending on the value SiteMinder passes in the reason parameter (object SmAuthQueryCode): The version and description of the authentication scheme. The kind of credentials that SiteMinder should collect from the user, and optionally, the URL for the site where credentials should be collected. |
release() |
Performs any rundown procedures that the authentication scheme requires. SiteMinder calls this method once for each authentication scheme instance, when SiteMinder is shutting down. |
The following classes are used in conjunction with the SmAuthScheme base interface:
Class |
Description |
---|---|
SmAuthenticationContext |
Contains the following context classes passed to authenticate(): APIContext UserContext UserCredentialsContext The set... methods in this object pass information directly to SiteMinder. |
SmAuthenticationResult |
Contains status and reason codes returned to SiteMinder after a call to authenticate(). |
SmAuthQueryCode |
Contains the type of request that SiteMinder is making of the authentication scheme (version number and description, or information about the credentials that SiteMinder must collect). SiteMinder passes this object to the authentication scheme in query(). |
SmAuthQueryResponse |
Contains constants that specify the kind of credentials that are required for authentication, if any. Also allows a text message to be returned to SiteMinder for display to the user. Optionally, the authentication scheme can call setResponseBuffer() to specify a URL where credentials must be collected. The set... methods in this object pass information directly to SiteMinder. |
SmAuthStatus |
Contains Authentication API status codes such as SMAUTH_ACCEPT and SMAUTH_REJECT. This object can be passed back to SiteMinder in SmAuthenticationResult. It is also the return value type for the authentication scheme’s init(), query(), and release() methods. |
UserCredentialsContext |
Contains credentials information and other information from the user directory where user context was established. This object is contained in the SmAuthenticationContext object passed to authenticate(). |
When user authentication is to occur against a custom authentication scheme created with the Java API, SiteMinder loads the custom scheme by loading:
Immediately after the scheme is loaded, SiteMinder calls the following methods in the custom class implemented from SmAuthScheme:
Note: When SiteMinder passes SMAUTH_QUERY_CREDENTIALS_REQ in query(), SiteMinder is requesting that the authentication scheme specify the kind of credentials that are required. SiteMinder then collects the specified credentials.
The following figure shows the key activities that occur during authentication:
The Java Authentication API supports authentication based on the following general types of credentials requirements:
You specify the authentication credentials that are required through the setResponseBuffer() method in the object SmAuthQueryResponse. This object contains a number of constants that indicate the specific credentials that are required or whether no credentials are required.
The authentication process includes two phases—user disambiguation and user authentication.
Before a user can be authenticated, the user’s profile information must be retrieved from the user store so that the user’s stored credentials can be compared with the credentials supplied at login. Looking up the user in a user store (such as an LDAP user directory or an ODBC database) is called user disambiguation. Either SiteMinder or the authentication scheme can disambiguate the user.
SiteMinder calls SmAuthScheme.authenticate() at least once during the disambiguation phase and at least once during the authentication phase:
The basic steps are as follows:
uid=jsmith,ou=marketing,o=myorg.org
An LDAP search expression can also be used to search an LDAP user directory, and a SQL query is used to search an ODBC database—for example:
(&(objectclass=inetOrgPerson)(uid=jsmith))
select Name from SmUser where Name = 'jsmith'
Multiple results are possible, given that the LDAP DN or the ID stored in the ODBC database might apply to different users who have different passwords.
SiteMinder first calls authenticate() at the beginning of the user disambiguation phase.
Either SiteMinder or the custom authentication scheme can disambiguate the user. The authentication scheme indicates whether it has performed the disambiguation through a combination of the following:
The status codes are set in the SmAuthStatus object. This object is passed in the status parameter of the SmAuthenticationResult constructor. SmAuthenticationResult is returned from authenticate():
The authentication scheme asks SiteMinder to disambiguate the user.
When returning this status code, the authentication scheme should also return an empty string through the setUserText() method. SiteMinder gets the login ID from the Agent, constructs the DN or search expression based on the login ID and the information defined in the SiteMinder User Directory Properties dialog box, and disambiguates the user by looking up the user in the user store.
The authentication scheme asks SiteMinder to disambiguate the user.
The authentication scheme passes the login ID to SiteMinder through setUserText(). SiteMinder uses that value to construct the DN or search expression and disambiguate the user in the user store. This approach gives the authentication scheme the opportunity to modify the login ID before SiteMinder disambiguates the user.
Note: If the authentication scheme passes an empty string in setUserText(), SiteMinder uses the login ID provided by the Agent (the same behavior as with return code SMAUTH_NO_USER_CONTEXT).
The authentication scheme disambiguates the user by constructing the complete DN or search expression and looking up the user in the user store. The authentication scheme passes the user’s complete DN or ODBC database ID to SiteMinder in setUserText(). Only one DN or database ID can be passed in setUserText().
The user cannot be found in the directory.
This is returned if an error condition exists. Error text is returned to SiteMinder through the setUserText() method.
During this phase, SiteMinder calls authenticate() again to allow the authentication scheme to verify the supplied credentials after the user context has been established during disambiguation. The method sets one of the following status codes:
Your authentication scheme can have the Policy Server instruct the agent to perform a redirect. To build redirection capabilities into your authentication scheme:
SmAuthenticationContext.setErrorText()
Authentication results are tied to SiteMinder events. If authentication events are enabled in the realm where the user is being authenticated, SiteMinder evaluates optional policies tied to OnAuthAccept, OnAuthReject, OnAuthAttempt, and OnAuthChallenge rules. You can configure these policies to return custom responses based on a user’s identity, redirect the user to another location based on the result of the authentication, or update the user data in an external database.
The SiteMinder SAML (1.x and 2.0) and WS-Federation authentication schemes process response messages. For business reasons, for example, you might want to add additional steps to further process a response. The Message Consumer Extension API defines an interface that enables you to elaborate on the SAML or WS-Federation response in two ways during the authentication process:
The SiteMinder Java MessageConsumerPlugin API implements the Message Consumer Extension (MCE) interface. You can code to your own requirements and then integrate the custom plug-in into SiteMinder.
The MessageConsumerPlugin includes the following four methods:
Method |
Description |
---|---|
init() |
Performs any initialization procedures that the plug-in requires. SiteMinder calls this method once for each plug-in instance, when the plug-in is loaded. |
release() |
Performs any rundown procedures that the plug-in requires. SiteMinder calls this method once for each plug-in instance, when SiteMinder is shutting down. |
postDisambiguateUser() |
Provides processing to disambiguate a user when the authentication scheme is unable to do so, or to add data for new federation users to a user store. Note that this method receives the decrypted assertion. The decrypted assertion is added to the properties map passed to MCP under the key “_DecryptedAssertion”. |
postAuthenticateUser() |
Provides any additional code to determine the final outcome of assertion processing, regardless of whether the policy server processing results in success or failure. |
SiteMinder provides the following samples of the Message Consumer plug-in class:
The following list describes the MessageConsumerPlugin in an elaborated process of user authentication:
The Java Authorization API lets you implement custom functionality for controlling access to protected resources.
The functionality is provided through custom Java classes that are referenced in Policy Server active expressions. An active expression is a string of variable definitions that appears in the following Policy Server objects:
For example, you might implement a custom Java class that returns true if the user belongs to a particular organizational unit (ou) in an LDAP directory. The ou is passed to the custom Java class in the parameter (param) field of the active expression.
For example, you might define an active response that returns a user’s common name (cn) if the user belongs to the ou passed in the param field of the active expression.
For example, you might define a custom Java class that returns true if a user is a member of a group, such as Directory Administrator, that has permission to view a realm. The group name is passed to the Java class in the param field of the active expression.
Active expressions are constructed in the Policy Server User Interface using the following syntax:
<@ lib=<lib-spec> func=<func-spec> param=<func-params>@>
An active expression based on the Java Authorization API has the following required fields:
You define an active expression when you configure the active policy, rule, or response in the Policy Server User Interface.
When SiteMinder detects an active expression that references a custom Java class, it performs the following tasks:
SiteMinder interprets the result returned by the instance of the custom Java class according to the type of active expression that references the Java class, as follows:
The policy does not fire if the result returned matches any of the following strings (not case-sensitive): FALSE, F, or 0.
Any other result causes the policy to fire.
Otherwise, the behavior is the same as for Active Policies.
(The URL that is passed back might vary according to information passed into the custom Java class. For example, a group name could be passed in the param field of the active expression. The custom Java class could then test for the group name to determine the URL to pass back.)
You specify the cookie name in the SiteMinder Response Attribute Editor.
If the method fails (that is, the method returns -1 or 0), the response attribute is ignored.
The base interface in the Java Authorization API is ActiveExpression. All Java classes that provide custom authorization functionality must implement this interface.
The name of the class that you implement from the base interface must appear in the param field of any associated active expression.
SiteMinder calls the following methods in the base interface ActiveExpression:
Method |
Description |
---|---|
init() |
Performs any initialization procedures that the custom Java class requires. SiteMinder calls this method once per instance of the custom ActiveExpression class. |
invoke() |
Performs the custom authorization functionality in the ActiveExpression object and returns a result. |
release() |
Performs any rundown procedures that the ActiveExpression object requires. SiteMinder calls this method once for each instance of an ActiveExpression class, when SiteMinder is shutting down. |
Note: Classes that implement ActiveExpression should be implemented on a stateless model that does not depend on instance state stored in member variables of the ActiveExpression class.
The following classes in the Authorization API are used in conjunction with the ActiveExpression base interface:
Class |
Description |
---|---|
ActiveExpressionContext |
Contains the following context classes passed to invoke():
|
RequestContext |
Provides information about the user’s access request—for example, the server or resource portion of the request. |
According to SAML specifications, an assertion (SAML 1.x) or response (SAML 2.0) is generated by a producer site and sent to a consumer site for validation. Typically, you will use the default SAML assertion or response that SiteMinder generates at the producer site. If you want to modify the content of the assertion or the reponse, you can do so by implementing the Java assertion generator plug-in. This plug-in is appropriate for both consumers (SAML 1.x) and Service Providers (SAML 2.0).
To modify the SAML assertion or response
The implementation is a plug-in for the SiteMinder Assertion Generator Framework. The Assertion Generator Framework sends a default token to the custom plug-in object. After processing, the custom object passes a modified token to the Assertion Generator Framework.
You configure a custom assertion generator plug-in in any of these ways:
Note: Configuration of the assertion generator plug-in requires a Policy Management API session version of at least v6.0 SP 2.
The following steps outline the interaction between SiteMinder and a custom assertion generator plug-in. The activities begin when an authorized user makes a request, through a SiteMinder Policy Server, for a resource at a site that consumes assertions:
Note: The site consuming assertions can have no more than one assertion generator plug-in defined for it.
A successfully initialized plug-in object remains in cache until SiteMinder shuts down. This avoids having to re-load and re-initialize the object every time the plug-in is required.
When SiteMinder is about to shut down, SiteMinder calls the plug-in’s release() method to allow the plug-in to perform any rundown activities it might require.
When developing and deploying a custom assertion generator plug-in, keep the following points in mind:
Copyright © 2013 CA.
All rights reserved.
|
|