Search in sources :

Example 1 with SystemProperties

use of com.iplanet.am.util.SystemProperties 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)

Aggregations

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 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 CachedSMSEntry (com.sun.identity.sm.CachedSMSEntry)1 SMSEntry (com.sun.identity.sm.SMSEntry)1 SMSException (com.sun.identity.sm.SMSException)1 ServiceConfig (com.sun.identity.sm.ServiceConfig)1 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 MissingResourceException (java.util.MissingResourceException)1 Properties (java.util.Properties)1 SortedMap (java.util.SortedMap)1 TreeMap (java.util.TreeMap)1