Package org.wso2.securevault

Examples of org.wso2.securevault.SecretResolver


     
      /* add the password manager */
      Iterator<OMElement> passwordMngrItr = dbsElement.getChildrenWithName(
          new QName(SecurityConstants.PASSWORD_MANAGER_SIMPLE));
      if (passwordMngrItr.hasNext()) {
        SecretResolver secretResolver = SecretResolverFactory.create(dbsElement, false);
        dataService.setSecretResolver(secretResolver);
      }
         
      /* add the configs */
      for (Iterator<OMElement> itr = dbsElement.getChildrenWithName(
View Full Code Here


     * This method is just to resolve the Email sender and NIO SSL transport passwords.
     * @param transport   Implementations of ParameterInclude
     */
    private void resolveTransportPasswords(ParameterInclude transport) {

        SecretResolver secretResolver = axisConfig.getSecretResolver();
        if(secretResolver.isInitialized()){
            String keyStorePassToken = null;
            String keyStoreKeyPassToken = null;
            String trustStorePassToken = null;
            String emailSenderPassword = null;
            if (transport instanceof TransportOutDescription){
                keyStorePassToken = "Axis2.Https.Sender.KeyStore.Password";
                keyStoreKeyPassToken = "Axis2.Https.Sender.KeyStore.KeyPassword";
                trustStorePassToken = "Axis2.Https.Sender.TrustStore.Password";
                emailSenderPassword = "Axis2.Mailto.Parameter.Password";
            }
            if (transport instanceof TransportInDescription){
                keyStorePassToken = "Axis2.Https.Listener.KeyStore.Password";
                keyStoreKeyPassToken = "Axis2.Https.Listener.KeyStore.KeyPassword";
                trustStorePassToken = "Axis2.Https.Listener.TrustStore.Password";
            }

            Parameter keyParam    = transport.getParameter("keystore");
            Parameter trustParam  = transport.getParameter("truststore");
            Parameter emailPasswordParam  = transport.getParameter("mail.smtp.password");

            if (keyParam != null) {
                OMElement ksEle = keyParam.getParameterElement().getFirstElement();
                if(ksEle != null){
                    OMElement storePasswordElement = ksEle.getFirstChildWithName(new QName("Password"));
                    OMElement keyPasswordElement = ksEle.getFirstChildWithName(new QName("KeyPassword"));
                    if(secretResolver.isTokenProtected(keyStorePassToken) && storePasswordElement != null){
                        String storePassword = secretResolver.resolve(keyStorePassToken);
                        ksEle.getFirstChildWithName(new QName("Password")).setText(storePassword );

                    }
                    if(secretResolver.isTokenProtected(keyStoreKeyPassToken) && keyPasswordElement != null){
                        String keyPassword  = secretResolver.resolve(keyStoreKeyPassToken);
                        ksEle.getFirstChildWithName(new QName("KeyPassword")).setText(keyPassword);
                    }
                }
            }

            if (trustParam != null) {
                OMElement tsEle = trustParam.getParameterElement().getFirstElement();
                if(tsEle != null){
                    OMElement storePasswordElement = tsEle.getFirstChildWithName(new QName("Password"));
                    if(secretResolver.isTokenProtected(trustStorePassToken) && storePasswordElement != null){
                        String storePassword = secretResolver.resolve(trustStorePassToken);
                        tsEle.getFirstChildWithName(new QName("Password")).setText(storePassword );
                    }
                }
            }

            if(secretResolver.isTokenProtected(emailSenderPassword) && emailPasswordParam != null) {
                String emailPassword = secretResolver.resolve(emailSenderPassword);
                emailPasswordParam.setValue(emailPassword);
            }
        }
    }
View Full Code Here

   * @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;
    }
  }
View Full Code Here

      }
      if (documentElement != null) {
        Iterator<?> it = documentElement.getChildrenWithName(new QName(CartridgeConstants.SECURITY_KEY));
        if (it.hasNext()) {
          OMElement securityKeyElement = (OMElement) it.next();
          SecretResolver secretResolver = SecretResolverFactory.create(documentElement, false);
          String alias = securityKeyElement.getAttributeValue(new QName(CartridgeConstants.ALIAS_NAMESPACE,
              CartridgeConstants.ALIAS_LOCALPART, CartridgeConstants.ALIAS_PREFIX));

          if (secretResolver != null && secretResolver.isInitialized()
              && secretResolver.isTokenProtected(alias)) {
            securityKey = "";
            securityKey = secretResolver.resolve(alias);
            // TODO : a proper testing on the secure vault protected
            // user defined encryption key
          }
        }
      }
View Full Code Here

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

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

      // 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
View Full Code Here

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

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

      // 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
View Full Code Here

             "Hence we will try to assign the plain text value (if specified).");
  }

  private String resolveSecret(final OMElement elt) {
    // retrieve the value using secure vault
    SecretResolver secretResolver = SecretResolverFactory.create(documentElement, false);

    String alias = elt.getAttributeValue(new QName(CloudControllerConstants.ALIAS_ATTRIBUTE));

    // retrieve the secured password
    if (secretResolver != null && secretResolver.isInitialized() &&
        secretResolver.isTokenProtected(alias)) {

      return secretResolver.resolve(alias);

    }

    return null;
  }
View Full Code Here

        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_ATTRIBUTE));

            // 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
View Full Code Here

        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_ATTRIBUTE));

            // 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
View Full Code Here

        validator.validate(new DOMSource(sourceElement));
    }

    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(CloudControllerConstants.ALIAS_ATTRIBUTE));

        // retrieve the secured password
        if (secretResolver != null && secretResolver.isInitialized() &&
            secretResolver.isTokenProtected(alias)) {

            return secretResolver.resolve(alias);

        }

        return null;
    }
View Full Code Here

TOP

Related Classes of org.wso2.securevault.SecretResolver

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.