Search in sources :

Example 1 with AdminDNAction

use of com.sun.identity.security.AdminDNAction in project OpenAM by OpenRock.

the class SMSLdapObject method initialize.

/**
     * Synchronized initialized method
     */
private synchronized void initialize() throws SMSException {
    if (initialized) {
        return;
    }
    // Obtain the I18N resource bundle & Debug
    debug = Debug.getInstance("amSMSLdap");
    AMResourceBundleCache amCache = AMResourceBundleCache.getInstance();
    bundle = amCache.getResBundle(IUMSConstants.UMS_BUNDLE_NAME, java.util.Locale.ENGLISH);
    OU_ATTR[0] = getNamingAttribute();
    O_ATTR[0] = getOrgNamingAttribute();
    String enableP = SystemProperties.get(SMSEntry.DB_PROXY_ENABLE);
    enableProxy = (enableP != null) && enableP.equalsIgnoreCase("true");
    if (debug.messageEnabled()) {
        debug.message("SMSLdapObject: proxy enable value: " + enableProxy);
    }
    try {
        if (enableProxy) {
            // Initialize the principal, used only with AMSDK
            // for proxy connections
            adminPrincipal = new AuthPrincipal((String) AccessController.doPrivileged(new AdminDNAction()));
            // Get UMS datalayer
            dlayer = DataLayer.getInstance();
            if (debug.messageEnabled()) {
                debug.message("SMSLdapObject: DataLayer instance " + "obtained.");
            }
        } else {
            // Get SM datalayer
            smdlayer = SMDataLayer.getInstance();
            if (debug.messageEnabled()) {
                debug.message("SMSLdapObject: SMDataLayer instance " + "obtained.");
            }
        }
        if ((dlayer == null) && (smdlayer == null)) {
            debug.error("SMSLdapObject: Unable to initialize LDAP");
            throw (new SMSException(IUMSConstants.UMS_BUNDLE_NAME, IUMSConstants.CONFIG_MGR_ERROR, null));
        }
        debug.message("SMSLdapObject: LDAP Initialized successfully");
        // Get connection retry parameters
        DataLayer.initConnectionParams();
        connNumRetry = DataLayer.getConnNumRetry();
        connRetryInterval = DataLayer.getConnRetryInterval();
        retryErrorCodes = DataLayer.getRetryErrorCodes();
        // Need to check if the root nodes exists. If not, create them
        String serviceDN = SMSEntry.SERVICES_RDN + SMSEntry.COMMA + getRootSuffix();
        if (!entryExists(serviceDN)) {
            Map attrs = new HashMap();
            Set attrValues = new HashSet();
            attrValues.add(SMSEntry.OC_TOP);
            attrValues.add(SMSEntry.OC_ORG_UNIT);
            attrs.put(SMSEntry.ATTR_OBJECTCLASS, attrValues);
            create(adminPrincipal, serviceDN, attrs);
        }
    } catch (Exception e) {
        // Unable to initialize (trouble!!)
        debug.error("SMSEntry: Unable to initalize(exception):", e);
        throw (new SMSException(IUMSConstants.UMS_BUNDLE_NAME, IUMSConstants.CONFIG_MGR_ERROR, null));
    }
    initialized = true;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) AdminDNAction(com.sun.identity.security.AdminDNAction) SMSException(com.sun.identity.sm.SMSException) HashMap(java.util.HashMap) AMResourceBundleCache(com.sun.identity.shared.locale.AMResourceBundleCache) AuthPrincipal(com.sun.identity.authentication.internal.AuthPrincipal) Map(java.util.Map) HashMap(java.util.HashMap) EntryNotFoundException(org.forgerock.opendj.ldap.EntryNotFoundException) NamingException(javax.naming.NamingException) SSOException(com.iplanet.sso.SSOException) LdapException(org.forgerock.opendj.ldap.LdapException) SMSException(com.sun.identity.sm.SMSException) SearchResultReferenceIOException(org.forgerock.opendj.ldap.SearchResultReferenceIOException) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 2 with AdminDNAction

use of com.sun.identity.security.AdminDNAction in project OpenAM by OpenRock.

the class AdminInterfaceUtils method initialize.

/**
     * Initializes the default containers using SMS
     */
private static void initialize() {
    if (!initialized) {
        try {
            // Generate a SSOToken to initialize ServiceSchemaManager
            String adminDN = (String) AccessController.doPrivileged(new AdminDNAction());
            String adminPassword = (String) AccessController.doPrivileged(new AdminPasswordAction());
            SSOTokenManager mgr = SSOTokenManager.getInstance();
            ServiceConfigManager scm = new ServiceConfigManager(SERVICE_NAME, mgr.createSSOToken(new AuthPrincipal(adminDN), adminPassword));
            if (!addedListener) {
                addedListener = true;
                scm.addListener(new AdminInterfaceUtils());
            }
            ServiceConfig globalConfig = scm.getGlobalConfig(null);
            ServiceConfig templatesConfig = globalConfig.getSubConfig(TEMPLATES);
            ServiceConfig structTemplateSubConfig = templatesConfig.getSubConfig(STRUCTURE_TEMPLATES);
            ServiceConfig groupContConfig = structTemplateSubConfig.getSubConfig(GCCREATE_ATTR_NAME);
            ServiceConfig peopleContConfig = structTemplateSubConfig.getSubConfig(PCCREATE_ATTR_NAME);
            ServiceConfig orgAdminConfig = structTemplateSubConfig.getSubConfig(ORG_ADMIN_ATTR_NAME);
            ServiceConfig helpDeskAdminConfig = structTemplateSubConfig.getSubConfig(HELP_DESK_ADMIN_ATTR_NAME);
            ServiceConfig policyAdminConfig = structTemplateSubConfig.getSubConfig(POLICY_ADMIN_ATTR_NAME);
            defaultGCCreateDuringOrgConfig = getConfigAttributeValue(groupContConfig, defaultGCCreateDuringOrgConfig);
            defaultPCCreateDuringOrgConfig = getConfigAttributeValue(peopleContConfig, defaultPCCreateDuringOrgConfig);
            defaultORGADMIN = getConfigAttributeValue(orgAdminConfig, defaultORGADMIN);
            defaultHELP_DESK_ADMIN = getConfigAttributeValue(helpDeskAdminConfig, defaultHELP_DESK_ADMIN);
            defaultPOLICY_ADMIN = getConfigAttributeValue(policyAdminConfig, defaultPOLICY_ADMIN);
            ServiceSchemaManager sm = new ServiceSchemaManager(CONSOLE_SERVICE_NAME, mgr.createSSOToken(new AuthPrincipal(adminDN), adminPassword));
            if (!addedListener) {
                addedListener = true;
                sm.addListener(new AdminInterfaceUtils());
            }
            ServiceSchema schema = sm.getGlobalSchema();
            defaultAC = getAttributeValue(schema, AC_ATTR_NAME, defaultAC);
            defaultGC = getAttributeValue(schema, GC_ATTR_NAME, defaultGC);
            defaultPC = getAttributeValue(schema, PC_ATTR_NAME, defaultPC);
        } catch (Exception e) {
            // Use the default values, and write out debug warning msg
            debug.warning("AdminInterfaceUtils: Unable to get " + "default People, Groups, Org Admin Role, " + "Help Desk Admin Role, Policy Admin Role and " + "Agents containers from SM", e);
        }
        if (debug.messageEnabled()) {
            debug.message("AdminInterfaceUtils: Defaults container: " + defaultPC + ", " + defaultGC + ", " + defaultAC + ", " + defaultPCCreateDuringOrgConfig + ", " + defaultGCCreateDuringOrgConfig + ", " + defaultORGADMIN + ", " + defaultHELP_DESK_ADMIN + ", " + defaultPOLICY_ADMIN);
        }
        initialized = true;
    }
}
Also used : SSOTokenManager(com.iplanet.sso.SSOTokenManager) ServiceSchema(com.sun.identity.sm.ServiceSchema) AdminDNAction(com.sun.identity.security.AdminDNAction) AdminPasswordAction(com.sun.identity.security.AdminPasswordAction) ServiceConfig(com.sun.identity.sm.ServiceConfig) AuthPrincipal(com.sun.identity.authentication.internal.AuthPrincipal) ServiceConfigManager(com.sun.identity.sm.ServiceConfigManager) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager) SMSException(com.sun.identity.sm.SMSException) AMException(com.iplanet.am.sdk.AMException) SSOException(com.iplanet.sso.SSOException)

Aggregations

SSOException (com.iplanet.sso.SSOException)2 AuthPrincipal (com.sun.identity.authentication.internal.AuthPrincipal)2 AdminDNAction (com.sun.identity.security.AdminDNAction)2 SMSException (com.sun.identity.sm.SMSException)2 AMException (com.iplanet.am.sdk.AMException)1 SSOTokenManager (com.iplanet.sso.SSOTokenManager)1 AdminPasswordAction (com.sun.identity.security.AdminPasswordAction)1 AMResourceBundleCache (com.sun.identity.shared.locale.AMResourceBundleCache)1 ServiceConfig (com.sun.identity.sm.ServiceConfig)1 ServiceConfigManager (com.sun.identity.sm.ServiceConfigManager)1 ServiceSchema (com.sun.identity.sm.ServiceSchema)1 ServiceSchemaManager (com.sun.identity.sm.ServiceSchemaManager)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 Map (java.util.Map)1 Set (java.util.Set)1 NamingException (javax.naming.NamingException)1 EntryNotFoundException (org.forgerock.opendj.ldap.EntryNotFoundException)1 LdapException (org.forgerock.opendj.ldap.LdapException)1