本文整理汇总了Java中org.wso2.securevault.SecretResolver类的典型用法代码示例。如果您正苦于以下问题:Java SecretResolver类的具体用法?Java SecretResolver怎么用?Java SecretResolver使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SecretResolver类属于org.wso2.securevault包,在下文中一共展示了SecretResolver类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initConfigurationFromFile
import org.wso2.securevault.SecretResolver; //导入依赖的package包/类
/**
* Initialize the configuration object from the properties in the BPS Analytics config xml file.
*/
private void initConfigurationFromFile(File BPMNAnalyticsCoreConfigurationFile) {
SecretResolver secretResolver = null;
try (InputStream in = new FileInputStream(BPMNAnalyticsCoreConfigurationFile)) {
StAXOMBuilder builder = new StAXOMBuilder(in);
secretResolver = SecretResolverFactory.create(builder.getDocumentElement(), true);
} catch (Exception e) {
log.warn("Error occurred while retrieving secured BPS Analytics configuration.", e);
}
TBPSAnalytics tBPSAnalytics = bpsAnalyticsDocument.getBPSAnalytics();
if (tBPSAnalytics == null) {
return;
}
if (tBPSAnalytics.getBPMN() != null) {
initBPMNAnalytics(tBPSAnalytics.getBPMN());
}
if (tBPSAnalytics.getAnalyticServer() != null) {
initAnalytics(secretResolver, tBPSAnalytics.getAnalyticServer());
}
// if (tBPSAnalytics.getAnalytics() != null) {
// initAnalytics(secretResolver, tBPSAnalytics.getAnalytics());
// }
}
示例2: initConfigurationFromFile
import org.wso2.securevault.SecretResolver; //导入依赖的package包/类
/**
* Initialize the configuration object from the properties in the BPS Analytics config xml file.
*/
private void initConfigurationFromFile(File BPSAnalyticsConfigurationFile) {
SecretResolver secretResolver = null;
try (InputStream in = new FileInputStream(BPSAnalyticsConfigurationFile);) {
StAXOMBuilder builder = new StAXOMBuilder(in);
secretResolver = SecretResolverFactory.create(builder.getDocumentElement(), true);
} catch (Exception e) {
log.warn("Error occurred while retrieving secured BPS Analytics configuration.", e);
}
TBPSAnalytics tBPSAnalytics = bpsAnalyticsDocument.getBPSAnalytics();
if (tBPSAnalytics == null) {
return;
}
if (tBPSAnalytics.getAnalyticServer() != null) {
initAnalytics(secretResolver, tBPSAnalytics.getAnalyticServer());
}
if (tBPSAnalytics.getBPMN() != null) {
initBPMNAnalytics(tBPSAnalytics.getBPMN());
}
}
示例3: testGetResolvedPassword
import org.wso2.securevault.SecretResolver; //导入依赖的package包/类
public void testGetResolvedPassword() throws Exception {
//Null Secret Resolver case
String pass = "admin";
String returnedPassword= CommonUtil.getResolvedPassword(null, null, pass);
assertEquals(pass, returnedPassword);
//Null config case
SecretResolver secretResolver = mock(SecretResolver.class);
when(secretResolver.isInitialized()).thenReturn(true);
returnedPassword= CommonUtil.getResolvedPassword(secretResolver, null, pass);
assertEquals(pass, returnedPassword);
//Null config case
String configName = "registry";
when(secretResolver.isTokenProtected("wso2registry." + configName + ".password")).thenReturn(true);
when(secretResolver.resolve("wso2registry." + configName + ".password")).thenReturn("mockpass");
returnedPassword= CommonUtil.getResolvedPassword(secretResolver, configName, pass);
assertEquals("mockpass", returnedPassword);
}
示例4: resolveEncryptedProperties
import org.wso2.securevault.SecretResolver; //导入依赖的package包/类
/**
* Resolve carbon secure vault encrypted properties.
* @param environment property values which need to construct the InitialContext
*/
private static void resolveEncryptedProperties(Hashtable environment) {
if (environment != null) {
Properties properties = convertToProperties(environment);
SecretResolver secretResolver = SecretResolverFactory.create(properties);
for (Object key : environment.keySet()) {
if (secretResolver != null && secretResolver.isInitialized()) {
String value = environment.get(key.toString()).toString();
if(value != null && value.startsWith(SECRET_ALIAS_PREFIX)) {
value = value.split(SECRET_ALIAS_PREFIX)[1];
}
if (secretResolver.isTokenProtected(value)) {
environment.put(key.toString(), secretResolver.resolve(value));
}
}
}
}
}
示例5: init
import org.wso2.securevault.SecretResolver; //导入依赖的package包/类
/**
* This method is called when the execution class is initialized.
* All the execution classes are initialized only once.
*
* @param parameterMap the parameters that have been given in the
* lifecycle configuration as the parameters of the executor.
*/
@Override
public void init(Map parameterMap) {
SecretResolver secretResolver = SecretResolverFactory.create((OMElement) null, false);
// Retrieves the secured password as follows
secretResolver.init(GovernanceRegistryExtensionsComponent.getSecretCallbackHandlerService()
.getSecretCallbackHandler());
if (secretResolver.isInitialized()) {
apimUsername = secretResolver.resolve(ExecutorConstants.APIM_USERNAME);
apimPassword = secretResolver.resolve(ExecutorConstants.APIM_PASSWORD);
}
if (parameterMap.get(ExecutorConstants.APIM_ENDPOINT) != null) {
apimEndpoint = parameterMap.get(ExecutorConstants.APIM_ENDPOINT).toString();
}
if (parameterMap.get(ExecutorConstants.APIM_USERNAME) != null) {
apimUsername = parameterMap.get(ExecutorConstants.APIM_USERNAME).toString();
}
if (parameterMap.get(ExecutorConstants.APIM_PASSWORD) != null) {
apimPassword = parameterMap.get(ExecutorConstants.APIM_PASSWORD).toString();
}
}
示例6: init
import org.wso2.securevault.SecretResolver; //导入依赖的package包/类
/**
* This method is called when the execution class is initialized. All the execution classes are initialized only
* once.
*
* @param parameterMap Static parameter map given by the user. These are the parameters that have been given in the
* lifecycle configuration as the parameters of the executor.
* <p>
* Eg:- <execution forEvent="Promote" class="org.wso2.carbon.governance.registry.extensions
* .executors.ServiceVersionExecutor"> <parameter name="currentEnvironment"
* value="/_system/governance/trunk/"/> <parameter name="targetEnvironment"
* value="/_system/governance/branches/testing/"/> <parameter name="service.mediatype"
* value="application/vnd.wso2-service+xml"/> </execution>
* <p>
* The parameters defined here are passed to the executor using this method.
*/
@Override
public void init(Map parameterMap) {
SecretResolver secretResolver = SecretResolverFactory.create((OMElement) null, false);
// Retrieves the secured password as follows
secretResolver.init(GovernanceRegistryExtensionsComponent.getSecretCallbackHandlerService()
.getSecretCallbackHandler());
if (secretResolver.isInitialized()) {
apimUsername = secretResolver.resolve(APIM_USERNAME);
apimPassword = secretResolver.resolve(APIM_PASSWORD);
}
if (parameterMap.get(APIM_ENDPOINT) != null) {
apimEndpoint = parameterMap.get(APIM_ENDPOINT).toString();
}
if (parameterMap.get(APIM_USERNAME) != null) {
apimUsername = parameterMap.get(APIM_USERNAME).toString();
}
if (parameterMap.get(APIM_PASSWORD) != null) {
apimPassword = parameterMap.get(APIM_PASSWORD).toString();
}
}
示例7: resolveSecrets
import org.wso2.securevault.SecretResolver; //导入依赖的package包/类
/**
* There can be sensitive information like passwords in configuration file. If they are encrypted using secure
* vault, this method will resolve them and replace with original values.
*/
private static void resolveSecrets(Properties properties) {
String protectedTokens = (String) properties.get(PROTECTED_TOKENS);
if (StringUtils.isNotBlank(protectedTokens)) {
String secretProvider = (String) properties.get(SECRET_PROVIDER);
SecretResolver secretResolver;
if (StringUtils.isBlank(secretProvider)) {
properties.put(SECRET_PROVIDER, DEFAULT_CALLBACK_HANDLER);
}
secretResolver = SecretResolverFactory.create(properties, "");
StringTokenizer st = new StringTokenizer(protectedTokens, ",");
while (st.hasMoreElements()) {
String element = st.nextElement().toString().trim();
if (secretResolver.isTokenProtected(element)) {
if (log.isDebugEnabled()) {
log.debug("Resolving and replacing secret for " + element);
}
// Replaces the original encrypted property with resolved property
properties.put(element, secretResolver.resolve(element));
} else {
if (log.isDebugEnabled()) {
log.debug("No encryption done for value with key :" + element);
}
}
}
} else {
if (log.isDebugEnabled()) {
log.debug("Secure vault encryption ignored since no protected tokens available");
}
}
}
示例8: resolveSecrets
import org.wso2.securevault.SecretResolver; //导入依赖的package包/类
/**
* There can be sensitive information like passwords in configuration file. If they are encrypted using secure
* vault, this method will resolve them and replace with original values.
*/
private void resolveSecrets() {
SecretResolver secretResolver = SecretResolverFactory.create(notificationMgtConfigProperties);
Enumeration propertyNames = notificationMgtConfigProperties.propertyNames();
if (secretResolver != null && secretResolver.isInitialized()) {
// Iterate through whole config file and find encrypted properties and resolve them
while (propertyNames.hasMoreElements()) {
String key = (String) propertyNames.nextElement();
if (secretResolver.isTokenProtected(key)) {
if (log.isDebugEnabled()) {
log.debug("Resolving and replacing secret for " + key);
}
// Resolving the secret password.
String value = secretResolver.resolve(key);
// Replaces the original encrypted property with resolved property
notificationMgtConfigProperties.put(key, value);
} else {
if (log.isDebugEnabled()) {
log.debug("No encryption done for value with key :" + key);
}
}
}
} else {
if(log.isDebugEnabled()){
log.debug("Secret Resolver is not present. Will not resolve encryptions in config file");
}
}
}
示例9: resolveSecrets
import org.wso2.securevault.SecretResolver; //导入依赖的package包/类
private static void resolveSecrets(Properties properties) {
SecretResolver secretResolver = SecretResolverFactory.create(properties);
Enumeration propertyNames = properties.propertyNames();
if (secretResolver != null && secretResolver.isInitialized()) {
// Iterate through config file, find encrypted properties and resolve them
while (propertyNames.hasMoreElements()) {
String key = (String) propertyNames.nextElement();
if (StringUtils
.startsWith(properties.getProperty(key), IdentityManagementEndpointConstants.SECRET_ALIAS)) {
String secretAlias = properties.getProperty(key)
.split(IdentityManagementEndpointConstants.SECRET_ALIAS_SEPARATOR,
2)[1];
if (secretResolver.isTokenProtected(secretAlias)) {
if (log.isDebugEnabled()) {
log.debug("Resolving and replacing secret for " + secretAlias);
}
// Resolving the secret password.
String value = secretResolver.resolve(secretAlias);
// Replaces the original encrypted property with resolved property
properties.put(key, value);
} else {
if (log.isDebugEnabled()) {
log.debug("No encryption done for value with key :" + key);
}
}
}
}
} else {
log.warn("Secret Resolver is not present. Failed to resolve encryption in " +
IdentityManagementEndpointConstants.SERVICE_CONFIG_FILE_NAME + " file");
}
}
示例10: initAnalytics
import org.wso2.securevault.SecretResolver; //导入依赖的package包/类
/**
* Initialize analytics common configurations
*
* @param secretResolver
* @param tAnalyticServer
*/
private void initAnalytics(SecretResolver secretResolver, TAnalyticServer tAnalyticServer) {
// Get Enabled
//this.analyticsEnabled = tAnalyticServer.getEnabled();
if (this.isAnalyticsDashboardEnabled()) {
// Get URL
if (tAnalyticServer.getDASServerUrl().endsWith("/")) {
this.analyticsServerURL = tAnalyticServer.getDASServerUrl().substring(0, tAnalyticServer.getDASServerUrl()
.length() - 1);
} else {
this.analyticsServerURL = tAnalyticServer.getDASServerUrl();
}
// Get Username
this.analyticsServerUsername = tAnalyticServer.getUsername();
// Get Password
if (secretResolver != null && secretResolver.isInitialized()
&& secretResolver.isTokenProtected(BPMNAnalyticsCoreConstants.ANALYTICS_SERVER_PASSWORD_SECRET_ALIAS)) {
this.analyticsServerPassword = secretResolver.resolve(BPMNAnalyticsCoreConstants
.ANALYTICS_SERVER_PASSWORD_SECRET_ALIAS);
if (log.isDebugEnabled()) {
log.debug("Loaded analytics password from secure vault");
}
} else {
if (tAnalyticServer.getPassword() != null) {
this.analyticsServerPassword = tAnalyticServer.getPassword();
}
}
}
}
示例11: resolveSecrets
import org.wso2.securevault.SecretResolver; //导入依赖的package包/类
/**
* There can be sensitive information like passwords in configuration file. If they are encrypted using secure
* vault, this method will resolve them and replace with original values.
*/
private static void resolveSecrets(Properties properties) {
SecretResolver secretResolver = SecretResolverFactory.create(properties);
Enumeration propertyNames = properties.propertyNames();
if (secretResolver != null && secretResolver.isInitialized()) {
// Iterate through whole config file and find encrypted properties and resolve them
while (propertyNames.hasMoreElements()) {
String key = (String) propertyNames.nextElement();
if (secretResolver.isTokenProtected(key)) {
if (log.isDebugEnabled()) {
log.debug("Resolving and replacing secret for " + key);
}
// Resolving the secret password.
String value = secretResolver.resolve(key);
// Replaces the original encrypted property with resolved property
properties.put(key, value);
} else {
if (log.isDebugEnabled()) {
log.debug("No encryption done for value with key :" + key);
}
}
}
} else {
log.warn("Secret Resolver is not present. Will not resolve encryptions in " + Constants.TenantConstants
.CONFIG_RELATIVE_PATH + " file");
}
}
示例12: initAnalytics
import org.wso2.securevault.SecretResolver; //导入依赖的package包/类
/**
* Initialize analytics common configurations
*
* @param tAnalyticServer
* @param secretResolver
*/
private void initAnalytics(SecretResolver secretResolver, TAnalyticServer tAnalyticServer) {
// Get Auth URL Set
this.analyticsAuthURLSet = tAnalyticServer.getAuthURLSet();
// Get Receiver URL Set
this.analyticsReceiverURLSet = tAnalyticServer.getReceiverURLSet();
// Get Username
this.analyticsServerUsername = tAnalyticServer.getUsername();
// Get Password
if (secretResolver != null && secretResolver.isInitialized()
&& secretResolver.isTokenProtected(AnalyticsPublisherConstants
.BPS_BPMN_ANALYTICS_SERVER_PASSWORD_SECRET_ALIAS)) {
this.analyticsServerPassword = secretResolver.resolve(AnalyticsPublisherConstants
.BPS_BPMN_ANALYTICS_SERVER_PASSWORD_SECRET_ALIAS);
if (log.isDebugEnabled()) {
log.debug("Loaded analytics password from secure vault");
}
} else {
if (tAnalyticServer.getPassword() != null) {
this.analyticsServerPassword = tAnalyticServer.getPassword();
}
}
}
示例13: getResolvedPassword
import org.wso2.securevault.SecretResolver; //导入依赖的package包/类
public static String getResolvedPassword(SecretResolver secretResolver,
String configName, String password) {
if (secretResolver != null && secretResolver.isInitialized()) {
if (secretResolver.isTokenProtected("wso2registry." + configName + ".password")) {
return secretResolver.resolve("wso2registry." + configName + ".password");
} else {
return password;
}
} else {
return password;
}
}
示例14: doInit
import org.wso2.securevault.SecretResolver; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected void doInit() throws AxisFault {
SecretResolver secretResolver = getConfigurationContext().getAxisConfiguration().getSecretResolver();
connFacManager = new JMSConnectionFactoryManager(getTransportInDescription(), secretResolver);
log.info("JMS Transport Receiver/Listener initialized...");
}
示例15: loadConnectionFactoryDefinitions
import org.wso2.securevault.SecretResolver; //导入依赖的package包/类
/**
* Create JMSConnectionFactory instances for the definitions in the transport configuration,
* and add these into our collection of connectionFactories map keyed by name.
*
* @param trpDesc the transport description for JMS
* @param secretResolver the SecretResolver to use to resolve secrets such as passwords
*/
private void loadConnectionFactoryDefinitions(ParameterInclude trpDesc, SecretResolver secretResolver) {
for (Parameter parameter : trpDesc.getParameters()) {
try {
JMSConnectionFactory jmsConFactory = new JMSConnectionFactory(parameter, secretResolver);
connectionFactories.put(jmsConFactory.getName(), jmsConFactory);
} catch (AxisJMSException e) {
log.error("Error setting up connection factory : " + parameter.getName(), e);
}
}
}