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


Java SecretResolver.isTokenProtected方法代码示例

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


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

示例1: 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));
                }
            }
        }
    }
}
 
开发者ID:wso2,项目名称:andes,代码行数:22,代码来源:PropertiesFileInitialContextFactory.java

示例2: 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");
        }
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:41,代码来源:TenantDataManager.java

示例3: 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");
        }
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:33,代码来源:NotificationMgtConfigBuilder.java

示例4: 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");
        }
    }
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:34,代码来源:IdentityManagementServiceUtil.java

示例5: 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();
            }
        }
    }
}
 
开发者ID:wso2,项目名称:product-ei,代码行数:35,代码来源:BPMNAnalyticsCoreConfiguration.java

示例6: 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");
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:32,代码来源:TenantDataManager.java

示例7: 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();
        }
    }

}
 
开发者ID:wso2,项目名称:carbon-business-process,代码行数:33,代码来源:BPSAnalyticsConfiguration.java

示例8: 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;
    }
}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:14,代码来源:CommonUtil.java

示例9: RabbitMQConnectionFactory

import org.wso2.securevault.SecretResolver; //导入方法依赖的package包/类
/**
 * Digest a AMQP CF definition from an axis2.xml 'Parameter' and construct
 *
 * @param parameter the axis2.xml 'Parameter' that defined the AMQP CF
 */
public RabbitMQConnectionFactory(Parameter parameter, SecretResolver secretResolver) {
    this.name = parameter.getName();
    ParameterIncludeImpl pi = new ParameterIncludeImpl();

    try {
        pi.deserializeParameters((OMElement) parameter.getValue());
    } catch (AxisFault axisFault) {
        handleException("Error reading parameters for RabbitMQ connection factory" + name, axisFault);
    }

    for (Parameter p : pi.getParameters()) {
        OMElement paramElement = p.getParameterElement();
        String propertyValue = p.getValue().toString();
        if (paramElement != null) {
            OMAttribute attribute = paramElement.getAttribute(
                    new QName(RabbitMQConstants.SECURE_VAULT_NAMESPACE, RabbitMQConstants.SECRET_ALIAS_ATTRIBUTE));
            if (attribute != null && attribute.getAttributeValue() != null
                && !attribute.getAttributeValue().isEmpty()) {
                if (secretResolver == null) {
                    throw new SecureVaultException("Axis2 Secret Resolver is null. Cannot resolve encrypted entry for " + p.getName());
                }
                if (secretResolver.isTokenProtected(attribute.getAttributeValue())) {
                    propertyValue = secretResolver.resolve(attribute.getAttributeValue());
                }
            }
        }
        parameters.put(p.getName(), propertyValue);
    }
    initConnectionFactory();
    log.info("RabbitMQ ConnectionFactory : " + name + " initialized");
}
 
开发者ID:wso2,项目名称:wso2-axis2-transports,代码行数:37,代码来源:RabbitMQConnectionFactory.java

示例10: resolveSecret

import org.wso2.securevault.SecretResolver; //导入方法依赖的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

示例11: decryptConfigurationFromFile

import org.wso2.securevault.SecretResolver; //导入方法依赖的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

示例12: resolvePasswordValue

import org.wso2.securevault.SecretResolver; //导入方法依赖的package包/类
/**
 * Check the given password is encrypted or not, if its encrypted resolve the password.
 *
 * @param dataService Data service object
 * @param password    Password before resolving
 * @return Resolved password
 */
public static String resolvePasswordValue(DataService dataService, String password) {
    SecretResolver secretResolver = dataService.getSecretResolver();
    if (secretResolver != null && secretResolver.isTokenProtected(password)) {
        return secretResolver.resolve(password);
    } else {
        return password;
    }
}
 
开发者ID:wso2,项目名称:carbon-data,代码行数:16,代码来源:DBUtils.java

示例13: JMSConnectionFactory

import org.wso2.securevault.SecretResolver; //导入方法依赖的package包/类
/**
 * Digest a JMS CF definition from an axis2.xml 'Parameter' and construct.
 * @param parameter the axis2.xml 'Parameter' that defined the JMS CF
 * @param secretResolver the SecretResolver to use to resolve secrets such as passwords
 */
public JMSConnectionFactory(Parameter parameter, SecretResolver secretResolver) {
    this.name = parameter.getName();
    ParameterIncludeImpl pi = new ParameterIncludeImpl();

    try {
        pi.deserializeParameters((OMElement) parameter.getValue());
    } catch (AxisFault axisFault) {
        handleException("Error reading parameters for JMS connection factory" + name, axisFault);
    }

    for (Parameter param : pi.getParameters()) {
        OMElement paramElement = param.getParameterElement();
        String propertyValue = param.getValue().toString();
        if (paramElement != null) {
            OMAttribute attribute = paramElement.getAttribute(JMSConstants.ALIAS_QNAME);
            if (attribute != null && attribute.getAttributeValue() != null
                    && !attribute.getAttributeValue().isEmpty()) {
                if (secretResolver == null) {
                    throw new SecureVaultException("Axis2 Secret Resolver is null. "
                            + "Cannot resolve encrypted entry for " + param.getName());
                }
                if (secretResolver.isTokenProtected(attribute.getAttributeValue())) {
                    propertyValue = secretResolver.resolve(attribute.getAttributeValue());
                }
            }
        }
        parameters.put(param.getName(), propertyValue);
    }
    digestCacheLevel();
    try {
        context = new InitialContext(parameters);
        conFactory = JMSUtils.lookup(context, ConnectionFactory.class,
            parameters.get(JMSConstants.PARAM_CONFAC_JNDI_NAME));
        if (parameters.get(JMSConstants.PARAM_DESTINATION) != null) {
            sharedDestination = JMSUtils.lookup(context, Destination.class,
                parameters.get(JMSConstants.PARAM_DESTINATION));
        }
        log.info("JMS ConnectionFactory : " + name + " initialized");

    } catch (NamingException e) {
        throw new AxisJMSException("Cannot acquire JNDI context, JMS Connection factory : " +
            parameters.get(JMSConstants.PARAM_CONFAC_JNDI_NAME) + " or default destination : " +
            parameters.get(JMSConstants.PARAM_DESTINATION) +
            " for JMS CF : " + name + " using : " + JMSUtils.maskAxis2ConfigSensitiveParameters(parameters), e);
    }
    setMaxSharedJMSConnectionsCount();
}
 
开发者ID:wso2,项目名称:wso2-axis2-transports,代码行数:53,代码来源:JMSConnectionFactory.java

示例14: loadCredentials

import org.wso2.securevault.SecretResolver; //导入方法依赖的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

示例15: loadIdentity

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

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

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

            // retrieve the value using secure vault
            SecretResolver secretResolver = SecretResolverFactory.create(elt, false);
            String alias = identityElt.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.setIdentity(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.getIdentity() == null) {
                log.warn("Unable to find a value for " + CloudControllerConstants.IDENTITY_ELEMENT +
                        " element from Secure Vault." +
                        "Hence we will try to assign the plain text value (if specified).");
                iaas.setIdentity(identityElt.getText());
            }
        }

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

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

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


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