SiteMinder
Java SDK r12.51


com.netegrity.policyserver.smapi
Class UserContext

java.lang.Object
  extended by com.netegrity.policyserver.smapi.UserContext

public class UserContext
extends java.lang.Object

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 and for authenticating a user are available only if isUserContext() returns true.

Since:
SDK 6.0

Field Summary
static int DEFAULT_BUFFER_SIZE
          The default buffer size is 100 bytes.
 
Constructor Summary
UserContext(long lpUserContext)
          Construct an UserContext from the SiteMinder context pointers.
UserContext(UserContext userContext)
          Construct a user context from a UserContext instance.
 
Method Summary
 java.lang.String authenticateUser(java.lang.String password)
          Authenticates a user whose context in the user directory has been established.
 java.lang.String authenticateUser(java.lang.String password, int msgBufferSize, int errBufferSize)
          Authenticates a user whose context in the user directory has been established.
 java.lang.String getDirNameSpace()
          Retrieves the directory namespace, such as LDAP:, WinNT:, or ODBC:.
 java.lang.String getDirPath()
          Retrieves the directory path (in SiteMinder notation) of a SiteMinder user directory where the user's context was established.
 java.lang.String getDirServer()
          Retrieves the directory server of a SiteMinder user directory where user's context was established.
 java.lang.String getDnProp(java.lang.String DN, java.lang.String propName)
          Retrieves the value of the specified property of the specified DN.
 java.lang.String getDnProp(java.lang.String DN, java.lang.String propName, int bufferSize)
          Retrieves the value of the specified property of the specified DN.
 java.lang.String getProp(java.lang.String propName)
          Retrieves the value of the specified user property.
 java.lang.String getProp(java.lang.String propName, int bufferSize)
          Retrieves the value of the specified user property.
 java.lang.String getSessionID()
          Retrieves the session ID that has been or will be assigned to the user's session, depending on whether the session has been established.
 java.lang.String getUserName()
          Retrieves the full distinguished name of the user.
 java.lang.String getUserPath()
          Retrieves the user path in SiteMinder notation.
 boolean isUserContext()
          Indicates that SiteMinder has established the user's identity, and that the user context information is available to retrieve and set.
 int setDnProp(java.lang.String DN, java.lang.String propName, java.lang.String value)
          Sets the property value of a directory object DN.
 int setProp(java.lang.String propName, java.lang.String value)
          Sets a value for the specified user property.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_BUFFER_SIZE

public static final int DEFAULT_BUFFER_SIZE

The default buffer size is 100 bytes. If a method in this class is affected by the default, the method description will indicate it.

See Also:
Constant Field Values
Constructor Detail

UserContext

public UserContext(long lpUserContext)
Construct an UserContext from the SiteMinder context pointers.

Parameters:
lpApiContext - the C++ pointer to lpApiContext

UserContext

public UserContext(UserContext userContext)
Construct a user context from a UserContext instance.

Parameters:
UserContext - The Java UserContext object.
Method Detail

isUserContext

public boolean isUserContext()

Indicates that SiteMinder has established the user's identity, and that the user context information is available to retrieve and set.

Returns:
A boolean indicating whether SiteMinder has established the user's identity.

getUserName

public java.lang.String getUserName()

Retrieves the full distinguished name of the user.

Returns:
The full distinguished name of the user.

getUserPath

public java.lang.String getUserPath()

Retrieves the user path in SiteMinder notation.

SiteMinder notation has the following format:
    directory-namespace + server + / + user-DN
For example:
     ldap://server.company.com/uid=user1,ou=people,o=company.com

Returns:
The user path in SiteMinder notation.

getDirPath

public java.lang.String getDirPath()

Retrieves the directory path (in SiteMinder notation) of a SiteMinder user directory where the user's context was established.

Returns:
The directory path in SiteMinder notation.

getDirServer

public java.lang.String getDirServer()

Retrieves the directory server of a SiteMinder user directory where user's context was established.

Returns:
The directory server where the user's context was established.

getDirNameSpace

public java.lang.String getDirNameSpace()

Retrieves the directory namespace, such as LDAP:, WinNT:, or ODBC:.

Returns:
The directory namespace.

getSessionID

public java.lang.String getSessionID()

Retrieves the session ID that has been or will be assigned to the user's session, depending on whether the session has been established.

Returns:
The session ID for the user's session.

getDnProp

public java.lang.String getDnProp(java.lang.String DN,
                                  java.lang.String propName)

Retrieves the value of the specified property of the specified DN. The user whose context has been established must be associated with the DN (for example, the user is a member of a group).

The retrieved property value should be no larger than DEFAULT_BUFFER_SIZE bytes long. Larger attributes are truncated to DEFAULT_BUFFER_SIZE.

Parameters:
DN - The DN of an object in the user directory. The user must be associated with this DN.
propName - The name of the DN property to retrieve.
Returns:
The value of the specified property, or null if not available. For information on the format of multiple values retrieved from a multi-valued LDAP attribute, see setProp().

getDnProp

public java.lang.String getDnProp(java.lang.String DN,
                                  java.lang.String propName,
                                  int bufferSize)

Retrieves the value of the specified property of the specified DN. The user whose context has been established must be associated with the DN (for example, the user is a member of a group).

The retrieved property value should be no larger than the maximum length specified in the bufferSize parameter. Larger attributes are truncated to bufferSize.

Parameters:
DN - The DN of an object in the user directory. The user must be associated with this DN.
propName - The name of the DN property to retrieve.
bufferSize - The maximum length of the retrieved value.
Returns:
The value of the specified property, or null if not available. For information on the format of multiple values retrieved from a multi-valued LDAP attribute, see setProp().

setDnProp

public int setDnProp(java.lang.String DN,
                     java.lang.String propName,
                     java.lang.String value)

Sets the property value of a directory object DN. The user whose context has been established must be associated with the object (for example, the user is a member of a group).

Parameters:
DN - The DN of an object in the user directory. The user must be associated with this DN.
propName - The name of the DN property to set.
value - The value to assign to the DN property. For information on setting multiple values in this parameter for an LDAP multi-valued attribute, see setProp().
Returns:
0 if successful, or -1 if unsuccessful.

getProp

public java.lang.String getProp(java.lang.String propName)

Retrieves the value of the specified user property.

The retrieved property value should be no larger than DEFAULT_BUFFER_SIZE bytes long. Larger attributes are truncated to DEFAULT_BUFFER_SIZE.

Parameters:
propName - The name of the user property to retrieve.
Returns:
The value of the specified property, or null if not available. For information on the format of multiple values retrieved from a multi-valued LDAP attribute, see setProp().

getProp

public java.lang.String getProp(java.lang.String propName,
                                int bufferSize)

Retrieves the value of the specified user property.

The retrieved property value should be no larger than the maximum length specified in the bufferSize parameter. Larger attributes are truncated to bufferSize.

Parameters:
propName - The name of the user property to retrieve.
bufferSize - The maximum length of the retrieved value.
Returns:
The value of the specified property, or null if not available. For information on the format of multiple values retrieved from a multi-valued LDAP attribute, see setProp().

setProp

public int setProp(java.lang.String propName,
                   java.lang.String value)

Sets a value for the specified user property.

When setting or retrieving multi-valued attributes in an LDAP user store, the values are presented in a single string, delimited by a carat character (^). For example, you might set three different telephone numbers in the value parameter as follows:
      "111-1234^111-5678^111-0000" 
Custom code that sets or retrieves multi-valued attributes must support the expected multi-valued string format.

Note: ODBC user stores do not support multi-valued attribute settings.

Parameters:
propName - The name of the user property to set.
value - The value to assign to the user property.
Returns:
0 if successful, or -1 if unsuccessful.

authenticateUser

public java.lang.String authenticateUser(java.lang.String password)
                                  throws UserAuthenticationException

Authenticates a user whose context in the user directory has been established.

The returned user message and any possible error text will be no larger than DEFAULT_BUFFER_SIZE bytes long.

Parameters:
password - The password to verify for this user.
Returns:
The user message, or null if authentication fails.
Throws:
UserAuthenticationException

authenticateUser

public java.lang.String authenticateUser(java.lang.String password,
                                         int msgBufferSize,
                                         int errBufferSize)
                                  throws UserAuthenticationException

Authenticates a user whose context in the user directory has been established.

The returned user message will be no larger than the maximum length defined in the msgBufferSize parameter.

Parameters:
password - The password to verify for this user.
msgBufferSize - The maximum length of the returned user message.
errBufferSize - The maximum length of the error message in a thrown UserAuthenticationException.
Returns:
The user message, or null if authentication fails.
Throws:
UserAuthenticationException

SiteMinder
Java SDK r12.51

Mon 04/08/2013

http://ca.com
Copyright (c) 2013 CA.