• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java SecretResolverFactory类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



SecretResolverFactory类属于org.wso2.securevault包,在下文中一共展示了SecretResolverFactory类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: initConfigurationFromFile

import org.wso2.securevault.SecretResolverFactory; //导入依赖的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());
//        }
    }
 
开发者ID:wso2,项目名称:product-ei,代码行数:29,代码来源:BPMNAnalyticsCoreConfiguration.java


示例2: initConfigurationFromFile

import org.wso2.securevault.SecretResolverFactory; //导入依赖的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());
    }
}
 
开发者ID:wso2,项目名称:carbon-business-process,代码行数:25,代码来源:BPSAnalyticsConfiguration.java


示例3: resolveEncryptedProperties

import org.wso2.securevault.SecretResolverFactory; //导入依赖的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));
                }
            }
        }
    }
}
 
开发者ID:wso2,项目名称:andes,代码行数:22,代码来源:PropertiesFileInitialContextFactory.java


示例4: init

import org.wso2.securevault.SecretResolverFactory; //导入依赖的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();
	}
}
 
开发者ID:wso2,项目名称:carbon-governance,代码行数:28,代码来源:APIDeleteExecutor.java


示例5: init

import org.wso2.securevault.SecretResolverFactory; //导入依赖的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();
    }
}
 
开发者ID:wso2,项目名称:carbon-governance,代码行数:36,代码来源:APIDeleteExecutor.java


示例6: resolveSecrets

import org.wso2.securevault.SecretResolverFactory; //导入依赖的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");
        }
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:41,代码来源:TenantDataManager.java


示例7: resolveSecrets

import org.wso2.securevault.SecretResolverFactory; //导入依赖的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");
        }
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:33,代码来源:NotificationMgtConfigBuilder.java


示例8: resolveSecrets

import org.wso2.securevault.SecretResolverFactory; //导入依赖的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");
        }
    }
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:34,代码来源:IdentityManagementServiceUtil.java


示例9: resolveSecrets

import org.wso2.securevault.SecretResolverFactory; //导入依赖的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");
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:32,代码来源:TenantDataManager.java


示例10: loadFromSecureVault

import org.wso2.securevault.SecretResolverFactory; //导入依赖的package包/类
private static synchronized String loadFromSecureVault(String alias) {
    if (secretResolver == null) {
        secretResolver = SecretResolverFactory.create((OMElement) null, false);
        secretResolver.init(TasksDSComponent.getSecretCallbackHandlerService()
                .getSecretCallbackHandler());
    }
    return secretResolver.resolve(alias);
}
 
开发者ID:wso2,项目名称:carbon-commons,代码行数:9,代码来源:TaskUtils.java


示例11: resolveSecret

import org.wso2.securevault.SecretResolverFactory; //导入依赖的package包/类
public static String resolveSecret(final OMElement docElt, final OMElement elt) {
    // retrieve the value using secure vault
    SecretResolver secretResolver = SecretResolverFactory.create(docElt, false);

    String alias = elt.getAttributeValue(new QName(
            ALIAS_NAMESPACE, ALIAS_ATTRIBUTE, ALIAS_ATTRIBUTE_PREFIX));

    // retrieve the secured password
    if (secretResolver != null && secretResolver.isInitialized() &&
            secretResolver.isTokenProtected(alias)) {
        return secretResolver.resolve(alias);
    }
    return null;
}
 
开发者ID:apache,项目名称:stratos,代码行数:15,代码来源:AxiomXpathParserUtil.java


示例12: decryptConfigurationFromFile

import org.wso2.securevault.SecretResolverFactory; //导入依赖的package包/类
/**
 * Decrypt properties with secure vault and maintain on a separate hashmap for cross-reference.
 *
 * @param filePath File path to the configuration file in question
 * @throws FileNotFoundException
 * @throws JaxenException
 * @throws XMLStreamException
 */
private static void decryptConfigurationFromFile(String filePath) throws FileNotFoundException, JaxenException, XMLStreamException {

    cipherValueMap = new ConcurrentHashMap<String, String>();

    StAXOMBuilder stAXOMBuilder = new StAXOMBuilder(new FileInputStream(new File(filePath)));
    OMElement dom = stAXOMBuilder.getDocumentElement();

    //Initialize the SecretResolver providing the configuration element.
    SecretResolver secretResolver = SecretResolverFactory.create(dom, false);

    AXIOMXPath xpathExpression = new AXIOMXPath("//*[@*[local-name() = 'secretAlias']]");
    List nodeList = xpathExpression.selectNodes(dom);

    for (Object o : nodeList) {

        String secretAlias = ((OMElement) o).getAttributeValue(SECURE_VAULT_QNAME);
        String decryptedValue = "";

        if (secretResolver != null && secretResolver.isInitialized()) {
            if (secretResolver.isTokenProtected(secretAlias)) {
                decryptedValue = secretResolver.resolve(secretAlias);
            }
        } else {
            log.warn("Error while trying to decipher secure property with secretAlias : " + secretAlias);
        }

        cipherValueMap.put(secretAlias, decryptedValue);
    }

}
 
开发者ID:wso2,项目名称:andes,代码行数:39,代码来源:AndesConfigurationManager.java


示例13: init

import org.wso2.securevault.SecretResolverFactory; //导入依赖的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();
	}
	if (parameterMap.get(ExecutorConstants.DEFAULT_TIER) != null) {
		defaultTier = parameterMap.get(ExecutorConstants.DEFAULT_TIER).toString();
	}
	if (parameterMap.get(ExecutorConstants.THROTTLING_TIER) != null) {
		apiThrottlingTier = parameterMap.get(ExecutorConstants.THROTTLING_TIER).toString();
	}
}
 
开发者ID:wso2,项目名称:carbon-governance,代码行数:35,代码来源:APIPublishExecutor.java


示例14: init

import org.wso2.securevault.SecretResolverFactory; //导入依赖的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.
 */
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 != null && secretResolver.isInitialized()) {
        apimUsername = secretResolver.resolve("apim.username");
    }
    if (secretResolver != null && secretResolver.isInitialized()) {
        apimPassword = secretResolver.resolve("apim.password");
    }

    this.parameterMap = parameterMap;
    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();
    }
    if (parameterMap.get(DEFAULT_TIER) != null) {
        defaultTier = parameterMap.get(DEFAULT_TIER).toString();
    }
    if (parameterMap.get(THROTTLING_TIER) != null) {
        apiThrottlingTier = parameterMap.get(THROTTLING_TIER).toString();
    }
    if (parameterMap.get(Constants.APIM_ENV) != null) {
        apimEnv = parameterMap.get(Constants.APIM_ENV).toString();
    }
}
 
开发者ID:wso2,项目名称:carbon-governance,代码行数:42,代码来源:RestServiceToAPIExecutor.java


示例15: init

import org.wso2.securevault.SecretResolverFactory; //导入依赖的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.
 */
@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();
    }
    if (parameterMap.get(Constants.APIM_ENV) != null) {
        apimEnv = parameterMap.get(Constants.APIM_ENV).toString();
    }
    if (parameterMap.get(DEFAULT_TIER) != null) {
        defaultTier = parameterMap.get(DEFAULT_TIER).toString();
    }
    if (parameterMap.get(THROTTLING_TIER) != null) {
        apiThrottlingTier = parameterMap.get(THROTTLING_TIER).toString();
    }

}
 
开发者ID:wso2,项目名称:carbon-governance,代码行数:39,代码来源:ServiceToAPIExecutor.java


示例16: init

import org.wso2.securevault.SecretResolverFactory; //导入依赖的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.
    */
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 != null && secretResolver.isInitialized()) {
        apimUsername = secretResolver.resolve("apim.username");
       }
       if (secretResolver != null && secretResolver.isInitialized()) {
        apimPassword = secretResolver.resolve("apim.password");
       }

       this.parameterMap = parameterMap;
	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();
	}
	if (parameterMap.get(DEFAULT_TIER) != null) {
		defaultTier = parameterMap.get(DEFAULT_TIER).toString();
	}
	if (parameterMap.get(THROTTLING_TIER) != null) {
		apiThrottlingTier = parameterMap.get(THROTTLING_TIER).toString();
	}
}
 
开发者ID:wso2,项目名称:carbon-governance,代码行数:39,代码来源:ApiStoreExecutor.java


示例17: init

import org.wso2.securevault.SecretResolverFactory; //导入依赖的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.
 */
@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();
	}
	if (parameterMap.get(Constants.APIM_ENV) != null) {
		apimEnv = parameterMap.get(Constants.APIM_ENV).toString();
	}
	if (parameterMap.get(DEFAULT_TIER) != null) {
		defaultTier = parameterMap.get(DEFAULT_TIER).toString();
	}
	if (parameterMap.get(THROTTLING_TIER) != null) {
		apiThrottlingTier = parameterMap.get(THROTTLING_TIER).toString();
	}
	if (parameterMap.get(APIM_PUBLISHER) != null) {
		apimPublisher = parameterMap.get(APIM_PUBLISHER).toString();
	}

}
 
开发者ID:wso2,项目名称:carbon-governance,代码行数:42,代码来源:ApiStore2Executor.java


示例18: loadFromSecureVault

import org.wso2.securevault.SecretResolverFactory; //导入依赖的package包/类
public static synchronized String loadFromSecureVault(String alias) {
	if (secretResolver == null) {
	    secretResolver = SecretResolverFactory.create((OMElement) null, false);
	    secretResolver.init(DataServicesDSComponent.
	    		getSecretCallbackHandlerService().getSecretCallbackHandler());
	}
	return secretResolver.resolve(alias);
}
 
开发者ID:wso2,项目名称:carbon-data,代码行数:9,代码来源:DBUtils.java


示例19: resolvePassword

import org.wso2.securevault.SecretResolverFactory; //导入依赖的package包/类
/**
 * Checks whether the password is configured from Secure Vault or not
 * Resolves the password or directly assigns the passwordInConfig
 *
 * @param passwordInConfig value of the <Password> element found in carbon.xml
 * @return final plain text password
 */
private String resolvePassword(String passwordInConfig) {
    // Plain password resolved/directly from carbon.xml
    String password;

    boolean secureVaultPassword = false;

    // Checking the <Password> element for the attribute "svns:secretAlias" to identify whether the
    // password is to be taken from Secure Vault or as plain text

    // nodeList contains all the nodes with the tag <Password>
    NodeList nodeList = serverConf.getDocumentElement().getElementsByTagName("Password");

    for (int i = 0; i < nodeList.getLength(); i++) {
        Node node = nodeList.item(i);
        // Find the node which has <ElasticObserver> as parent node
        if ("ElasticObserver".equals(node.getParentNode().getLocalName())) {
            // Take attributes map of the node and look into it for the defined secret alias
            NamedNodeMap attributeMap = node.getAttributes();
            for (int j = 0; j < attributeMap.getLength(); j++) {
                if ("svns:secretAlias".equals(attributeMap.item(j).getNodeName())
                        && ElasticObserverConstants.PASSWORD_ALIAS.equals(attributeMap.item(j).getNodeValue())) {
                    secureVaultPassword = true;
                    break;
                }
            }
        }
    }

    if (secureVaultPassword) {
        // Creates Secret Resolver from carbon.xml document element
        SecretResolver secretResolver = SecretResolverFactory.create(serverConf.getDocumentElement(),
                true);

        // Resolves password using the defined alias
        password = secretResolver.resolve(ElasticObserverConstants.PASSWORD_ALIAS);

        // If the alias is wrong and there is no password, resolver returns the alias string again
        if (ElasticObserverConstants.PASSWORD_ALIAS.equals(password)) {
            log.error("Wrong password alias in Secure Vault. Use alias: " +
                    ElasticObserverConstants.PASSWORD_ALIAS);
            password = null;
        } else {
            if (log.isDebugEnabled()) {
                log.debug("Password resolved from Secure Vault.");
            }
        }
    } else {
        // If not secure vault password take directly
        password = passwordInConfig;
        if (log.isDebugEnabled()) {
            log.debug("Password taken directly from carbon.xml");
        }
    }

    return password;
}
 
开发者ID:wso2,项目名称:product-ei,代码行数:64,代码来源:ElasticMediationFlowObserver.java


示例20: loadCredentials

import org.wso2.securevault.SecretResolverFactory; //导入依赖的package包/类
private static void loadCredentials(final String fileName, final OMElement elt, final IaasProvider iaas, final OMElement iaasElt,
                                    final String xpath) {

    Iterator<?> it =
            iaasElt.getChildrenWithName(new QName(
                    CloudControllerConstants.CREDENTIAL_ELEMENT));

    if (it.hasNext()) {
        OMElement credentialElt = (OMElement) it.next();

        // retrieve the value using secure vault
        SecretResolver secretResolver = SecretResolverFactory.create(elt, false);
        String alias = credentialElt.getAttributeValue(new QName(
                CloudControllerConstants.ALIAS_NAMESPACE,
                CloudControllerConstants.ALIAS_ATTRIBUTE,
                CloudControllerConstants.ALIAS_ATTRIBUTE_PREFIX));

        // retrieve the secured password
        if (secretResolver != null && secretResolver.isInitialized() &&
                secretResolver.isTokenProtected(alias)) {
            iaas.setCredential(secretResolver.resolve(alias));
        }

        // if we still cannot find a value, we try to assign the value which
        // is specified
        // in the element, if any
        if (iaas.getCredential() == null) {
            log.warn("Unable to find a value for " + CloudControllerConstants.CREDENTIAL_ELEMENT +
                    " element from Secure Vault." +
                    "Hence we will try to assign the plain text value (if specified).");
            iaas.setCredential(credentialElt.getText());
        }
    }

    if (it.hasNext()) {
        log.warn(fileName + " contains more than one " +
                CloudControllerConstants.CREDENTIAL_ELEMENT + " elements!" +
                " Elements other than the first will be neglected.");
    }

    if (iaas.getCredential() == null) {
        String msg =
                "Essential '" + CloudControllerConstants.CREDENTIAL_ELEMENT + "' element" +
                        " has not specified in " + fileName;
        handleException(msg);
    }

}
 
开发者ID:apache,项目名称:stratos,代码行数:49,代码来源:IaasProviderConfigParser.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SHA256类代码示例发布时间:2022-05-22
下一篇:
Java MaxLatticeDefault类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap