Class PCDirectoryHelper
java.lang.Object
com.webmethods.caf.portalclient.dir.PCDirectoryHelper
Provides a variety of higher level functions
to simplify common tasks such as:
- getting views and lookin up principals
- getting principal attributes
- getting membership information
- getting system information
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Constants for user attribute namestatic class
Static constants to identify common aliases in MWS -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Parameter constant to specify group principalsstatic final int
Parameter constant to specify role principalsstatic final int
Parameter constant to specify user principals -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic View
authenticateUser
(String userID, String password) Authenticate a user with the given userID and passwordgetAllAttributes
(URI principalURI) Get a map of all attributes associated with a given principalstatic Object
getAttribute
(URI principalAttrProviderURI, URI principalURI, String attrName) Get a specific attribute from a specific principal attribute provider for a principalgetAttributes
(URI principalAttrProviderURI, URI principalURI) Get a map of attributes for a principal from a specific attribute providerstatic ThingIDList
Get a ThingIDList of all available directory servicesstatic String
getDirectoryURI
(View view) Get a directory URI from a View of a principalstatic ListView
getMembers
(URI principalURI) Get a list of members of a group or rolestatic ListView
getMembership
(URI principalURI, int type) Get a list of groups or roles that a principal has membership instatic View
Get a View of a principal attribute provider given the provider's aliasstatic View
Get a View of the MWS system directory servicestatic 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
Get a View that exposes the properties of a specified MWS thingstatic ThingIDList
Retrieve a list of all role defined in the systemstatic View
lookupPrincipalByDN
(String dn, int type) Lookup a user/group/role based on the principal's dynamic namestatic View
lookupPrincipalByID
(String id, int type) Lookup a user/group/role based on idstatic ListView
searchDirectory
(URI directoryServiceURI, String search, int type) Pperforms a search query for principals of a certain type in a specific directory service
-
Field Details
-
TYPE_USER
public static final int TYPE_USERParameter constant to specify user principals- See Also:
-
TYPE_GROUP
public static final int TYPE_GROUPParameter constant to specify group principals- See Also:
-
TYPE_ROLE
public static final int TYPE_ROLEParameter constant to specify role principals- See Also:
-
-
Constructor Details
-
PCDirectoryHelper
public PCDirectoryHelper()
-
-
Method Details
-
getView
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
Lookup a user/group/role based on id- Parameters:
id
- the principal IDtype
- the principal type, eitherTYPE_GROUP
,TYPE_ROLE
orTYPE_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
Lookup a user/group/role based on the principal's dynamic name- Parameters:
dn
- the principal DNtype
- the principal type, eitherTYPE_GROUP
,TYPE_ROLE
orTYPE_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 searchsearch
- The search string. Wildcarding is implied, e.g. 'bob' will match user 'bobby' and 'kabob'type
- the principal type to search for, eitherTYPE_GROUP
,TYPE_ROLE
orTYPE_USER
- Returns:
- listview a ListView object containing those principal Views that matched the query string
- Throws:
Exception
-
getAllAttributes
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<String,Object> 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 attributesprincipalURI
- 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 attributesprincipalURI
- the URI identifying the principal to retrieve attributes forattrName
- 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 thePCDirectoryHelper.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 attributesprincipalURI
- 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 thePCDirectoryHelper.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 attributesprincipalURI
- the URI identifying the principal to retrieve attributes forattrName
- the name of the attribute to retrieve- Returns:
- the attribute as a
TypedAttribute
, the object may be null - Throws:
Exception
-
getMembers
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
Get a list of groups or roles that a principal has membership in- Parameters:
principalURI
- he URI identifying the principal to retrieve membership intype
- type the principal membership to retrieve, eitherTYPE_GROUP
,TYPE_ROLE
- Returns:
- a ListView of roles or groups that the principal is a member of
- Throws:
Exception
-
listRoles
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
Authenticate a user with the given userID and password -
getSystemDirSvc
Get a View of the MWS system directory service- Returns:
- a View of the MWS system directory service
- Throws:
Exception
-
getDirectorySvcs
Get a ThingIDList of all available directory services- Returns:
- a ThingIDList of all available MWS directory services
- Throws:
Exception
-
getPrincipalAttributeProvider
Get a View of a principal attribute provider given the provider's alias- Parameters:
alias
- the provider to retrieve, seePCDirectoryHelper.DIR_ALIAS
for a list of well known principal attribute provider aliases- Returns:
- a View of the attribute provider
- Throws:
Exception
-
getDirectoryURI
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
-