Example usage for java.util Properties keys

List of usage examples for java.util Properties keys

Introduction

In this page you can find the example usage for java.util Properties keys.

Prototype

@Override
    public Enumeration<Object> keys() 

Source Link

Usage

From source file:org.apache.geronimo.security.realm.providers.GenericHttpHeaderPropertiesFileLoginModule.java

public void loadProperties(ServerInfo serverInfo, URI groupURI) throws GeronimoSecurityException {
    try {/* ww w .j a va  2  s  .  c o  m*/
        URI groupFile = serverInfo.resolveServer(groupURI);
        Properties temp = new Properties();
        InputStream stream = groupFile.toURL().openStream();
        temp.load(stream);
        stream.close();

        Enumeration e = temp.keys();
        while (e.hasMoreElements()) {
            String groupName = (String) e.nextElement();
            String[] userList = ((String) temp.get(groupName)).split(",");

            Set<String> userset = roleUsersMap.get(groupName);
            if (userset == null) {
                userset = new HashSet<String>();
                roleUsersMap.put(groupName, userset);
            }
            for (String user : userList) {
                userset.add(user);
            }
        }

    } catch (Exception e) {
        log.error("Generic HTTP Header Properties File Login Module - data load failed", e);
        throw new GeronimoSecurityException(e);
    }
}

From source file:com.pivotal.gemfire.tools.pulse.internal.data.DataBrowser.java

/**
 * getQueryHistoryByUserId method reads and lists out the queries from history
 * file//from   www .  ja v  a  2 s . com
 * 
 * @param userId
 *          Logged in User's Id
 * @throws JSONException
 */
public JSONArray getQueryHistoryByUserId(String userId) throws JSONException {

    JSONArray queryList = new JSONArray();

    if (StringUtils.isNotNullNotEmptyNotWhiteSpace(userId)) {

        // Fetch all queries from query log file
        Properties properties = fetchAllQueriesFromFile();

        // Traversing all properties and list out user's queries
        Enumeration<Object> enumerator = properties.keys();
        while (enumerator.hasMoreElements()) {
            String queryId = (String) enumerator.nextElement();
            if (queryId.startsWith(userId)) {
                String strQueryDate = queryId.substring(queryId.indexOf(".") + 1, queryId.length());
                Date queryDate = new Date(Long.valueOf(strQueryDate));

                JSONObject queryItem = new JSONObject();
                queryItem.put("queryId", queryId);
                queryItem.put("queryText", properties.getProperty(queryId));
                queryItem.put("queryDateTime", simpleDateFormat.format(queryDate));

                queryList.put(queryItem);
            }
        }
    }

    return queryList;
}

From source file:org.pentaho.reporting.engine.classic.extensions.datasources.mondrian.DefaultMondrianConnectionProvider.java

protected String computeConnectionString(final Properties parameters) {
    final StringBuffer connectionStr = new StringBuffer(100);
    connectionStr.append("provider=mondrian");

    connectionStr.append("; ");
    connectionStr.append("Catalog=");
    connectionStr.append(parameters.getProperty("Catalog"));

    final Enumeration objectEnumeration = parameters.keys();
    while (objectEnumeration.hasMoreElements()) {
        final String key = (String) objectEnumeration.nextElement();
        if ("Catalog".equals(key)) {
            continue;
        }//from ww w.ja v a 2s. co m
        final Object value = parameters.getProperty(key);
        if (value != null) {
            connectionStr.append("; ");
            connectionStr.append(key);
            connectionStr.append("=");
            connectionStr.append(value);
        }
    }
    return connectionStr.toString();
}

From source file:org.wso2.carbon.registry.social.impl.appdata.AppDataManagerImpl.java

/**
 * Fetches AppData for the given userId,appId,fields collection
 *
 * @param userId The id of the person to fetch the AppData
 * @param appId  The appId to of the AppData to fetch
 * @param fields The fields of AppData to fetch
 * @return A Map<String,String> of AppData values
 * @throws RegistryException//from  w w  w  .  jav a  2 s  . c  o  m
 */
private Map<String, String> getAppData(String userId, String appId, Set<String> fields)
        throws RegistryException {
    Map<String, String> appDataMap = new HashMap<String, String>();
    String appDataPath = SocialImplConstants.APP_DATA_REGISTRY_ROOT + SocialImplConstants.SEPARATOR + appId
            + SocialImplConstants.SEPARATOR + userId;
    Resource appDataResource;

    registry = getRegistry();
    if (registry.resourceExists(appDataPath)) {
        appDataResource = registry.get(appDataPath);
        if (fields != null && fields.size() > 0) {
            for (String key : fields) {
                String value;
                if ((value = appDataResource.getProperty(key)) != null) {
                    appDataMap.put(key, value);
                }
            }
        } else {
            //Handle when fields is null -> get All properties
            // TODO: refactor code
            Properties props = appDataResource.getProperties();

            for (Enumeration propKeys = props.keys(); propKeys.hasMoreElements();) {
                String key = propKeys.nextElement().toString();
                String propValue = props.get(key).toString();
                //TODO: Re-write this code
                appDataMap.put(key, propValue.substring(1, propValue.length() - 1));
            }
        }
    } else {
        return null;
    }

    return appDataMap;
}

From source file:eu.planets_project.tb.gui.backing.exp.ResultsForDigitalObjectBean.java

/**
 * Returns all information when the experiment's result type is: 'PropertiesListResult' i.e.
 * all wee workflows use this result type to pass on information.
 * @return/*ww w.j  a v  a2  s.co  m*/
 */
public List<String> getResultPropertiesList() {
    List<String> ret = new ArrayList<String>();
    if (this.getExecutionRecord() == null || this.getExecutionRecord().getReportLog() == null)
        return null;
    try {
        Properties ps = this.getExecutionRecord().getPropertiesListResult();
        if (ps != null) {
            Enumeration enumeration = ps.keys();
            while (enumeration.hasMoreElements()) {
                String key = (String) enumeration.nextElement();
                String value = ps.getProperty(key);
                if (!key.startsWith(ExecutionRecordImpl.RESULT_PROPERTY_URI)) {
                    ret.add("[" + key + "= " + value + "]");
                }
            }
            // Sort list in Case-insensitive sort
            Collections.sort(ret, String.CASE_INSENSITIVE_ORDER);
            return ret;
        }
    } catch (IOException e) {
        log.debug("unable to fetch the resultPropertiesList in ResultsForDigitalObjectBean " + e);
        return null;
    }
    return null;
}

From source file:gov.nih.nci.cacisweb.action.SecureXDSNAVAction.java

@Override
public String input() throws Exception {
    log.debug("input() - START");
    secureXDSNAVRecepientList = new ArrayList<SecureXDSNAVModel>();

    String secureXDSNAVKeystoreLocation = CaCISUtil
            .getProperty(CaCISWebConstants.COM_PROPERTY_NAME_SECXDSNAV_RECEPIENT_TRUSTSTORE_LOCATION);
    String secureXDSNAVKeystorePassword = CaCISUtil
            .getProperty(CaCISWebConstants.COM_PROPERTY_NAME_SECXDSNAV_RECEPIENT_TRUSTSTORE_PASSWORD);
    String propertyFileLocation = CaCISUtil
            .getProperty(CaCISWebConstants.COM_PROPERTY_NAME_SECXDSNAV_RECEPIENT_CONFIG_FILE_LOCATION);

    CaCISUtil caCISUtil = new CaCISUtil();
    try {/*www.j a  v a 2 s .  c om*/
        caCISUtil.isPropertyFileAndKeystoreInSync(propertyFileLocation, secureXDSNAVKeystoreLocation,
                CaCISWebConstants.COM_KEYSTORE_TYPE_JKS, secureXDSNAVKeystorePassword);
    } catch (PropFileAndKeystoreOutOfSyncException e) {
        log.error(e.getMessage());
        addActionError(e.getMessage());
    }

    try {
        KeyStore keystore = caCISUtil.getKeystore(secureXDSNAVKeystoreLocation,
                CaCISWebConstants.COM_KEYSTORE_TYPE_JKS, secureXDSNAVKeystorePassword);
        // List the aliases
        //            Enumeration<String> enumeration = keystore.aliases();            
        Properties configFile = new Properties();
        InputStream is = new FileInputStream(propertyFileLocation);
        configFile.load(is);
        is.close();
        Enumeration<Object> enumeration = configFile.keys();
        //            while (enumeration.hasMoreElements()) {
        //                String alias = (String) enumeration.nextElement();
        //                X509Certificate x509Certificate = (X509Certificate) keystore.getCertificate(alias);
        //                SecureXDSNAVModel secureXDSNAVModel = new SecureXDSNAVModel();
        //                secureXDSNAVModel.setCertificateAlias(alias);
        //                secureXDSNAVModel.setCertificateDN(x509Certificate.getSubjectDN().toString());
        //                secureXDSNAVRecepientList.add(secureXDSNAVModel);
        //                log.debug("Alias: " + alias + " DN: " + x509Certificate.getSubjectDN().getName());
        //            }            
        while (enumeration.hasMoreElements()) {
            String alias = (String) enumeration.nextElement();
            X509Certificate x509Certificate = (X509Certificate) keystore.getCertificate(alias);
            String distinguishedName = "";
            if (x509Certificate != null) {
                distinguishedName = x509Certificate.getSubjectDN().toString();
            }
            //              String distinguishedName = CaCISUtil.getPropertyFromPropertiesFile(propertyFileLocation, alias);
            SecureXDSNAVModel secureXDSNAVModel = new SecureXDSNAVModel();
            secureXDSNAVModel.setCertificateAlias(alias);
            secureXDSNAVModel.setCertificateDN(distinguishedName);
            secureXDSNAVRecepientList.add(secureXDSNAVModel);
            log.debug("Alias: " + alias + " DN: " + distinguishedName);
        }

        caCISUtil.releaseKeystore();
    } catch (KeystoreInstantiationException kie) {
        log.error(kie.getMessage());
        addActionError(getText("exception.keystoreInstantiation"));
        return ERROR;
    }
    log.debug("input() - END");
    return INPUT;
}

From source file:gov.nih.nci.cacisweb.action.SecureFTPAction.java

@Override
public String input() throws Exception {
    log.debug("input() - START");
    secureFTPRecepientList = new ArrayList<SecureFTPModel>();
    String secureFTPPropertyFileLocation = CaCISUtil
            .getProperty(CaCISWebConstants.COM_PROPERTY_NAME_SECFTP_PROPERTIES_FILE_LOCATION);
    String secureFTPKeystoreLocation = CaCISUtil.getPropertyFromPropertiesFile(secureFTPPropertyFileLocation,
            CaCISUtil.getProperty(CaCISWebConstants.COM_PROPERTY_NAME_SECFTP_TRUSTSTORE_LOCATION_PROP_NAME));
    String secureFTPKeystorePassword = CaCISUtil.getPropertyFromPropertiesFile(secureFTPPropertyFileLocation,
            CaCISUtil.getProperty(CaCISWebConstants.COM_PROPERTY_NAME_SECFTP_TRUSTSTORE_PASSWORD_PROP_NAME));

    CaCISUtil caCISUtil = new CaCISUtil();
    String propertyFileLocation = CaCISUtil
            .getProperty(CaCISWebConstants.COM_PROPERTY_NAME_SECFTP_CONFIG_FILE_LOCATION);

    try {//from   w w  w. j  a  v  a  2s  .co m
        caCISUtil.isPropertyFileAndKeystoreInSync(propertyFileLocation, secureFTPKeystoreLocation,
                CaCISWebConstants.COM_KEYSTORE_TYPE_JKS, secureFTPKeystorePassword);
    } catch (PropFileAndKeystoreOutOfSyncException e) {
        if (!StringUtils.contains(e.getMessage(), "sftp")) {
            log.error(e.getMessage());
            addActionError(e.getMessage());
        }
    }

    try {
        KeyStore keystore = caCISUtil.getKeystore(secureFTPKeystoreLocation,
                CaCISWebConstants.COM_KEYSTORE_TYPE_JKS, secureFTPKeystorePassword);
        // // List the aliases
        // Enumeration<String> enumeration = keystore.aliases();
        Properties configFile = new Properties();
        InputStream is = new FileInputStream(propertyFileLocation);
        configFile.load(is);
        is.close();
        Enumeration<Object> enumeration = configFile.keys();
        // while (enumeration.hasMoreElements()) {
        // String alias = (String) enumeration.nextElement();
        // X509Certificate x509Certificate = (X509Certificate) keystore.getCertificate(alias);
        // SecureFTPModel secureFTPModel = new SecureFTPModel();
        // secureFTPModel.setCertificateAlias(alias);
        // secureFTPModel.setCertificateDN(x509Certificate.getSubjectDN().toString());
        // secureFTPRecepientList.add(secureFTPModel);
        // log.debug("Alias: " + alias + " DN: " + x509Certificate.getSubjectDN().getName());
        // }
        while (enumeration.hasMoreElements()) {
            String alias = (String) enumeration.nextElement();
            X509Certificate x509Certificate = (X509Certificate) keystore.getCertificate(alias);
            String distinguishedName = "";
            if (x509Certificate != null) {
                distinguishedName = x509Certificate.getSubjectDN().toString();
            }
            SecureFTPModel secureFTPModel = new SecureFTPModel();
            secureFTPModel.setCertificateAlias(alias);
            secureFTPModel.setCertificateDN(distinguishedName);
            secureFTPRecepientList.add(secureFTPModel);
            log.debug("Alias: " + alias + " DN: " + distinguishedName);
        }

        caCISUtil.releaseKeystore();
    } catch (KeystoreInstantiationException kie) {
        log.error(kie.getMessage());
        addActionError(getText("exception.keystoreInstantiation"));
        return ERROR;
    }
    log.debug("input() - END");
    return INPUT;
}

From source file:org.ejbca.core.model.ca.publisher.custpubl2.CertSernoCustomLdapPublisher.java

@Override
public void init(Properties properties) {
    if (log.isDebugEnabled()) {
        log.debug(">init");
    }//from  www . j  a  va  2s.  co m
    // Transfer Properties into data used in LdapPublisher
    Enumeration<Object> keys = properties.keys();
    while (keys.hasMoreElements()) {
        final String key = (String) keys.nextElement();
        final String value = properties.getProperty(key);
        if (log.isDebugEnabled()) {
            log.debug("Setting property: " + key + "," + value);
        }
        if (key.equals("usefieldsinldapdn")) {
            // Create use fieldsin ldapDN, it is a Collection that needs to be created
            Collection<Integer> usefieldinldapdn = new ArrayList<Integer>();
            String[] values = StringUtils.split(value, ',');
            for (int i = 0; i < values.length; i++) {
                usefieldinldapdn.add(Integer.valueOf(values[i]));
                setUseFieldInLdapDN(usefieldinldapdn);
            }
        } else if (key.equals("connectionsecurity")) {
            if ("PLAIN".equalsIgnoreCase(value)) {
                setConnectionSecurity(ConnectionSecurity.PLAIN);
            } else if ("STARTTLS".equalsIgnoreCase(value)) {
                setConnectionSecurity(ConnectionSecurity.STARTTLS);
            } else if ("SSL".equalsIgnoreCase(value)) {
                setConnectionSecurity(ConnectionSecurity.SSL);
            }
        } else {
            // Booleans should be added as Booleans, not strings
            if ("true".equalsIgnoreCase(value) || "false".equalsIgnoreCase(value)) {
                data.put(key, Boolean.valueOf(value));
            } else {
                // Everything else added as String
                data.put(key, value);
            }
        }
    }
    if (log.isDebugEnabled()) {
        log.debug(">init");
    }
}

From source file:org.jajuk.util.UpgradeManager.java

/**
 * For Jajuk < 1.9: bootstrap file is now in XML format
 * <br>/*from  w  w  w  . ja  va  2s.  c o  m*/
 * If it exists and contains data in 1.7 or 1.8 format, it convert it to new XML
 * format (to handle backslashes properly, old format just drop them)
 * <br>
 * This method doesn't yet validate provided workspace paths but only the bootstrap file
 * structure itself.
 */
public static void upgradeBootstrapFile() {
    try {
        String KEY_TEST = "test";
        String KEY_FINAL = "final";
        File bootstrapOld = new File(SessionService.getBootstrapPath(Const.FILE_BOOTSTRAP_OLD));
        File bootstrapOldOldHome = new File(System.getProperty("user.home") + "/" + Const.FILE_BOOTSTRAP_OLD);
        File bootstrapNew = new File(SessionService.getBootstrapPath());
        // Fix for #1473 : move the bootstrap file if required (See #1473)
        if (UtilSystem.isUnderWindows() && !bootstrapOld.equals(bootstrapOldOldHome) && !bootstrapOld.exists()
                && bootstrapOldOldHome.exists()) {
            try {
                FileUtils.copyFileToDirectory(bootstrapOldOldHome, new File(UtilSystem.getUserHome()));
                UtilSystem.deleteFile(bootstrapOldOldHome);
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }
        if (bootstrapOld.exists() && !bootstrapNew.exists()) {
            Properties prop = null;
            // Try to load a bootstrap file using plain text old format
            prop = new Properties();
            FileInputStream fis = new FileInputStream(
                    SessionService.getBootstrapPath(Const.FILE_BOOTSTRAP_OLD));
            prop.load(fis);
            fis.close();
            // If it exists and contains pre-1.7 bootstrap format (a single line with a raw path),
            // convert it to 1.7 format first
            if (prop.size() == 1) {
                // We get something like <... path ...> = <nothing>
                String path = (String) prop.keys().nextElement();
                // we use this path for both test and final workspace
                prop.clear();
                prop.put(KEY_TEST, path);
                prop.put(KEY_FINAL, path);
            }
            // Make sure to populate both test and final release
            if (!prop.containsKey(KEY_TEST)) {
                prop.put(KEY_TEST, UtilSystem.getUserHome());
            }
            if (!prop.containsKey(KEY_FINAL)) {
                prop.put(KEY_FINAL, UtilSystem.getUserHome());
            }
            // Write down the new bootstrap file
            SessionService.commitBootstrapFile(prop);
            // Delete old bootstrap file
            bootstrapOld.delete();
        }
    } catch (Exception e) {
        // Do not throw any exception from here. display raw stack trace, Logs facilities 
        // are not yet available.
        e.printStackTrace();
    }
}

From source file:sk.openhouse.web.recaptcha.LocaleReCaptchaImpl.java

/**
 * Produces javascript array with the RecaptchaOptions encoded.
 * If the value starts with "{" and ends with "}", single quotes are not
 * prepended and appended. This way javascript objects can be passed.
 *
 * @param properties/*  ww w.  java 2 s  .  co m*/
 * @return
 */
private String fetchJSOptions(Properties properties) {

    if (properties == null || properties.size() == 0) {
        return "";
    }

    String jsOptions = "<script type=\"text/javascript\">\r\n" + "var RecaptchaOptions = {";

    for (Enumeration e = properties.keys(); e.hasMoreElements();) {
        String property = (String) e.nextElement();

        String value = properties.getProperty(property).trim();
        if (value.startsWith("{") && value.endsWith("}")) {
            jsOptions += property + ":" + value;
        } else {
            jsOptions += property + ":'" + value + "'";
        }

        if (e.hasMoreElements()) {
            jsOptions += ",";
        }

    }

    jsOptions += "};\r\n</script>\r\n";

    return jsOptions;
}