com.webmethods.caf.portalclient.dir
Class PCDirectoryHelper

java.lang.Object
  extended by com.webmethods.caf.portalclient.dir.PCDirectoryHelper

public class PCDirectoryHelper
extends Object

Provides a variety of higher level functions to simplify common tasks such as:


Nested Class Summary
static class PCDirectoryHelper.ATTR_NAMES
          Constants for user attribute name
static class PCDirectoryHelper.DIR_ALIAS
          Static constants to identify common aliases in MWS
 
Field Summary
static int TYPE_GROUP
          Parameter constant to specify group principals
static int TYPE_ROLE
          Parameter constant to specify role principals
static int TYPE_USER
          Parameter constant to specify user principals
 
Constructor Summary
PCDirectoryHelper()
           
 
Method Summary
static View authenticateUser(String userID, String password)
          Authenticate a user with the given userID and password
static Map getAllAttributes(URI principalURI)
          Get a map of all attributes associated with a given principal
static Object getAttribute(URI principalAttrProviderURI, URI principalURI, String attrName)
          Get a specific attribute from a specific principal attribute provider for a principal
static Map getAttributes(URI principalAttrProviderURI, URI principalURI)
          Get a map of attributes for a principal from a specific attribute provider
static ThingIDList getDirectorySvcs()
          Get a ThingIDList of all available directory services
static String getDirectoryURI(View view)
          Get a directory URI from a View of a principal
static ListView getMembers(URI principalURI)
          Get a list of members of a group or role
static ListView getMembership(URI principalURI, int type)
          Get a list of groups or roles that a principal has membership in
static View getPrincipalAttributeProvider(String alias)
          Get a View of a principal attribute provider given the provider's alias
static View getSystemDirSvc()
          Get a View of the MWS system directory service
static TypedAttribute getTypedAttribute(URI principalAttrProviderURI, URI principalURI, String attrName)
          Get a specified attribute for a principal from a specific attribute provider.
static Map getTypedAttributes(URI principalAttrProviderURI, URI principalURI)
          Get a map of attributes for a principal from a specific attribute provider.
static View getView(URI uri)
          Get a View that exposes the properties of a specified MWS thing
static ThingIDList listRoles()
          Retrieve a list of all role defined in the system
static View lookupPrincipalByDN(String dn, int type)
          Lookup a user/group/role based on the principal's dynamic name
static View lookupPrincipalByID(String id, int type)
          Lookup a user/group/role based on id
static ListView searchDirectory(URI directoryServiceURI, String search, int type)
          Pperforms a search query for principals of a certain type in a specific directory service
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TYPE_USER

public static final int TYPE_USER
Parameter constant to specify user principals

See Also:
Constant Field Values

TYPE_GROUP

public static final int TYPE_GROUP
Parameter constant to specify group principals

See Also:
Constant Field Values

TYPE_ROLE

public static final int TYPE_ROLE
Parameter constant to specify role principals

See Also:
Constant Field Values
Constructor Detail

PCDirectoryHelper

public PCDirectoryHelper()
Method Detail

getView

public static View getView(URI uri)
                    throws Exception
Get a View that exposes the properties of a specified MWS thing

Parameters:
uri - the MWS thing URI to retrieve a View for
Returns:
a View object that exposes properties of the specified MWS thing
Throws:
Exception

lookupPrincipalByID

public static View lookupPrincipalByID(String id,
                                       int type)
                                throws Exception
Lookup a user/group/role based on id

Parameters:
id - the principal ID
type - the principal type, either PCDirectoryHelper.TYPE_GROUP, PCDirectoryHelper.TYPE_ROLE or PCDirectoryHelper.TYPE_USER
Returns:
view a View object exposing the properties of the retreived principal, may be null if the principal ID does not exist
Throws:
Exception

lookupPrincipalByDN

public static View lookupPrincipalByDN(String dn,
                                       int type)
                                throws Exception
Lookup a user/group/role based on the principal's dynamic name

Parameters:
dn - the principal DN
type - the principal type, either PCDirectoryHelper.TYPE_GROUP, PCDirectoryHelper.TYPE_ROLE or PCDirectoryHelper.TYPE_USER
Returns:
view a View object exposing the properties of the retreived principal, may be null if the principal DN does not exist
Throws:
Exception

searchDirectory

public static ListView searchDirectory(URI directoryServiceURI,
                                       String search,
                                       int type)
                                throws Exception
Pperforms a search query for principals of a certain type in a specific directory service

Parameters:
directoryServiceURI - the URI of the directory service to search
search - The search string. Wildcarding is implied, e.g. 'bob' will match user 'bobby' and 'kabob'
type - the principal type to search for, either PCDirectoryHelper.TYPE_GROUP, PCDirectoryHelper.TYPE_ROLE or PCDirectoryHelper.TYPE_USER
Returns:
listview a ListView object containing those principal Views that matched the query string
Throws:
Exception

getAllAttributes

public static Map getAllAttributes(URI principalURI)
                            throws Exception
Get a map of all attributes associated with a given principal

Parameters:
principalURI - the URI identifying the principal to retrieve attributes for
Returns:
a Map of attributes for the specified principal, may be null
Throws:
Exception

getAttributes

public static Map getAttributes(URI principalAttrProviderURI,
                                URI principalURI)
                         throws Exception
Get a map of attributes for a principal from a specific attribute provider

Parameters:
principalAttrProviderURI - the URI of the attribute provider to retrieve attributes from, null returns the principal's core attributes
principalURI - the URI identifying the principal to retrieve attributes for
Returns:
a Map of attributes for the specified principal, may be null
Throws:
Exception

getAttribute

public static Object getAttribute(URI principalAttrProviderURI,
                                  URI principalURI,
                                  String attrName)
                           throws Exception
Get a specific attribute from a specific principal attribute provider for a principal

Parameters:
principalAttrProviderURI - the URI of the attribute provider to retrieve attributes from, null returns the principal's core attributes
principalURI - the URI identifying the principal to retrieve attributes for
attrName - the attribute name to retrieve
Returns:
the attribute value (maybe null)
Throws:
Exception

getTypedAttributes

public static Map getTypedAttributes(URI principalAttrProviderURI,
                                     URI principalURI)
                              throws Exception
Get a map of attributes for a principal from a specific attribute provider. Note: this is primarily used for dynamic attributes on principals that have attributes provided by the PCDirectoryHelper.DIR_ALIAS.PAP_DYN_ATTR_MAP attribute provider, which contain information about attribute data types

Parameters:
principalAttrProviderURI - the URI of the attribute provider to retrieve attributes from, null returns the principal's core attributes
principalURI - the URI identifying the principal to retrieve attributes for
Returns:
a map of name/TypedAttribute pairs
Throws:
Exception

getTypedAttribute

public static TypedAttribute getTypedAttribute(URI principalAttrProviderURI,
                                               URI principalURI,
                                               String attrName)
                                        throws Exception
Get a specified attribute for a principal from a specific attribute provider. Note: this is primarily used for dynamic attributes on principals that have attributes provided by the PCDirectoryHelper.DIR_ALIAS.PAP_DYN_ATTR_MAP attribute provider, which contain information about attribute data types

Parameters:
principalAttrProviderURI - the URI of the attribute provider to retrieve attributes from, null returns the principal's core attributes
principalURI - the URI identifying the principal to retrieve attributes for
attrName - the name of the attribute to retrieve
Returns:
the attribute as a TypedAttribute, the object may be null
Throws:
Exception

getMembers

public static ListView getMembers(URI principalURI)
                           throws Exception
Get a list of members of a group or role

Parameters:
principalURI - the URI identifying the principal to retrieve membership for
Returns:
a ListView of principals that are members of this group or role
Throws:
Exception

getMembership

public static ListView getMembership(URI principalURI,
                                     int type)
                              throws Exception
Get a list of groups or roles that a principal has membership in

Parameters:
principalURI - he URI identifying the principal to retrieve membership in
type - type the principal membership to retrieve, either PCDirectoryHelper.TYPE_GROUP, PCDirectoryHelper.TYPE_ROLE
Returns:
a ListView of roles or groups that the principal is a member of
Throws:
Exception

listRoles

public static ThingIDList listRoles()
                             throws Exception
Retrieve a list of all role defined in the system

Returns:
a ThingIDList containing the role URIs of all roles defined in the MWS system
Throws:
Exception

authenticateUser

public static View authenticateUser(String userID,
                                    String password)
                             throws Exception
Authenticate a user with the given userID and password

Parameters:
userID - the userID to authenticate
password - the password to use to authenticate
Returns:
a View of user if authenticated, may be null
Throws:
Exception

getSystemDirSvc

public static View getSystemDirSvc()
                            throws Exception
Get a View of the MWS system directory service

Returns:
a View of the MWS system directory service
Throws:
Exception

getDirectorySvcs

public static ThingIDList getDirectorySvcs()
                                    throws Exception
Get a ThingIDList of all available directory services

Returns:
a ThingIDList of all available MWS directory services
Throws:
Exception

getPrincipalAttributeProvider

public static View getPrincipalAttributeProvider(String alias)
                                          throws Exception
Get a View of a principal attribute provider given the provider's alias

Parameters:
alias - the provider to retrieve, see PCDirectoryHelper.DIR_ALIAS for a list of well known principal attribute provider aliases
Returns:
a View of the attribute provider
Throws:
Exception

getDirectoryURI

public static String getDirectoryURI(View view)
                              throws Exception
Get a directory URI from a View of a principal

Parameters:
view - a principal View to extract the principal URI from
Returns:
the directory URI of the principal as a String
Throws:
Exception