Class PCDirectoryHelper

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

public class PCDirectoryHelper extends Object
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
  • Field Details

    • TYPE_USER

      public static final int TYPE_USER
      Parameter constant to specify user principals
      See Also:
    • TYPE_GROUP

      public static final int TYPE_GROUP
      Parameter constant to specify group principals
      See Also:
    • TYPE_ROLE

      public static final int TYPE_ROLE
      Parameter constant to specify role principals
      See Also:
  • Constructor Details

    • PCDirectoryHelper

      public PCDirectoryHelper()
  • Method Details

    • 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 TYPE_GROUP, TYPE_ROLE or 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 TYPE_GROUP, TYPE_ROLE or 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 TYPE_GROUP, TYPE_ROLE or TYPE_USER
      Returns:
      listview a ListView object containing those principal Views that matched the query string
      Throws:
      Exception
    • getAllAttributes

      public static Map<String,Object> 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<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 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 TYPE_GROUP, 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