Search in sources :

Example 1 with BootstrapData

use of com.sun.identity.setup.BootstrapData in project OpenAM by OpenRock.

the class ServiceBase method getBootfileContent.

private Map getBootfileContent(String path) throws IOException, UnsupportedEncodingException {
    BootstrapData bootstrapData = new BootstrapData(path);
    List list = bootstrapData.getData();
    Map<String, String> mapQuery = null;
    Map<String, Map> bootList = new HashMap();
    String dsprotocol = "unknown";
    for (Iterator<String> i = list.iterator(); i.hasNext(); ) {
        String info = i.next();
        if (info.startsWith(PROTOCOL_LDAPS)) {
            info = "http://" + info.substring(8);
            dsprotocol = "ldaps";
        } else if (info.startsWith(PROTOCOL_LDAP)) {
            info = "http://" + info.substring(7);
            dsprotocol = "ldap";
        }
        URL url = new URL(info);
        mapQuery = queryStringToMap(url.getQuery());
        String instanceName = URLDecoder.decode(url.getPath(), "UTF-8");
        if (instanceName.startsWith("/")) {
            instanceName = instanceName.substring(1);
        }
        mapQuery.put(SERVER_INSTANCE, instanceName);
        String dsHost = url.getHost();
        String dsPort = Integer.toString(url.getPort());
        mapQuery.put(DS_HOST, dsHost);
        mapQuery.put(DS_PORT, dsPort);
        mapQuery.put(DS_PROTOCOL, dsprotocol);
        String key = dsHost + ":" + dsPort;
        bootList.put(key, mapQuery);
    }
    return bootList;
}
Also used : BootstrapData(com.sun.identity.setup.BootstrapData) HashMap(java.util.HashMap) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) URL(java.net.URL)

Example 2 with BootstrapData

use of com.sun.identity.setup.BootstrapData in project OpenAM by OpenRock.

the class InitializeSystem method load.

private void load(String basedir) throws FileNotFoundException, IOException, UnsupportedEncodingException, LDAPServiceException {
    if (!basedir.endsWith(File.separator)) {
        basedir = basedir + File.separator;
    }
    String amConfigProperties = basedir + SetupConstants.AMCONFIG_PROPERTIES;
    File file = new File(amConfigProperties);
    if (file.exists()) {
        Properties prop = new Properties();
        InputStream propIn = new FileInputStream(amConfigProperties);
        try {
            prop.load(propIn);
        } finally {
            propIn.close();
        }
        SystemProperties.initializeProperties(prop);
    } else {
        bData = new BootstrapData(basedir);
        bData.initSMS(false);
        AdminUtils.initialize();
        SMSAuthModule.initialize();
        rootsuffix = bData.getBaseDN();
        instanceName = bData.getInstanceName();
    }
}
Also used : BootstrapData(com.sun.identity.setup.BootstrapData) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) Properties(java.util.Properties) SystemProperties(com.iplanet.am.util.SystemProperties) File(java.io.File) FileInputStream(java.io.FileInputStream)

Example 3 with BootstrapData

use of com.sun.identity.setup.BootstrapData in project OpenAM by OpenRock.

the class UpgradeServiceUtils method setUserAndPassword.

private static void setUserAndPassword(IHttpServletRequest requestFromFile, String basedir) throws UpgradeException {
    try {
        BootstrapData bootStrap = new BootstrapData(basedir);
        Map<String, String> data = bootStrap.getDataAsMap(0);
        requestFromFile.addParameter(SetupConstants.CONFIG_VAR_DS_MGR_DN, data.get(BootstrapData.DS_MGR));
        requestFromFile.addParameter(SetupConstants.CONFIG_VAR_DS_MGR_PWD, JCECrypt.decode(data.get(BootstrapData.DS_PWD)));
    } catch (IOException ioe) {
        DEBUG.error("Unable to load directory user/password from bootstrap file", ioe);
        throw new UpgradeException("Unable to load bootstrap file: " + ioe.getMessage());
    }
}
Also used : UpgradeException(org.forgerock.openam.upgrade.UpgradeException) BootstrapData(com.sun.identity.setup.BootstrapData) IOException(java.io.IOException)

Aggregations

BootstrapData (com.sun.identity.setup.BootstrapData)3 SystemProperties (com.iplanet.am.util.SystemProperties)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 URL (java.net.URL)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Properties (java.util.Properties)1 UpgradeException (org.forgerock.openam.upgrade.UpgradeException)1