Search in sources :

Example 1 with CachedSMSEntry

use of com.sun.identity.sm.CachedSMSEntry in project OpenAM by OpenRock.

the class AMSetupServlet method configure.

private static boolean configure(IHttpServletRequest request, Map<String, Object> map, Map<String, Object> userRepo) throws Exception {
    boolean configured;
    boolean existingConfiguration = false;
    try {
        String basedir = (String) map.get(SetupConstants.CONFIG_VAR_BASE_DIR);
        checkBaseDir(basedir, request);
        boolean isDITLoaded = setupSMDatastore(map);
        String serverURL = (String) map.get(SetupConstants.CONFIG_VAR_SERVER_URL);
        String deployuri = (String) map.get(SetupConstants.CONFIG_VAR_SERVER_URI);
        // do this here since initializeConfigProperties needs the dir
        setupSecurIDDirs(basedir, deployuri);
        SetupProgress.reportStart("configurator.progress.reinit.system", null);
        Map mapFileNameToConfig = initializeConfigProperties();
        String strAMConfigProperties = (String) mapFileNameToConfig.get(SetupConstants.AMCONFIG_PROPERTIES);
        String strServerConfigXML = (String) mapFileNameToConfig.get(SystemProperties.CONFIG_FILE_NAME);
        Properties propAMConfig = ServerConfiguration.getProperties(strAMConfigProperties);
        // Set the install property since reInitConfigProperties
        // initializes SMS which inturn initializes EventService
        propAMConfig.put(Constants.SYS_PROPERTY_INSTALL_TIME, "true");
        String serverInstanceName = serverURL + deployuri;
        reInitConfigProperties(serverInstanceName, propAMConfig, strServerConfigXML);
        // SystemProperties gets reinitialized and installTime property
        // has to set again
        SystemProperties.initializeProperties(Constants.SYS_PROPERTY_INSTALL_TIME, "true");
        SetupProgress.reportEnd("emb.done", null);
        SSOToken adminSSOToken = getAdminSSOToken();
        if (!isDITLoaded) {
            RegisterServices regService = new RegisterServices();
            boolean bUseExtUMDS = userRepo != null && !userRepo.isEmpty();
            regService.registers(adminSSOToken, bUseExtUMDS);
            processDataRequests("/WEB-INF/template/sms");
        }
        // Set installTime to false, to avoid in-memory notification from
        // SMS in cases where not needed, and to denote that service  
        // registration got completed during configuration phase and it 
        // has passed installtime.
        SystemProperties.initializeProperties(Constants.SYS_PROPERTY_INSTALL_TIME, "false");
        configureServerInstance(adminSSOToken, serverInstanceName, strAMConfigProperties, isDITLoaded, basedir, strServerConfigXML, propAMConfig, map);
        // Embedded :get our serverid and configure embedded idRepo
        String dataStore = (String) map.get(SetupConstants.CONFIG_VAR_DATA_STORE);
        boolean embedded = dataStore.equals(SetupConstants.SMS_EMBED_DATASTORE);
        // Ensure this service are initialized before continuing
        WebtopNaming.initialize();
        NamingService.initialize();
        if (embedded) {
            try {
                String serverID = WebtopNaming.getAMServerID();
                String entry = map.get(SetupConstants.CONFIG_VAR_DIRECTORY_SERVER_HOST) + ":" + map.get(SetupConstants.CONFIG_VAR_DIRECTORY_SERVER_PORT) + "|" + (serverID == null ? "" : serverID);
                String orgName = (String) map.get(SetupConstants.SM_CONFIG_ROOT_SUFFIX);
                updateEmbeddedIdRepo(orgName, "embedded", entry);
            } catch (Exception ex) {
                Debug.getInstance(SetupConstants.DEBUG_NAME).error("EmbeddedDS : failed to setup serverid", ex);
                throw ex;
            }
        }
        SystemProperties.setServerInstanceName(serverInstanceName);
        LDIFTemplates.copy(basedir, servletCtx);
        ServiceXMLTemplates.copy(basedir + "/template/xml", servletCtx);
        createDotVersionFile(basedir);
        handlePostPlugins(adminSSOToken);
        if (!isDITLoaded && userRepo != null && !userRepo.isEmpty()) {
            // Construct the SMSEntry for the node to check to 
            // see if this is an existing configuration store, 
            // or new store.
            ServiceConfig sc = UserIdRepo.getOrgConfig(adminSSOToken);
            if (sc != null) {
                CachedSMSEntry cEntry = CachedSMSEntry.getInstance(adminSSOToken, "ou=" + userRepo.get("userStoreHostName") + "," + sc.getDN());
                SMSEntry entry = cEntry.getClonedSMSEntry();
                if (entry.isNewEntry()) {
                    UserIdRepo.getInstance().configure(userRepo, basedir, servletCtx, adminSSOToken);
                } else {
                    existingConfiguration = true;
                }
            }
        }
        // postInitialize requires the user repo to be configured
        postInitialize(adminSSOToken);
        /*
             * Requiring the keystore.jks file in OpenAM workspace.
             * The createIdentitiesForWSSecurity is for the 
             * JavaEE/NetBeans integration that we had done.
             */
        createPasswordFiles(basedir, deployuri);
        if (!isDITLoaded) {
            if ((userRepo == null) || userRepo.isEmpty()) {
                createDemoUser();
            }
        }
        String aceDataDir = basedir + "/" + deployuri + "/auth/ace/data";
        copyAuthSecurIDFiles(aceDataDir);
        createMonitoringAuthFile(basedir, deployuri);
        isConfiguredFlag = true;
        configured = true;
    } catch (Exception e) {
        // catch all because we want all exception to be logged
        Debug.getInstance(SetupConstants.DEBUG_NAME).error("AMSetupServlet.configure: error", e);
        errorMessage = e.getMessage();
        throw e;
    }
    return configured;
}
Also used : SSOToken(com.iplanet.sso.SSOToken) ServiceConfig(com.sun.identity.sm.ServiceConfig) SMSEntry(com.sun.identity.sm.SMSEntry) CachedSMSEntry(com.sun.identity.sm.CachedSMSEntry) Properties(java.util.Properties) SystemProperties(com.iplanet.am.util.SystemProperties) Map(java.util.Map) TreeMap(java.util.TreeMap) SortedMap(java.util.SortedMap) HashMap(java.util.HashMap) MissingResourceException(java.util.MissingResourceException) SSOException(com.iplanet.sso.SSOException) IOException(java.io.IOException) ServletException(javax.servlet.ServletException) NamingException(javax.naming.NamingException) UnknownPropertyNameException(com.sun.identity.common.configuration.UnknownPropertyNameException) PolicyException(com.sun.identity.policy.PolicyException) LDAPServiceException(com.iplanet.services.ldap.LDAPServiceException) UpgradeException(org.forgerock.openam.upgrade.UpgradeException) IdRepoException(com.sun.identity.idm.IdRepoException) SMSException(com.sun.identity.sm.SMSException) MalformedURLException(java.net.MalformedURLException) ConfigurationException(com.sun.identity.common.configuration.ConfigurationException) CachedSMSEntry(com.sun.identity.sm.CachedSMSEntry)

Example 2 with CachedSMSEntry

use of com.sun.identity.sm.CachedSMSEntry in project OpenAM by OpenRock.

the class SMSJAXRPCObjectImpl method read.

/**
     * Returns the attribute names and values of the provided object using the
     * identity of the provided SSO Token
     */
public Map read(String tokenID, String objName) throws SMSException, SSOException, RemoteException {
    initialize();
    if (debug.messageEnabled()) {
        debug.message("SMSJAXRPCObjectImpl::read dn: " + objName);
    }
    Map returnAttributes = null;
    if (objName.equals("o=" + SMSJAXRPCObject.AMJAXRPCVERSIONSTR)) {
        returnAttributes = new HashMap();
        returnAttributes.put(SMSJAXRPCObject.AMJAXRPCVERSIONSTR, SMSJAXRPCObject.AMJAXRPCVERSION);
    } else {
        CachedSMSEntry ce = CachedSMSEntry.getInstance(getToken(tokenID), objName);
        if (ce.isDirty()) {
            ce.refresh();
        }
        Map attrs = ce.getSMSEntry().getAttributes();
        if ((attrs != null) && (attrs instanceof CaseInsensitiveHashMap)) {
            returnAttributes = new HashMap();
            for (Iterator items = attrs.keySet().iterator(); items.hasNext(); ) {
                String attrName = items.next().toString();
                Object o = attrs.get(attrName);
                returnAttributes.put(attrName, o);
            }
        } else {
            // could be null or instance of HashMap - return as it is.
            returnAttributes = attrs;
        }
    }
    return returnAttributes;
}
Also used : HashMap(java.util.HashMap) CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap) Iterator(java.util.Iterator) HashMap(java.util.HashMap) CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap) Map(java.util.Map) CachedSMSEntry(com.sun.identity.sm.CachedSMSEntry) CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap)

Example 3 with CachedSMSEntry

use of com.sun.identity.sm.CachedSMSEntry in project OpenAM by OpenRock.

the class SMSJAXRPCObjectImpl method entryExists.

/**
     * Checks if the provided DN exists. Used by PolicyManager.
     */
public boolean entryExists(String tokenID, String objName) throws SSOException, RemoteException {
    initialize();
    if (debug.messageEnabled()) {
        debug.message("SMSJAXRPCObjectImpl::exists dn: " + objName);
    }
    boolean entryExists = false;
    try {
        CachedSMSEntry ce = CachedSMSEntry.getInstance(getToken(tokenID), objName);
        if (ce.isDirty()) {
            ce.refresh();
        }
        entryExists = !(ce.getSMSEntry().isNewEntry());
    } catch (SMSException smse) {
    // Ignore the exception
    }
    return (entryExists);
}
Also used : SMSException(com.sun.identity.sm.SMSException) CachedSMSEntry(com.sun.identity.sm.CachedSMSEntry)

Aggregations

CachedSMSEntry (com.sun.identity.sm.CachedSMSEntry)3 SMSException (com.sun.identity.sm.SMSException)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 SystemProperties (com.iplanet.am.util.SystemProperties)1 LDAPServiceException (com.iplanet.services.ldap.LDAPServiceException)1 SSOException (com.iplanet.sso.SSOException)1 SSOToken (com.iplanet.sso.SSOToken)1 CaseInsensitiveHashMap (com.sun.identity.common.CaseInsensitiveHashMap)1 ConfigurationException (com.sun.identity.common.configuration.ConfigurationException)1 UnknownPropertyNameException (com.sun.identity.common.configuration.UnknownPropertyNameException)1 IdRepoException (com.sun.identity.idm.IdRepoException)1 PolicyException (com.sun.identity.policy.PolicyException)1 SMSEntry (com.sun.identity.sm.SMSEntry)1 ServiceConfig (com.sun.identity.sm.ServiceConfig)1 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 Iterator (java.util.Iterator)1 MissingResourceException (java.util.MissingResourceException)1 Properties (java.util.Properties)1