org.wso2.carbon.base.api.ServerConfigurationService源码实例Demo

java.net.ContentHandler#org.wso2.carbon.base.api.ServerConfigurationService源码实例Demo

下面列出了java.net.ContentHandler#org.wso2.carbon.base.api.ServerConfigurationService 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

@Reference(
        name = "server.configuration.service",
        service = ServerConfigurationService.class,
        cardinality = ReferenceCardinality.MANDATORY,
        policy = ReferencePolicy.DYNAMIC,
        unbind = "unsetServerConfigurationService"
)
protected void setServerConfigurationService(ServerConfigurationService serverConfigurationService) {
    if (log.isDebugEnabled()) {
        log.debug("Set the ServerConfiguration Service");
    }
    IdentityCoreServiceComponent.serverConfigurationService = serverConfigurationService;

}
 
/**
 * Encrypt a given text.
 *
 * @param plainText Cipher text to be encrypted
 * @return Returns the encrypted text
 * @throws IdentityUserStoreMgtException Encryption failed
 */
public String encryptPlainText(String plainText) throws IdentityUserStoreMgtException {

    boolean isInternalKeyStoreEncryptionEnabled = false;
    boolean isSymmetricKeyEncryptionEnabled = false;
    ServerConfigurationService config =
            UserStoreConfigComponent.getServerConfigurationService();
    if (config != null) {
        String encryptionKeyStore = config.getFirstProperty(ENCRYPTION_KEYSTORE);

        if (INTERNAL_KEYSTORE.equalsIgnoreCase(encryptionKeyStore)) {
            isInternalKeyStoreEncryptionEnabled = true;
        }
        String cryptoProvider = config.getFirstProperty(CRYPTO_PROVIDER);
        if (SYMMETRIC_KEY_CRYPTO_PROVIDER.equalsIgnoreCase(cryptoProvider)) {
            isSymmetricKeyEncryptionEnabled = true;
        }
    }

    if (isInternalKeyStoreEncryptionEnabled && isSymmetricKeyEncryptionEnabled) {

        throw new IdentityUserStoreMgtException(String.format("Userstore encryption can not be supported due to " +
                "conflicting configurations: '%s' and '%s'. When using internal keystore, assymetric crypto " +
                "provider should be used.", INTERNAL_KEYSTORE, SYMMETRIC_KEY_CRYPTO_PROVIDER));
    } else if (isInternalKeyStoreEncryptionEnabled || isSymmetricKeyEncryptionEnabled) {

        try {
            return CryptoUtil.getDefaultCryptoUtil().encryptAndBase64Encode(plainText.getBytes());
        } catch (CryptoException e) {
            String errorMessage = "Error while encrypting the plain text using internal keystore.";
            throw new IdentityUserStoreMgtException(errorMessage, e);
        }
    } else {
        return encryptWithPrimaryKeyStore(config, plainText);
    }
}
 
@Reference(
        name = "server.configuration.service",
        service = ServerConfigurationService.class,
        cardinality = ReferenceCardinality.MANDATORY,
        policy = ReferencePolicy.DYNAMIC,
        unbind = "unsetServerConfigurationService"
)
protected void setServerConfigurationService(ServerConfigurationService serverConfigurationService) {
    if (log.isDebugEnabled()) {
        log.debug("Set the ServerConfiguration Service");
    }
    UserStoreConfigComponent.serverConfigurationService = serverConfigurationService;

}
 
@Reference(
        name = "server.configuration.service",
        service = ServerConfigurationService.class,
        cardinality = ReferenceCardinality.MANDATORY,
        policy = ReferencePolicy.DYNAMIC,
        unbind = "unsetServerConfigurationService"
)
protected void setServerConfigurationService(ServerConfigurationService serverConfigurationService) {
    if (log.isDebugEnabled()) {
        log.debug("Setting the serverConfigurationService");
    }
    UserStoreConfigComponent.serverConfigurationService = serverConfigurationService;
}
 
源代码5 项目: carbon-identity-framework   文件: UserStoreUtil.java
/**
 * Util function to encrypt given plain text using given cipher
 *
 * @param plainTextBytes target plain text to encrypt using the cipher
 * @return Cipher text
 * @throws BadPaddingException
 * @throws IllegalBlockSizeException
 * @throws IOException
 */
public static byte[] encrypt(byte[] plainTextBytes) throws CryptoException {

    boolean isInternalKeyStoreEncryptionEnabled = false;
    boolean isSymmetricKeyEncryptionEnabled = false;
    ServerConfigurationService config =
            UserStoreConfigComponent.getServerConfigurationService();
    if (config != null) {
        String encryptionKeyStore = config.getFirstProperty(UserStoreConfigurationConstants.ENCRYPTION_KEYSTORE);

        if (INTERNAL_KEYSTORE.equalsIgnoreCase(encryptionKeyStore)) {
            isInternalKeyStoreEncryptionEnabled = true;
        }
        String cryptoProvider = config.getFirstProperty(UserStoreConfigurationConstants.CRYPTO_PROVIDER);
        if (UserStoreConfigurationConstants.SYMMETRIC_KEY_CRYPTO_PROVIDER.equalsIgnoreCase(cryptoProvider)) {
            isSymmetricKeyEncryptionEnabled = true;
        }
    }

    if (isInternalKeyStoreEncryptionEnabled && isSymmetricKeyEncryptionEnabled) {

        throw new CryptoException(String.format("Userstore encryption can not be supported due to " +
                        "conflicting configurations: '%s' and '%s'. When using internal keystore, assymetric crypto " +
                        "provider should be used.", UserStoreConfigurationConstants.INTERNAL_KEYSTORE,
                UserStoreConfigurationConstants.SYMMETRIC_KEY_CRYPTO_PROVIDER));
    } else if (isInternalKeyStoreEncryptionEnabled || isSymmetricKeyEncryptionEnabled) {
        return CryptoUtil.getDefaultCryptoUtil().encrypt(plainTextBytes);
    } else {
        return encryptWithPrimaryKeyStore(plainTextBytes);
    }
}
 
源代码6 项目: product-ei   文件: MigrationServiceComponent.java
/**
 * Method to set server configuration service.
 *
 * @param serverConfigurationService ServerConfigurationService.
 */
protected void setServerConfigurationService(ServerConfigurationService serverConfigurationService) {
    if (log.isDebugEnabled()) {
        log.debug("Setting ServerConfigurationService to WSO2 EI Config component");
    }
    MigrationServiceDataHolder.setServerConfigurationService(serverConfigurationService);
}
 
源代码7 项目: product-ei   文件: MigrationServiceComponent.java
/**
 * Method to unset server configuration service.
 *
 * @param serverConfigurationService ServerConfigurationService.
 */
protected void unsetServerConfigurationService(ServerConfigurationService serverConfigurationService) {
    if (log.isDebugEnabled()) {
        log.debug("Unsetting ServerConfigurationService from WSO2 EI Config component");
    }
    MigrationServiceDataHolder.setServerConfigurationService(null);
}
 
protected void setServerConfigurationService(ServerConfigurationService serverConfigurationService) {
    if (log.isDebugEnabled()) {
        log.debug("Set the ServerConfiguration Service");
    }
    UserStoreConfigComponent.serverConfigurationService = serverConfigurationService;

}
 
/**
 * This method will be called when {@link ServerConfigurationService} instance is available in OSGI environment.
 *
 * @param serverConfigurationService Instance of {@link ServerConfigurationService}
 */
@Reference(
        name = "server.configuration.service",
        service = org.wso2.carbon.base.api.ServerConfigurationService.class,
        cardinality = ReferenceCardinality.MANDATORY,
        policy = ReferencePolicy.DYNAMIC,
        unbind = "unsetServerConfigurationService")
protected void setServerConfigurationService(ServerConfigurationService serverConfigurationService) {

    if (log.isDebugEnabled()) {
        log.debug("Server configuration service is bound to the API handlers");
    }
    ServiceReferenceHolder.getInstance().setServerConfigurationService(serverConfigurationService);
}
 
源代码10 项目: carbon-apimgt   文件: APIHandlerServiceComponent.java
/**
 * This method will be called when {@link ServerConfigurationService} instance is being removed from OSGI
 * environment.
 *
 * @param serverConfigurationService Instance of {@link ServerConfigurationService}
 */
protected void unsetServerConfigurationService(ServerConfigurationService serverConfigurationService) {

    if (log.isDebugEnabled()) {
        log.debug("Server configuration service is unbound from the API handlers");
    }
    ServiceReferenceHolder.getInstance().setServerConfigurationService(null);
}
 
@Reference(
        name = "server.configuration",
        service = org.wso2.carbon.base.api.ServerConfigurationService.class,
        cardinality = ReferenceCardinality.MANDATORY,
        policy = ReferencePolicy.DYNAMIC,
        unbind = "unsetServerConfiguration")
protected void setServerConfiguration(ServerConfigurationService serverConfiguration) {

    this.serverConfig = serverConfiguration;
}
 
源代码12 项目: attic-stratos   文件: CarbonUIServiceComponent.java
public static ServerConfigurationService getServerConfiguration() {
    if (serverConfiguration == null) {
        String msg = "Before activating Carbon UI bundle, an instance of "
                     + "ServerConfiguration Service should be in existence";
        log.error(msg);
        throw new RuntimeException(msg);
    }
    return serverConfiguration;
}
 
源代码13 项目: attic-stratos   文件: CarbonUIServiceComponent.java
/**
 * This method checks whether the management console is configured to run on the local transport.
 * Check the ServerURL property in the carbon.xml.
 * Set a system property if and only if the system is running on local transport.
 * 
 * @param serverConfiguration Service configuration.
 * @return boolean; true if running on local transport
 */
private boolean checkForLocalTransportMode(ServerConfigurationService serverConfiguration) {
    String serverURL = serverConfiguration.getFirstProperty(CarbonConstants.SERVER_URL);
    if(serverURL != null && (serverURL.startsWith("local") ||
            serverURL.startsWith("Local") || serverURL.startsWith("LOCAL"))) {
        System.setProperty(CarbonConstants.LOCAL_TRANSPORT_MODE_ENABLED, "true");
        return true;
    }
    return false;
}
 
源代码14 项目: attic-stratos   文件: CarbonUIUtil.java
/**
 * Get a ServerConfiguration Property
 *
 * @param propertyName Name of the property
 * @return the property
 */
public static String getServerConfigurationProperty(String propertyName) {
    try {
        ServerConfigurationService serverConfig = CarbonUIServiceComponent.getServerConfiguration();
        return serverConfig.getFirstProperty(propertyName);
    } catch (Exception e) {
        String msg = "ServerConfiguration Service not available";
        log.error(msg, e);
    }

    return null;
}
 
public static ServerConfigurationService getServerConfigurationService() {
    return IdentityCoreServiceComponent.serverConfigurationService;
}
 
protected void unsetServerConfigurationService(ServerConfigurationService serverConfigurationService) {
    if (log.isDebugEnabled()) {
        log.debug("Unset the ServerConfiguration Service");
    }
    IdentityCoreServiceComponent.serverConfigurationService = null;
}
 
public static ServerConfigurationService getServerConfigurationService() {
    return UserStoreConfigComponent.serverConfigurationService;
}
 
protected void unsetServerConfigurationService(ServerConfigurationService serverConfigurationService) {
    if (log.isDebugEnabled()) {
        log.debug("Unset the ServerConfiguration Service");
    }
    UserStoreConfigComponent.serverConfigurationService = null;
}
 
public static ServerConfigurationService getServerConfigurationService() {
    return UserStoreConfigComponent.serverConfigurationService;
}
 
protected void unsetServerConfigurationService(ServerConfigurationService serverConfigurationService) {
    if (log.isDebugEnabled()) {
        log.debug("Unsetting the ServerConfigurationService");
    }
    UserStoreConfigComponent.serverConfigurationService = null;
}
 
public ServerConfigurationService getServerConfigurationService() {
    return serverConfigurationService;
}
 
public void setServerConfigurationService(ServerConfigurationService serverConfigurationService) {
    this.serverConfigurationService = serverConfigurationService;
}
 
源代码23 项目: carbon-identity   文件: OAuthUIServiceComponent.java
protected void setServerConfigurationService(ServerConfigurationService serverConfigService) {
    OAuthUIServiceComponentHolder.getInstance().setServerConfigurationService(serverConfigService);
    log.debug("ServerConfigurationService instance was set.");
}
 
源代码24 项目: carbon-identity   文件: OAuthUIServiceComponent.java
protected void unsetServerConfigurationService(ServerConfigurationService serverConfigService) {
    OAuthUIServiceComponentHolder.getInstance().setServerConfigurationService(null);
    log.debug("ServerConfigurationService instance was unset.");
}
 
源代码25 项目: carbon-identity   文件: UserStoreConfigComponent.java
public static ServerConfigurationService getServerConfigurationService() {
    return UserStoreConfigComponent.serverConfigurationService;
}
 
源代码26 项目: carbon-identity   文件: UserStoreConfigComponent.java
protected void unsetServerConfigurationService(ServerConfigurationService serverConfigurationService) {
    if (log.isDebugEnabled()) {
        log.debug("Unset the ServerConfiguration Service");
    }
    UserStoreConfigComponent.serverConfigurationService = null;
}
 
源代码27 项目: carbon-identity   文件: UserStoreConfigComponent.java
public static ServerConfigurationService getServerConfigurationService() {
    return UserStoreConfigComponent.serverConfigurationService;
}
 
源代码28 项目: carbon-identity   文件: UserStoreConfigComponent.java
protected void setServerConfigurationService(ServerConfigurationService serverConfigurationService) {
    if (log.isDebugEnabled()) {
        log.debug("Setting the serverConfigurationService");
    }
    UserStoreConfigComponent.serverConfigurationService = serverConfigurationService;
}
 
源代码29 项目: carbon-identity   文件: UserStoreConfigComponent.java
protected void unsetServerConfigurationService(ServerConfigurationService serverConfigurationService) {
    if (log.isDebugEnabled()) {
        log.debug("Unsetting the ServerConfigurationService");
    }
    UserStoreConfigComponent.serverConfigurationService = null;
}
 
public ServerConfigurationService getServerConfigurationService() {
    return serverConfigurationService;
}