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


Java ServerConfiguration类代码示例

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


ServerConfiguration类属于org.wso2.carbon.base包,在下文中一共展示了ServerConfiguration类的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: activate

import org.wso2.carbon.base.ServerConfiguration; //导入依赖的package包/类
@Activate
protected void activate(ComponentContext context) {
    BundleContext bundleContext = context.getBundleContext();
    WorkflowManagementService workflowService = new WorkflowManagementServiceImpl();
    bundleContext.registerService(WorkflowManagementService.class, workflowService, null);
    WorkflowServiceDataHolder.getInstance().setWorkflowService(workflowService);
    WorkflowServiceDataHolder.getInstance().setBundleContext(bundleContext);
    ServiceRegistration serviceRegistration = context.getBundleContext().registerService(WorkflowListener.class.getName(), new WorkflowAuditLogger(), null);
    context.getBundleContext().registerService(WorkflowExecutorManagerListener.class.getName(), new WorkflowExecutorAuditLogger(), null);
    if (serviceRegistration != null) {
        if (log.isDebugEnabled()) {
            log.debug("WorkflowAuditLogger registered.");
        }
    } else {
        log.error("Workflow Audit Logger could not be registered.");
    }
    if (System.getProperty(WFConstant.KEYSTORE_SYSTEM_PROPERTY_ID) == null) {
        System.setProperty(WFConstant.KEYSTORE_SYSTEM_PROPERTY_ID, ServerConfiguration.getInstance().getFirstProperty(WFConstant.KEYSTORE_CARBON_CONFIG_PATH));
    }
    if (System.getProperty(WFConstant.KEYSTORE_PASSWORD_SYSTEM_PROPERTY_ID) == null) {
        System.setProperty(WFConstant.KEYSTORE_PASSWORD_SYSTEM_PROPERTY_ID, ServerConfiguration.getInstance().getFirstProperty(WFConstant.KEYSTORE_PASSWORD_CARBON_CONFIG_PATH));
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:24,代码来源:WorkflowMgtServiceComponent.java

示例3: getTrustedSSLSocketFactory

import org.wso2.carbon.base.ServerConfiguration; //导入依赖的package包/类
private static SSLSocketFactory getTrustedSSLSocketFactory() {
    try {
        String keyStorePassword = ServerConfiguration.getInstance().getFirstProperty("Security.KeyStore.Password");
        String keyStoreLocation = ServerConfiguration.getInstance().getFirstProperty("Security.KeyStore.Location");
        String trustStorePassword = ServerConfiguration.getInstance().getFirstProperty(
                "Security.TrustStore.Password");
        String trustStoreLocation = ServerConfiguration.getInstance().getFirstProperty(
                "Security.TrustStore.Location");
        KeyStore keyStore = loadKeyStore(keyStoreLocation,keyStorePassword,KEY_STORE_TYPE);
        KeyStore trustStore = loadTrustStore(trustStoreLocation,trustStorePassword);

        return initSSLConnection(keyStore,keyStorePassword,trustStore);
    } catch (KeyManagementException | NoSuchAlgorithmException | KeyStoreException
            |CertificateException | IOException | UnrecoverableKeyException e) {
        log.error("Error while creating the SSL socket factory due to "+e.getMessage(),e);
        return null;
    }

}
 
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:20,代码来源:Utils.java

示例4: SignKeyDataHolder

import org.wso2.carbon.base.ServerConfiguration; //导入依赖的package包/类
public SignKeyDataHolder() throws Exception {
    try {
        String keyAlias = ServerConfiguration.getInstance().getFirstProperty("Security.KeyStore.KeyAlias");
        KeyStoreManager keyMan = KeyStoreManager.getInstance(MultitenantConstants.SUPER_TENANT_ID);
        Certificate[] certificates = keyMan.getPrimaryKeyStore().getCertificateChain(keyAlias);
        issuerPK = keyMan.getDefaultPrivateKey();
        issuerCerts = new X509Certificate[certificates.length];
        int i = 0;
        for (Certificate certificate : certificates) {
            issuerCerts[i++] = (X509Certificate) certificate;
        }
        signatureAlgorithm = XMLSignature.ALGO_ID_SIGNATURE_RSA;
        String pubKeyAlgo = issuerCerts[0].getPublicKey().getAlgorithm();
        if (pubKeyAlgo.equalsIgnoreCase("DSA")) {
            signatureAlgorithm = XMLSignature.ALGO_ID_SIGNATURE_DSA;
        }

    } catch (Exception e) {
        throw new Exception("Error while reading the key", e);
    }

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

示例5: activate

import org.wso2.carbon.base.ServerConfiguration; //导入依赖的package包/类
protected void activate(ComponentContext ctxt) {
    try {
        ConfigurationContext mainConfigCtx = configContextService.getServerConfigContext();
        AxisConfiguration mainAxisConfig = mainConfigCtx.getAxisConfiguration();
        BundleContext bundleCtx = ctxt.getBundleContext();
        String enablePoxSecurity = ServerConfiguration.getInstance()
                .getFirstProperty("EnablePoxSecurity");
        if (enablePoxSecurity == null || "true".equals(enablePoxSecurity)) {
            mainAxisConfig.engageModule(POX_SECURITY_MODULE);
        } else {
            log.info("POX Security Disabled");
        }

        bundleCtx.registerService(SecurityConfigAdmin.class.getName(),
                new SecurityConfigAdmin(mainAxisConfig,
                        registryService.getConfigSystemRegistry(),
                        null),
                null);
        bundleCtx.registerService(Axis2ConfigurationContextObserver.class.getName(),
                new SecurityAxis2ConfigurationContextObserver(),
                null);
        log.debug("Security Mgt bundle is activated");
    } catch (Throwable e) {
        log.error("Failed to activate SecurityMgtServiceComponent", e);
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:27,代码来源:SecurityMgtServiceComponent.java

示例6: 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

示例7: createDefaultJSch

import org.wso2.carbon.base.ServerConfiguration; //导入依赖的package包/类
@Override
protected JSch createDefaultJSch(FS fs) throws JSchException {

    JSch def = super.createDefaultJSch(fs);
    String keyName = ServerConfiguration.getInstance().
            getFirstProperty(GitDeploymentSynchronizerConstants.SSH_PRIVATE_KEY_NAME);
    String keyPath = ServerConfiguration.getInstance().
            getFirstProperty(GitDeploymentSynchronizerConstants.SSH_PRIVATE_KEY_PATH);

    if (keyName == null || keyName.isEmpty())
        keyName = GitDeploymentSynchronizerConstants.SSH_KEY;

    if (keyPath == null || keyPath.isEmpty())
        keyPath = System.getProperty("user.home") + "/" + GitDeploymentSynchronizerConstants.SSH_KEY_DIRECTORY;

    if (keyPath.endsWith("/"))
        def.addIdentity(keyPath + keyName);
    else
        def.addIdentity(keyPath + "/" + keyName);

    return def;
}
 
开发者ID:apache,项目名称:stratos,代码行数:23,代码来源:CustomJschConfigSessionFactory.java

示例8: doPaging

import org.wso2.carbon.base.ServerConfiguration; //导入依赖的package包/类
/**
 * This method is used internally to do the pagination purposes.
 *
 * @param pageNumber page Number
 * @param policySet  set of policies
 * @return PaginatedPolicySetDTO object containing the number of pages and the set of policies
 * that reside in the given page.
 */
private PaginatedPolicySetDTO doPaging(int pageNumber, PolicyDTO[] policySet) {

    PaginatedPolicySetDTO paginatedPolicySet = new PaginatedPolicySetDTO();
    if (policySet.length == 0) {
        paginatedPolicySet.setPolicySet(new PolicyDTO[0]);
        return paginatedPolicySet;
    }
    String itemsPerPage = EntitlementServiceComponent.getEntitlementConfig().
            getEngineProperties().getProperty(PDPConstants.ENTITLEMENT_ITEMS_PER_PAGE);
    if (itemsPerPage != null) {
        itemsPerPage = ServerConfiguration.getInstance().getFirstProperty("ItemsPerPage");
    }
    int itemsPerPageInt = PDPConstants.DEFAULT_ITEMS_PER_PAGE;
    if (itemsPerPage != null) {
        itemsPerPageInt = Integer.parseInt(itemsPerPage);
    }
    int numberOfPages = (int) Math.ceil((double) policySet.length / itemsPerPageInt);
    if (pageNumber > numberOfPages - 1) {
        pageNumber = numberOfPages - 1;
    }
    int startIndex = pageNumber * itemsPerPageInt;
    int endIndex = (pageNumber + 1) * itemsPerPageInt;
    PolicyDTO[] returnedPolicySet = new PolicyDTO[itemsPerPageInt];

    for (int i = startIndex, j = 0; i < endIndex && i < policySet.length; i++, j++) {
        returnedPolicySet[j] = policySet[i];
    }

    paginatedPolicySet.setPolicySet(returnedPolicySet);
    paginatedPolicySet.setNumberOfPages(numberOfPages);

    return paginatedPolicySet;
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:42,代码来源:EntitlementPolicyAdminService.java

示例9: doPagingString

import org.wso2.carbon.base.ServerConfiguration; //导入依赖的package包/类
/**
 * This method is used internally to do the pagination purposes.
 *
 * @param pageNumber page Number
 * @param ids        <code>String</code>
 * @return PaginatedStringDTO object containing the number of pages and the set of policies
 * that reside in the given page.
 */
private PaginatedStringDTO doPagingString(int pageNumber, String[] ids) {

    PaginatedStringDTO paginatedStatusHolder = new PaginatedStringDTO();
    if (ids.length == 0) {
        paginatedStatusHolder.setStatusHolders(new String[0]);
        return paginatedStatusHolder;
    }

    String itemsPerPage = EntitlementServiceComponent.getEntitlementConfig().
            getEngineProperties().getProperty(PDPConstants.ENTITLEMENT_ITEMS_PER_PAGE);
    if (itemsPerPage != null) {
        itemsPerPage = ServerConfiguration.getInstance().getFirstProperty("ItemsPerPage");
    }
    int itemsPerPageInt = PDPConstants.DEFAULT_ITEMS_PER_PAGE;
    if (itemsPerPage != null) {
        itemsPerPageInt = Integer.parseInt(itemsPerPage);
    }
    int numberOfPages = (int) Math.ceil((double) ids.length / itemsPerPageInt);
    if (pageNumber > numberOfPages - 1) {
        pageNumber = numberOfPages - 1;
    }
    int startIndex = pageNumber * itemsPerPageInt;
    int endIndex = (pageNumber + 1) * itemsPerPageInt;
    String[] returnedHolders = new String[itemsPerPageInt];

    for (int i = startIndex, j = 0; i < endIndex && i < ids.length; i++, j++) {
        returnedHolders[j] = ids[i];
    }

    paginatedStatusHolder.setStatusHolders(returnedHolders);
    paginatedStatusHolder.setNumberOfPages(numberOfPages);

    return paginatedStatusHolder;
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:43,代码来源:EntitlementPolicyAdminService.java

示例10: 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

示例11: activate

import org.wso2.carbon.base.ServerConfiguration; //导入依赖的package包/类
@Activate
protected void activate(ComponentContext ctxt) {
    try {
        ConfigurationContext mainConfigCtx = configContextService.getServerConfigContext();
        AxisConfiguration mainAxisConfig = mainConfigCtx.getAxisConfiguration();
        BundleContext bundleCtx = ctxt.getBundleContext();
        String enablePoxSecurity = ServerConfiguration.getInstance()
                .getFirstProperty("EnablePoxSecurity");
        if (enablePoxSecurity == null || "true".equals(enablePoxSecurity)) {
            mainAxisConfig.engageModule(POX_SECURITY_MODULE);
        } else {
            log.info("POX Security Disabled");
        }

        bundleCtx.registerService(SecurityConfigAdmin.class.getName(),
                new SecurityConfigAdmin(mainAxisConfig,
                        registryService.getConfigSystemRegistry(),
                        null),
                null);
        bundleCtx.registerService(Axis2ConfigurationContextObserver.class.getName(),
                new SecurityAxis2ConfigurationContextObserver(),
                null);
        log.debug("Security Mgt bundle is activated");
    } catch (Throwable e) {
        log.error("Failed to activate SecurityMgtServiceComponent", e);
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:28,代码来源:SecurityMgtServiceComponent.java

示例12: setAuthHeaders

import org.wso2.carbon.base.ServerConfiguration; //导入依赖的package包/类
private void setAuthHeaders(MessageContext msgCtx) throws IOException {
    String serverName = ServerConfiguration.getInstance().getFirstProperty("Name");

    if (serverName == null || serverName.trim().length() == 0) {
        serverName = "WSO2 Carbon";
    }

    HttpServletResponse response = (HttpServletResponse)
            msgCtx.getProperty(HTTPConstants.MC_HTTP_SERVLETRESPONSE);
    // TODO : verify this fix. This is to handle soap fault from UT scenario
    if (msgCtx.isFault() && response == null) {
        MessageContext originalContext = (MessageContext) msgCtx.getProperty(MessageContext.IN_MESSAGE_CONTEXT);
        if (originalContext != null) {
            response = (HttpServletResponse)
                    originalContext.getProperty(HTTPConstants.MC_HTTP_SERVLETRESPONSE);
        }
    }
    if (response != null) {
        if (msgCtx.getProperty(MESSAGE_TYPE) != null) {
            response.setContentType(String.valueOf(msgCtx.getProperty(MESSAGE_TYPE)));
        }
        response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
        response.addHeader("WWW-Authenticate",
                "BASIC realm=\"" + serverName + "\"");
        response.flushBuffer();
    } else {
        // if not servlet transport assume it to be nhttp transport
        msgCtx.setProperty("NIO-ACK-Requested", "true");
        msgCtx.setProperty("HTTP_SC", HttpServletResponse.SC_UNAUTHORIZED);
        Map<String, String> responseHeaders = new HashMap<>();
        responseHeaders.put("WWW-Authenticate",
                "BASIC realm=\"" + serverName + "\"");
        msgCtx.setProperty(MessageContext.TRANSPORT_HEADERS, responseHeaders);
    }

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

示例13: 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

示例14: testGetDefaultRampartConfig

import org.wso2.carbon.base.ServerConfiguration; //导入依赖的package包/类
@Test
public void testGetDefaultRampartConfig() throws Exception {
    //mock ServerConfiguration
    mockStatic(ServerConfiguration.class);
    when(ServerConfiguration.getInstance()).thenReturn(mockServerConfig);
    when(mockServerConfig.getFirstProperty(anyString())).thenReturn("mockedValue");

    Policy policy = IdentityBaseUtil.getDefaultRampartConfig();
    assertNotNull(policy);
    assertNotNull(policy.getFirstPolicyComponent());
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:12,代码来源:IdentityBaseUtilTest.java

示例15: isValidFileName

import org.wso2.carbon.base.ServerConfiguration; //导入依赖的package包/类
public static boolean isValidFileName(String fileName) {
    String fileNameRegEx = ServerConfiguration.getInstance().getFirstProperty(IdentityCoreConstants.FILE_NAME_REGEX);

    if (isBlank(fileNameRegEx)) {
        fileNameRegEx = DEFAULT_FILE_NAME_REGEX;
    }

    Pattern pattern = Pattern.compile(fileNameRegEx, Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE |
            Pattern.COMMENTS);
    Matcher matcher = pattern.matcher(fileName);
    return matcher.matches();
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:13,代码来源:IdentityUtil.java


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