Search in sources :

Example 1 with AMResourceBundleCache

use of com.sun.identity.shared.locale.AMResourceBundleCache in project OpenAM by OpenRock.

the class PWResetResBundleCacher method getBundle.

/**
     * Gets resource bundle
     *
     * @param name of bundle
     * @param locale of bundle
     * @return resource bundle
     */
public static ResourceBundle getBundle(String name, Locale locale) {
    AMResourceBundleCache cache = AMResourceBundleCache.getInstance();
    ResourceBundle rb = cache.getResBundle(name, locale);
    if (rb == null) {
        rb = cache.getResBundle(PWResetModel.DEFAULT_RB, locale);
    }
    return rb;
}
Also used : AMResourceBundleCache(com.sun.identity.shared.locale.AMResourceBundleCache) ResourceBundle(java.util.ResourceBundle)

Example 2 with AMResourceBundleCache

use of com.sun.identity.shared.locale.AMResourceBundleCache in project OpenAM by OpenRock.

the class SMSEmbeddedLdapObject method initialize.

/**
     * Synchronized initialized method
     */
private synchronized void initialize() throws SMSException {
    auditorFactory = InjectorHolder.getInstance(ConfigAuditorFactory.class);
    if (initialized) {
        return;
    }
    // Obtain the I18N resource bundle & Debug
    debug = Debug.getInstance("amSMSEmbeddedLdap");
    AMResourceBundleCache amCache = AMResourceBundleCache.getInstance();
    bundle = amCache.getResBundle(IUMSConstants.UMS_BUNDLE_NAME, java.util.Locale.ENGLISH);
    orgUnitAttr = new LinkedHashSet<>(1);
    orgUnitAttr.add(getNamingAttribute());
    orgAttr = new LinkedHashSet<>(1);
    orgAttr.add(getOrgNamingAttribute());
    icConn = InternalClientConnection.getRootConnection();
    try {
        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);
            internalCreate(null, serviceDN, attrs);
        }
    } catch (Exception e) {
        // Unable to initialize (trouble!!)
        debug.error("SMSEmbeddedLdapObject.initialize: " + "Unable to initalize(exception):", e);
        throw (new SMSException(IUMSConstants.UMS_BUNDLE_NAME, IUMSConstants.CONFIG_MGR_ERROR, null));
    }
    String[] smsAttrs = getAttributeNames();
    smsAttributes = new LinkedHashSet(smsAttrs.length);
    for (int i = 0; i < smsAttrs.length; i++) {
        smsAttributes.add(smsAttrs[i]);
    }
    initialized = true;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Set(java.util.Set) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) HashMap(java.util.HashMap) SMSException(com.sun.identity.sm.SMSException) NamingException(javax.naming.NamingException) DirectoryException(org.opends.server.types.DirectoryException) SSOException(com.iplanet.sso.SSOException) SMSException(com.sun.identity.sm.SMSException) AMResourceBundleCache(com.sun.identity.shared.locale.AMResourceBundleCache) Map(java.util.Map) HashMap(java.util.HashMap) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 3 with AMResourceBundleCache

use of com.sun.identity.shared.locale.AMResourceBundleCache 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)

Aggregations

AMResourceBundleCache (com.sun.identity.shared.locale.AMResourceBundleCache)3 SSOException (com.iplanet.sso.SSOException)2 SMSException (com.sun.identity.sm.SMSException)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 LinkedHashSet (java.util.LinkedHashSet)2 Map (java.util.Map)2 Set (java.util.Set)2 NamingException (javax.naming.NamingException)2 AuthPrincipal (com.sun.identity.authentication.internal.AuthPrincipal)1 AdminDNAction (com.sun.identity.security.AdminDNAction)1 ResourceBundle (java.util.ResourceBundle)1 EntryNotFoundException (org.forgerock.opendj.ldap.EntryNotFoundException)1 LdapException (org.forgerock.opendj.ldap.LdapException)1 SearchResultReferenceIOException (org.forgerock.opendj.ldap.SearchResultReferenceIOException)1 DirectoryException (org.opends.server.types.DirectoryException)1