当前位置: 首页>>代码示例>>Java>>正文


Java ServerConfiguration.getFirstProperty方法代码示例

本文整理汇总了Java中org.wso2.carbon.base.ServerConfiguration.getFirstProperty方法的典型用法代码示例。如果您正苦于以下问题:Java ServerConfiguration.getFirstProperty方法的具体用法?Java ServerConfiguration.getFirstProperty怎么用?Java ServerConfiguration.getFirstProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.wso2.carbon.base.ServerConfiguration的用法示例。


在下文中一共展示了ServerConfiguration.getFirstProperty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getPrivateKey

import org.wso2.carbon.base.ServerConfiguration; //导入方法依赖的package包/类
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;
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:25,代码来源:KeyStoreAdmin.java

示例2: IdentityApplicationManagementServiceClient

import org.wso2.carbon.base.ServerConfiguration; //导入方法依赖的package包/类
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);
        }
    }
 
开发者ID:apache,项目名称:stratos,代码行数:27,代码来源:IdentityApplicationManagementServiceClient.java

示例3: getPrivateStore

import org.wso2.carbon.base.ServerConfiguration; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:18,代码来源:SecurityConfigParams.java

示例4: getDefaultRampartConfig

import org.wso2.carbon.base.ServerConfiguration; //导入方法依赖的package包/类
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;

    }
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:41,代码来源:IdentityBaseUtil.java

示例5: getHostName

import org.wso2.carbon.base.ServerConfiguration; //导入方法依赖的package包/类
private static String getHostName() {
    ServerConfiguration serverConfig = ServerConfiguration.getInstance();
    if (serverConfig.getFirstProperty("HostName") != null) {
        return MultitenantUtils.getDomainNameFromOpenId(serverConfig.getFirstProperty("HostName"));
    } else {
        return "localhost";
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:9,代码来源:OpenIDUtil.java

示例6: createSAMLAssertion

import org.wso2.carbon.base.ServerConfiguration; //导入方法依赖的package包/类
@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);

}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:30,代码来源:SAML1TokenBuilder.java

示例7: getDefaultRampartConfig

import org.wso2.carbon.base.ServerConfiguration; //导入方法依赖的package包/类
@Deprecated
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.registry.ws.api.utils.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);
    sigCrypto.setProp(props);

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

}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:35,代码来源:SecurityUtil.java

示例8: addUser

import org.wso2.carbon.base.ServerConfiguration; //导入方法依赖的package包/类
public static void addUser() {
	//Extract the primary keystore information from server configuration
    ServerConfiguration serverConfig = ServerConfiguration.getInstance();
    String privateKeyAlias = serverConfig.getFirstProperty("Security.KeyStore.KeyAlias");
    String privateKeyPassword = serverConfig.getFirstProperty("Security.KeyStore.KeyPassword");
	//Set the private key alias and private key password in the password callback handler
    InMemoryPasswordCallbackHandler.addUser(privateKeyAlias, privateKeyPassword);
}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:9,代码来源:SecurityUtil.java

示例9: init

import org.wso2.carbon.base.ServerConfiguration; //导入方法依赖的package包/类
/**
 * 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());
}
 
开发者ID:wso2,项目名称:carbon-commons,代码行数:20,代码来源:DeploymentSynchronizationManager.java

示例10: loadConfiguration

import org.wso2.carbon.base.ServerConfiguration; //导入方法依赖的package包/类
/**
 * 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;
    }
}
 
开发者ID:apache,项目名称:stratos,代码行数:16,代码来源:CSRFValve.java

示例11: loadConfiguration

import org.wso2.carbon.base.ServerConfiguration; //导入方法依赖的package包/类
/**
 * 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();
}
 
开发者ID:apache,项目名称:stratos,代码行数:16,代码来源:XSSValve.java

示例12: getWebContextName

import org.wso2.carbon.base.ServerConfiguration; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:apache,项目名称:stratos,代码行数:18,代码来源:Utils.java

示例13: OAuthAdminServiceClient

import org.wso2.carbon.base.ServerConfiguration; //导入方法依赖的package包/类
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);
        }
    }
 
开发者ID:apache,项目名称:stratos,代码行数:30,代码来源:OAuthAdminServiceClient.java

示例14: createDataPublisher

import org.wso2.carbon.base.ServerConfiguration; //导入方法依赖的package包/类
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);
    }
}
 
开发者ID:apache,项目名称:stratos,代码行数:29,代码来源:CartridgeSubscriptionDataPublisher.java

示例15: decryptElement

import org.wso2.carbon.base.ServerConfiguration; //导入方法依赖的package包/类
private static Element decryptElement(Element encryptedToken) throws Exception {

        ServerConfiguration serverConfig = ServerConfiguration.getInstance();
        PrivateKey key = null;
        String keyStoreFile = null;
        String privateKeyPass = null;
        String privateKeyAlias = null;
        String keyStorePass = null;
        String type = null;
        byte[] content = null;

        keyStoreFile = serverConfig.getFirstProperty("Security.KeyStore.Location");
        keyStorePass = serverConfig.getFirstProperty("Security.KeyStore.Password");
        type = serverConfig.getFirstProperty("Security.KeyStore.Type");
        privateKeyAlias = serverConfig.getFirstProperty("Security.KeyStore.KeyAlias");
        privateKeyPass = serverConfig.getFirstProperty("Security.KeyStore.KeyPassword");

        content = readBytesFromFile(keyStoreFile);

        KeyStore keyStore = KeyStore.getInstance(type);
        keyStore.load(new ByteArrayInputStream(content), keyStorePass.toCharArray());

        key = (PrivateKey) keyStore.getKey(privateKeyAlias, privateKeyPass.toCharArray());

        Element kiElem = (Element) encryptedToken.getElementsByTagNameNS(WSConstants.SIG_NS, "KeyInfo").item(0);
        Element encrKeyElem =
                (Element) kiElem.getElementsByTagNameNS(WSConstants.ENC_NS, EncryptionConstants._TAG_ENCRYPTEDKEY)
                                .item(0);

        EncryptedKeyProcessor encrKeyProcessor = new EncryptedKeyProcessor();
        encrKeyProcessor.handleEncryptedKey(encrKeyElem, key);

        SecretKey secretKey = WSSecurityUtil.prepareSecretKey(
                EncryptionConstants.ALGO_ID_BLOCKCIPHER_AES128, encrKeyProcessor.getDecryptedBytes());

        XMLCipher cipher = XMLCipher.getInstance();
        cipher.init(XMLCipher.DECRYPT_MODE, secretKey);

        Document doc = cipher.doFinal(encryptedToken.getOwnerDocument(), encryptedToken);

        return doc.getDocumentElement();
    }
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:43,代码来源:TokenDecrypter.java


注:本文中的org.wso2.carbon.base.ServerConfiguration.getFirstProperty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。