Search in sources :

Example 1 with AMTemplate

use of com.iplanet.am.sdk.AMTemplate in project OpenAM by OpenRock.

the class EmailNotificationHelper method getOrgTypeAttributes.

/**
     * Protected method to be used to obtain organization attribute values for a
     * given serviceName and attribute name. Returns a null value if a template
     * value or default value for the attribute does not exist.
     */
protected Set getOrgTypeAttributes(AMOrganization org, String serviceName, String attrName) throws SSOException {
    Set attrValues = null;
    try {
        AMTemplate amTemplate = org.getTemplate(serviceName, AMTemplate.ORGANIZATION_TEMPLATE);
        attrValues = amTemplate.getAttribute(attrName);
        if (debug.messageEnabled()) {
            debug.message("AMOrganizationImpl." + "getOrgTypeAttributes(): " + "obtained from org template " + serviceName + " : " + attrName + "\n" + org.getDN() + " : " + attrValues);
        }
    } catch (AMException ame) {
        // Get default Service attribues
        try {
            Map defaultValues = AMServiceUtils.getServiceConfig(internalToken, ADMINISTRATION_SERVICE, SchemaType.ORGANIZATION);
            attrValues = (Set) defaultValues.get(attrName);
            if (debug.messageEnabled()) {
                debug.message("AMOrganizationImpl." + "getOrgTypeAttributes(): " + "obtained from org defaults " + serviceName + " : " + attrName + "\n" + org.getDN() + " : " + attrValues);
            }
        } catch (Exception se) {
            debug.warning("AMOrganizationImpl." + "getOrgTypeAttributes(): " + "Error encountered in retrieving " + "default org attrs for", se);
        }
    }
    return attrValues;
}
Also used : AttrSet(com.iplanet.services.ldap.AttrSet) Set(java.util.Set) HashSet(java.util.HashSet) AMTemplate(com.iplanet.am.sdk.AMTemplate) AMException(com.iplanet.am.sdk.AMException) Map(java.util.Map) MessagingException(javax.mail.MessagingException) AMException(com.iplanet.am.sdk.AMException) SSOException(com.iplanet.sso.SSOException)

Example 2 with AMTemplate

use of com.iplanet.am.sdk.AMTemplate in project OpenAM by OpenRock.

the class AMAuthConfigUtils method getAllAuthModules.

/**
     * Returns all supported authentication modules in an Organization
     * If there are not modules configured at the Organization level
     * then the authentication modules set at Global level will be returned.
     *
     * @param orgDN organization DN.
     * @param token single sign on token. 
     * @return Map contains all modules, key is the module name (e.g. LDAP),
     *         value is the complete class name (e.g.
     *         <code>com.sun.identity.authentication.modules.ldap.LDAP</code>)
     */
public static Map getAllAuthModules(String orgDN, SSOToken token) {
    Map modules = new HashMap();
    // get auth global attribute
    Set authenticators = null;
    try {
        AMStoreConnection dpStore = new AMStoreConnection(token);
        AMOrganization org = (AMOrganization) dpStore.getOrganization(orgDN);
        AMTemplate template = org.getTemplate(AUTH_SERVICE, AMTemplate.ORGANIZATION_TEMPLATE);
        Map attrs = template.getAttributes();
        authenticators = (Set) attrs.get(AUTH_MODULES_ATTR);
    } catch (Exception e) {
        debug.error("getAllAuthModules", e);
    }
    Set globalAuth = getGlobalAuthenticators(token);
    if ((authenticators != null) && (!authenticators.isEmpty())) {
        modules = constructModulesList(authenticators, globalAuth);
    } else {
        modules = constructModulesList(globalAuth, null);
    }
    if (debug.messageEnabled()) {
        debug.message("Returning modules : " + modules);
    }
    return modules;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) AMStoreConnection(com.iplanet.am.sdk.AMStoreConnection) HashMap(java.util.HashMap) AMOrganization(com.iplanet.am.sdk.AMOrganization) AMTemplate(com.iplanet.am.sdk.AMTemplate) HashMap(java.util.HashMap) Map(java.util.Map) SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException)

Aggregations

AMTemplate (com.iplanet.am.sdk.AMTemplate)2 SSOException (com.iplanet.sso.SSOException)2 HashSet (java.util.HashSet)2 Map (java.util.Map)2 Set (java.util.Set)2 AMException (com.iplanet.am.sdk.AMException)1 AMOrganization (com.iplanet.am.sdk.AMOrganization)1 AMStoreConnection (com.iplanet.am.sdk.AMStoreConnection)1 AttrSet (com.iplanet.services.ldap.AttrSet)1 SMSException (com.sun.identity.sm.SMSException)1 HashMap (java.util.HashMap)1 MessagingException (javax.mail.MessagingException)1