Java Code Examples for org.wso2.carbon.base.ServerConfiguration#getFirstProperty()

The following examples show how to use org.wso2.carbon.base.ServerConfiguration#getFirstProperty() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KeyStoreAdmin.java    From carbon-identity-framework with Apache License 2.0 6 votes vote down vote up
public Key getPrivateKey(String alias, boolean isSuperTenant) throws SecurityConfigException {
    KeyStoreData[] keystores = getKeyStores(isSuperTenant);
    KeyStore keyStore = null;
    String privateKeyPassowrd = null;

    try {

        for (int i = 0; i < keystores.length; i++) {
            if (KeyStoreUtil.isPrimaryStore(keystores[i].getKeyStoreName())) {
                KeyStoreManager keyMan = KeyStoreManager.getInstance(tenantId);
                keyStore = keyMan.getPrimaryKeyStore();
                ServerConfiguration serverConfig = ServerConfiguration.getInstance();
                privateKeyPassowrd = serverConfig
                        .getFirstProperty(RegistryResources.SecurityManagement.SERVER_PRIVATE_KEY_PASSWORD);
                return keyStore.getKey(alias, privateKeyPassowrd.toCharArray());
            }
        }
    } catch (Exception e) {
        String msg = "Error has encounted while loading the key for the given alias " + alias;
        log.error(msg, e);
        throw new SecurityConfigException(msg);
    }
    return null;
}
 
Example 2
Source File: IdentityApplicationManagementServiceClient.java    From attic-stratos with Apache License 2.0 6 votes vote down vote up
public IdentityApplicationManagementServiceClient(String epr) throws AxisFault {

        XMLConfiguration conf = ConfUtil.getInstance(null).getConfiguration();
        int autosclaerSocketTimeout = conf.getInt("autoscaler.identity.clientTimeout", 180000);
        try {
            ServerConfiguration serverConfig = CarbonUtils.getServerConfiguration();
            String trustStorePath = serverConfig.getFirstProperty("Security.TrustStore.Location");
            String trustStorePassword = serverConfig.getFirstProperty("Security.TrustStore.Password");
            String type = serverConfig.getFirstProperty("Security.TrustStore.Type");

            System.setProperty("javax.net.ssl.trustStore", trustStorePath);
            System.setProperty("javax.net.ssl.trustStorePassword", trustStorePassword);
            System.setProperty("javax.net.ssl.trustStoreType", type);

            stub = new IdentityApplicationManagementServiceStub(epr);
            stub._getServiceClient().getOptions().setProperty(HTTPConstants.SO_TIMEOUT, autosclaerSocketTimeout);
            stub._getServiceClient().getOptions().setProperty(HTTPConstants.CONNECTION_TIMEOUT, autosclaerSocketTimeout);
	        String username = conf.getString("autoscaler.identity.adminUser", "admin");
            Utility.setAuthHeaders(stub._getServiceClient(), username);

        } catch (AxisFault axisFault) {
            String msg = "Failed to initiate identity service client. " + axisFault.getMessage();
            log.error(msg, axisFault);
            throw new AxisFault(msg, axisFault);
        }
    }
 
Example 3
Source File: KeyStoreAdmin.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
public Key getPrivateKey(String alias, boolean isSuperTenant) throws SecurityConfigException {
    KeyStoreData[] keystores = getKeyStores(isSuperTenant);
    KeyStore keyStore = null;
    String privateKeyPassowrd = null;

    try {

        for (int i = 0; i < keystores.length; i++) {
            if (KeyStoreUtil.isPrimaryStore(keystores[i].getKeyStoreName())) {
                KeyStoreManager keyMan = KeyStoreManager.getInstance(tenantId);
                keyStore = keyMan.getPrimaryKeyStore();
                ServerConfiguration serverConfig = ServerConfiguration.getInstance();
                privateKeyPassowrd = serverConfig
                        .getFirstProperty(RegistryResources.SecurityManagement.SERVER_PRIVATE_KEY_PASSWORD);
                return keyStore.getKey(alias, privateKeyPassowrd.toCharArray());
            }
        }
    } catch (Exception e) {
        String msg = "Error has encounted while loading the key for the given alias " + alias;
        log.error(msg, e);
        throw new SecurityConfigException(msg);
    }
    return null;
}
 
Example 4
Source File: OpenIDUtil.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
private static String getHostName() {
    ServerConfiguration serverConfig = ServerConfiguration.getInstance();
    if (serverConfig.getFirstProperty("HostName") != null) {
        return MultitenantUtils.getDomainNameFromOpenId(serverConfig.getFirstProperty("HostName"));
    } else {
        return "localhost";
    }
}
 
Example 5
Source File: SAML1TokenBuilder.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
@Override
public void createSAMLAssertion(DateTime notAfter, DateTime notBefore, String assertionId)
        throws IdentityProviderException {
    assertion = (Assertion) buildXMLObject(Assertion.DEFAULT_ELEMENT_NAME);
    Conditions conditions = (Conditions) buildXMLObject(Conditions.DEFAULT_ELEMENT_NAME);
    conditions.setNotBefore(notBefore);
    conditions.setNotOnOrAfter(notAfter);

    ServerConfiguration config = ServerConfiguration.getInstance();
    String host = "http://" + config.getFirstProperty("HostName");
    assertion.setIssuer(host);
    assertion.setIssueInstant(new DateTime());

    if (appilesTo != null) {
        Audience audience = (Audience) buildXMLObject(Audience.DEFAULT_ELEMENT_NAME);
        audience.setUri(appilesTo);
        AudienceRestrictionCondition audienceRestrictions =
                (AudienceRestrictionCondition) buildXMLObject(AudienceRestrictionCondition.DEFAULT_ELEMENT_NAME);
        audienceRestrictions.getAudiences().add(audience);

        conditions.getAudienceRestrictionConditions().add(audienceRestrictions);
    }

    assertion.setConditions(conditions);

    assertion.getAttributeStatements().add(this.attributeStmt);
    assertion.setID(assertionId);

}
 
Example 6
Source File: SecurityConfigParams.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
/**
 * Get the private key store
 *
 * If the key store is defined in the Security configuration take it from there otherwise
 * key store is taken from the Server Configuration
 *
 * @return private key store
 */
public String getPrivateStore() {

    if (privateStore == null) {
        ServerConfiguration serverConfig = ServerConfiguration.getInstance();
        String pvtStore = serverConfig.getFirstProperty("Security.KeyStore.Location");
        return pvtStore.substring(pvtStore.lastIndexOf("/") + 1);
    }
    return privateStore;
}
 
Example 7
Source File: IdentityBaseUtil.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
public static Policy getDefaultRampartConfig() {

        //Extract the primary keystore information from server configuration
        ServerConfiguration serverConfig = ServerConfiguration.getInstance();
        String keyStore = serverConfig.getFirstProperty("Security.KeyStore.Location");
        String keyStoreType = serverConfig.getFirstProperty("Security.KeyStore.Type");
        String keyStorePassword = serverConfig.getFirstProperty("Security.KeyStore.Password");
        String privateKeyAlias = serverConfig.getFirstProperty("Security.KeyStore.KeyAlias");
        String privateKeyPassword = serverConfig.getFirstProperty("Security.KeyStore.KeyPassword");

        //Populate Rampart Configuration
        RampartConfig rampartConfig = new RampartConfig();
        rampartConfig.setUser(privateKeyAlias);
        //TODO use a registry based callback handler
        rampartConfig.setPwCbClass("org.wso2.carbon.identity.base.InMemoryPasswordCallbackHandler");

        //Set the private key alias and private key password in the password callback handler
        InMemoryPasswordCallbackHandler.addUser(privateKeyAlias, privateKeyPassword);

        CryptoConfig sigCrypto = new CryptoConfig();
        Properties props = new Properties();
        sigCrypto.setProvider("org.apache.ws.security.components.crypto.Merlin");
        props.setProperty("org.apache.ws.security.crypto.merlin.keystore.type", keyStoreType);
        props.setProperty("org.apache.ws.security.crypto.merlin.file", keyStore);
        props.setProperty("org.apache.ws.security.crypto.merlin.keystore.password", keyStorePassword);

        // This property is set in order to fix IDENTITY-1931.
        // This issue is however not found in IS-4.5.0.
        // The reason for the error is unknown. Suspecting JCE provider.
        // Error occurrs when WSS4J tries to read the certificates in the JDK's cacerts store.
        props.setProperty("org.apache.ws.security.crypto.merlin.load.cacerts", "false");
        sigCrypto.setProp(props);

        rampartConfig.setSigCryptoConfig(sigCrypto);
        Policy policy = new Policy();
        policy.addAssertion(rampartConfig);

        return policy;

    }
 
Example 8
Source File: DeploymentSynchronizationManager.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
/**
 * Initialize the RepositoryManager instance. The RepositoryManager must be initialized by
 * calling this method, before synchronizers can use it to schedule tasks.
 *
 * @param serverConfig Active Carbon ServerConfiguration
 */
public void init(ServerConfiguration serverConfig) {
    if (log.isDebugEnabled()) {
        log.debug("Initializing deployment synchronization manager");
    }

    int poolSize = DeploymentSynchronizerConstants.DEFAULT_POOL_SIZE;
    String value = serverConfig.getFirstProperty(DeploymentSynchronizerConstants.POOL_SIZE);
    if (value != null) {
        poolSize = Integer.parseInt(value);
    }

    repositoryTaskExecutor = Executors.newScheduledThreadPool(poolSize, new SimpleThreadFactory());
}
 
Example 9
Source File: CSRFValve.java    From attic-stratos with Apache License 2.0 5 votes vote down vote up
/**
 * Load configuration
 */
private void loadConfiguration() {

    ServerConfiguration serverConfiguration = ServerConfiguration.getInstance();
    whiteList = serverConfiguration.getProperties(WHITE_LIST_PROPERTY);
    csrfPatternList = serverConfiguration.getProperties(RULE_PATTERN_PROPERTY);
    csrfRule = serverConfiguration.getFirstProperty(RULE_PROPERTY);
    if (whiteList.length > 0 && csrfPatternList.length > 0 && csrfRule != null
            && serverConfiguration.getFirstProperty(ENABLED_PROPERTY) != null && Boolean
            .parseBoolean(serverConfiguration.getFirstProperty(ENABLED_PROPERTY))) {
        csrfEnabled = true;
    }
}
 
Example 10
Source File: XSSValve.java    From attic-stratos with Apache License 2.0 5 votes vote down vote up
/**
 * Load configuration
 */
private void loadConfiguration() {

    ServerConfiguration serverConfiguration = ServerConfiguration.getInstance();
    if (serverConfiguration.getFirstProperty(ENABLED_PROPERTY) != null && Boolean.parseBoolean(
            serverConfiguration.getFirstProperty(ENABLED_PROPERTY))) {
        xssEnabled = true;
    }
    xssURIPatternList = serverConfiguration.getProperties(RULE_PATTERN_PROPERTY);
    xssRule = serverConfiguration.getFirstProperty(RULE_PROPERTY);
    patterPath = CarbonUtils.getCarbonSecurityConfigDirPath() + "/" + XSS_EXTENSION_FILE_NAME;
    buildScriptPatterns();
}
 
Example 11
Source File: Utils.java    From attic-stratos with Apache License 2.0 5 votes vote down vote up
/**
 * Read context name from carbon.xml
 * "carbon" will be the default value
 *
 * @return webcontext name
 */
public static String getWebContextName() {
    String webContext = "carbon";
    ServerConfiguration sc = ServerConfiguration.getInstance();
    if (sc != null) {
        String value = sc.getFirstProperty("WebContext");
        if (value != null) {
            webContext = value;
        }
    }
    return webContext;
}
 
Example 12
Source File: OAuthAdminServiceClient.java    From attic-stratos with Apache License 2.0 5 votes vote down vote up
public OAuthAdminServiceClient(String epr) throws AxisFault {

        XMLConfiguration conf = ConfUtil.getInstance(null).getConfiguration();
        int autosclaerSocketTimeout = conf.getInt("autoscaler.identity.clientTimeout", 180000);

        try {
            ServerConfiguration serverConfig = CarbonUtils.getServerConfiguration();
            String trustStorePath = serverConfig.getFirstProperty("Security.TrustStore.Location");
            String trustStorePassword = serverConfig.getFirstProperty("Security.TrustStore.Password");
            String type = serverConfig.getFirstProperty("Security.TrustStore.Type");
            System.setProperty("javax.net.ssl.trustStore", trustStorePath);
            System.setProperty("javax.net.ssl.trustStorePassword", trustStorePassword);
            System.setProperty("javax.net.ssl.trustStoreType", type);

            stub = new OAuthAdminServiceStub(epr);
            stub._getServiceClient().getOptions().setProperty(HTTPConstants.SO_TIMEOUT, autosclaerSocketTimeout);
            stub._getServiceClient().getOptions().setProperty(HTTPConstants.CONNECTION_TIMEOUT, autosclaerSocketTimeout);
            //String username = CarbonContext.getThreadLocalCarbonContext().getUsername();
            //TODO StratosAuthenticationHandler does not set to carbon context, thus user name becomes null.
            // For the moment username is hardcoded since above is fixed.
            String username = conf.getString("autoscaler.identity.adminUser", "admin");
            Utility.setAuthHeaders(stub._getServiceClient(), username);

        } catch (AxisFault axisFault) {
            String msg = "Failed to initiate identity service client. " + axisFault.getMessage();
            log.error(msg, axisFault);
            throw new AxisFault(msg, axisFault);
        }
    }
 
Example 13
Source File: KeyStoreAdmin.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
public KeyStoreAdmin(int tenantId, Registry registry) {

        ServerConfiguration config = ServerConfiguration.getInstance();
        TRUST_STORE_LOCATION = config.getFirstProperty("Security.TrustStore.Location");
        TRUST_STORE_PASSWORD = config.getFirstProperty("Security.TrustStore.Password");
        this.registry = registry;
        this.tenantId = tenantId;
    }
 
Example 14
Source File: CartridgeSubscriptionDataPublisher.java    From attic-stratos with Apache License 2.0 5 votes vote down vote up
private static void createDataPublisher() throws StratosManagerException {
    // creating the agent
    ServerConfiguration serverConfig = CarbonUtils.getServerConfiguration();
    String trustStorePath = serverConfig.getFirstProperty("Security.TrustStore.Location");
    String trustStorePassword = serverConfig.getFirstProperty("Security.TrustStore.Password");

    //value is in the carbon.xml file and should be set to the thrift port of BAM
    String bamServerUrl = serverConfig.getFirstProperty("BamServerURL");

    //getting the BAM related values from cartridge-config.properties
    String adminUsername = System.getProperty(CartridgeConstants.BAM_ADMIN_USERNAME);
    String adminPassword = System.getProperty(CartridgeConstants.BAM_ADMIN_PASSWORD);

    System.setProperty("javax.net.ssl.trustStore", trustStorePath);
    System.setProperty("javax.net.ssl.trustStorePassword",
            trustStorePassword);

    try {
        dataPublisher = new AsyncDataPublisher(
                "tcp://" + bamServerUrl + "", adminUsername, adminPassword);
        initializeStream();
        dataPublisher.addStreamDefinition(streamDefinition);
    } catch (Exception e) {
        String msg = "Unable to create a data publisher to " + bamServerUrl;
        log.error(msg, e);
        throw new StratosManagerException(msg, e);
    }
}
 
Example 15
Source File: SAML2TokenBuilder.java    From carbon-identity with Apache License 2.0 4 votes vote down vote up
@Override
public void createSAMLAssertion(DateTime notAfter, DateTime notBefore, String assertionId)
        throws IdentityProviderException {
    assertion = (Assertion) buildXMLObject(Assertion.DEFAULT_ELEMENT_NAME);
    Conditions conditions = (Conditions) buildXMLObject(Conditions.DEFAULT_ELEMENT_NAME);
    conditions.setNotBefore(notBefore);
    conditions.setNotOnOrAfter(notAfter);

    ServerConfiguration config = ServerConfiguration.getInstance();
    String host = "http://" + config.getFirstProperty("HostName");

    Issuer issuer = (Issuer) buildXMLObject(Issuer.DEFAULT_ELEMENT_NAME);
    issuer.setValue(host);
    assertion.setIssuer(issuer);
    assertion.setIssueInstant(new DateTime());

    if (appilesTo != null) {
        Audience audience = (Audience) buildXMLObject(Audience.DEFAULT_ELEMENT_NAME);
        audience.setAudienceURI(appilesTo);
        AudienceRestriction audienceRestrictions =
                (AudienceRestriction) buildXMLObject(AudienceRestriction.DEFAULT_ELEMENT_NAME);
        audienceRestrictions.getAudiences().add(audience);

        conditions.getAudienceRestrictions().add(audienceRestrictions);
    }

    assertion.setConditions(conditions);

    assertion.getAttributeStatements().add(this.attributeStmt);
    assertion.setID(assertionId);

    Subject subject = (Subject) buildXMLObject(Subject.DEFAULT_ELEMENT_NAME);
    SubjectConfirmation subjectConf =
            (SubjectConfirmation) buildXMLObject(SubjectConfirmation.DEFAULT_ELEMENT_NAME);
    SubjectConfirmationData confData =
            (SubjectConfirmationData) buildXMLObject(SubjectConfirmationData.DEFAULT_ELEMENT_NAME);
    confData.setAddress(CONF_KEY);
    subjectConf.setSubjectConfirmationData(confData);
    subject.getSubjectConfirmations().add(subjectConf);
    assertion.setSubject(subject);

}
 
Example 16
Source File: STSConfigAdmin.java    From carbon-identity with Apache License 2.0 4 votes vote down vote up
public static void configureService(AxisConfiguration config, Registry registry)
        throws IdentityProviderException {
    AxisConfiguration axisConfig = IdentitySTSMgtServiceComponent.getConfigurationContext().getAxisConfiguration();

    try {
        ServerConfiguration serverConfig = ServerConfiguration.getInstance();
        String ksName =
                serverConfig.getFirstProperty(STSMgtConstants.ServerConfigProperty.SECURITY_KEYSTORE_LOCATION);
        ksName = ksName.substring(ksName.lastIndexOf("/") + 1);

        SecurityConfigAdmin admin = new SecurityConfigAdmin(config, registry, new IPPasswordCallbackHandler());
        if (log.isDebugEnabled()) {
            log.debug("Applying identity security policy for Identity STS services");
        }

        if (IdentityProviderUtil.isIntial()) {
            if (axisConfig.getService(IdentityConstants.SERVICE_NAME_STS_UT) != null) {
                admin.applySecurity(IdentityConstants.SERVICE_NAME_STS_UT, STSMgtConstants.Policy.POLICY_SCENARIO19,
                                    null, null, null, null);
            }
            if (axisConfig.getService(IdentityConstants.OpenId.SERVICE_NAME_STS_OPENID) != null) {
                admin.applySecurity(IdentityConstants.OpenId.SERVICE_NAME_STS_OPENID,
                                    STSMgtConstants.Policy.POLICY_SCENARIO19, null, null, null, null);
            }
            if (axisConfig.getService(IdentityConstants.SERVICE_NAME_STS_IC) != null) {
                admin.applySecurity(IdentityConstants.SERVICE_NAME_STS_IC, STSMgtConstants.Policy.POLICY_SCENARIO18,
                                    null, new String[] { ksName }, ksName, null);
            }
            if (axisConfig.getService(IdentityConstants.OpenId.SERVICE_NAME_STS_IC_OPENID) != null) {
                admin.applySecurity(IdentityConstants.OpenId.SERVICE_NAME_STS_IC_OPENID,
                                    STSMgtConstants.Policy.POLICY_SCENARIO18, null, new String[] { ksName }, ksName,
                                    null);
            }
            if (axisConfig.getService(IdentityConstants.SERVICE_NAME_STS_UT_SYMM) != null) {
                admin.applySecurity(IdentityConstants.SERVICE_NAME_STS_UT_SYMM,
                                    STSMgtConstants.Policy.POLICY_SCENARIO18, null, new String[] { ksName }, ksName,
                                    null);
            }
            if (axisConfig.getService(IdentityConstants.SERVICE_NAME_STS_IC_SYMM) != null) {
                admin.applySecurity(IdentityConstants.SERVICE_NAME_STS_IC_SYMM,
                                    STSMgtConstants.Policy.POLICY_SCENARIO18, null, new String[] { ksName }, ksName,
                                    null);
            }
        }

        if (axisConfig.getService(IdentityConstants.SERVICE_NAME_STS_UT) != null) {
            overrideCallbackHandler(axisConfig, IdentityConstants.SERVICE_NAME_STS_UT);
        }
        if (axisConfig.getService(IdentityConstants.SERVICE_NAME_STS_UT_SYMM) != null) {
            overrideCallbackHandler(axisConfig, IdentityConstants.SERVICE_NAME_STS_UT_SYMM);
        }
        if (axisConfig.getService(IdentityConstants.OpenId.SERVICE_NAME_STS_OPENID) != null) {
            overrideCallbackHandler(axisConfig, IdentityConstants.OpenId.SERVICE_NAME_STS_OPENID);
        }
        if (axisConfig.getService(IdentityConstants.SERVICE_NAME_STS_IC) != null) {
            overrideCallbackHandler(axisConfig, IdentityConstants.SERVICE_NAME_STS_IC);
        }

    } catch (Exception e) {
        log.error("errorInChangingSecurityConfiguration", e);
        throw new IdentityProviderException("errorInChangingSecurityConfiguration", e);
    }

}
 
Example 17
Source File: KeyStoreManagementServiceImpl.java    From carbon-identity-framework with Apache License 2.0 4 votes vote down vote up
private String getTrustStoreName() {

        ServerConfiguration serverConfiguration = ServerConfiguration.getInstance();
        String filePath = serverConfiguration.getFirstProperty(SERVER_TRUSTSTORE_FILE);
        return Paths.get(filePath).getFileName().toString();
    }
 
Example 18
Source File: CarbonRepositoryUtils.java    From carbon-commons with Apache License 2.0 4 votes vote down vote up
/**
 * Load the deployment synchronizer configuration from the global ServerConfiguration
 * of Carbon.
 *
 * @return a DeploymentSynchronizerConfiguration instance
 * @throws org.wso2.carbon.deployment.synchronizer.DeploymentSynchronizerException on error
 */
public static DeploymentSynchronizerConfiguration getDeploymentSyncConfigurationFromConf() throws DeploymentSynchronizerException{

    DeploymentSynchronizerConfiguration config = new DeploymentSynchronizerConfiguration();
    ServerConfiguration serverConfig = ServerConfiguration.getInstance();

    String value = serverConfig.getFirstProperty(DeploymentSynchronizerConstants.ENABLED);
    //If Deployment Synchronizer Configuration is not found in carbon.xml
    if (value == null) {
        return null;
    }
    config.setEnabled(JavaUtils.isTrueExplicitly(value));

    if (config.isEnabled()) {
        value = serverConfig.getFirstProperty(DeploymentSynchronizerConstants.AUTO_CHECKOUT_MODE);
        config.setAutoCheckout(value != null && JavaUtils.isTrueExplicitly(value));

        value = serverConfig.getFirstProperty(DeploymentSynchronizerConstants.AUTO_COMMIT_MODE);
        config.setAutoCommit(value != null && JavaUtils.isTrueExplicitly(value));

        value = serverConfig.getFirstProperty(DeploymentSynchronizerConstants.USE_EVENTING);
        config.setUseEventing(value != null && JavaUtils.isTrueExplicitly(value));

        value = serverConfig.getFirstProperty(DeploymentSynchronizerConstants.AUTO_SYNC_PERIOD);
        if (value != null) {
            config.setPeriod(Long.parseLong(value));
        } else {
            config.setPeriod(DeploymentSynchronizerConstants.DEFAULT_AUTO_SYNC_PERIOD);
        }

        value = serverConfig.getFirstProperty(DeploymentSynchronizerConstants.REPOSITORY_TYPE);
        if (value != null) {
            config.setRepositoryType(value);
        } else {
            config.setRepositoryType(DeploymentSynchronizerConstants.DEFAULT_REPOSITORY_TYPE);
        }

        ArtifactRepository repository =
                RepositoryReferenceHolder.getInstance().getRepositoryByType(config.getRepositoryType());
        if (repository == null) {
            throw new DeploymentSynchronizerException("No Repository found for type " + config.getRepositoryType());
        }

        List<RepositoryConfigParameter> parameters = repository.getParameters();

        //If repository specific configuration parameters are found.
        if (parameters != null) {
            //Find the 'value' of each parameter from the server config by parameter 'name' and attach to parameter
            for (RepositoryConfigParameter parameter : parameters) {
                parameter.setValue(serverConfig.getFirstProperty(parameter.getName()));
            }

            //Attach parameter list to config object.
            config.setRepositoryConfigParameters(
                    parameters.toArray(new RepositoryConfigParameter[parameters.size()]));
        }

        return config;
    } else {
        return config;
    }
}
 
Example 19
Source File: SecurityConfigParams.java    From carbon-identity with Apache License 2.0 3 votes vote down vote up
/**
 * Get the private key alias
 *
 * If the key alias is defined in the Security configuration take it from there otherwise
 * key alias is taken from the Server Configuration
 *
 * @return private key key alias
 */
public String getKeyAlias() {
    if (keyAlias == null) {
        ServerConfiguration serverConfig = ServerConfiguration.getInstance();
        return serverConfig.getFirstProperty("Security.KeyStore.KeyAlias");
    }
    return keyAlias;
}