Package br.net.woodstock.rockframework.xml.dom

Examples of br.net.woodstock.rockframework.xml.dom.XmlElement


    SecretKey secretKey = SecurityUtils.getSecretKeyFromFile(data, KeyType.getKeyType(algorithm));
    return secretKey;
  }

  private void addCertificateElement(final XmlElement parent, final String alias, final Certificate certificate) throws CertificateEncodingException, UnsupportedEncodingException {
    XmlElement certificateElement = parent.addElement(XMLStore.CERTIFICATE_ELEMENT);
    certificateElement.setAttribute(XMLStore.ALIAS_ATTRIBUTE, alias);
    certificateElement.setAttribute(XMLStore.ALGORITHM_ATTRIBUTE, certificate.getType());

    this.setBase64Data(certificateElement, certificate.getEncoded());
  }
View Full Code Here


  }

  private void addPrivateKeyElement(final XmlElement parent, final String alias, final PrivateKeyHolder holder) throws CertificateEncodingException, UnsupportedEncodingException {
    PrivateKey privateKey = holder.getPrivateKey();
    Certificate[] chain = holder.getChain();
    XmlElement privateKeyElement = parent.addElement(XMLStore.PRIVATE_KEY_ELEMENT);
    XmlElement chainElement = privateKeyElement.addElement(XMLStore.CHAIN_ELEMENT);
    privateKeyElement.setAttribute(XMLStore.ALIAS_ATTRIBUTE, alias);
    privateKeyElement.setAttribute(XMLStore.ALGORITHM_ATTRIBUTE, privateKey.getAlgorithm());

    this.setBase64Data(privateKeyElement, privateKey.getEncoded());
View Full Code Here

      }
    }
  }

  private void addPublicKeyElement(final XmlElement parent, final String alias, final PublicKey publicKey) throws UnsupportedEncodingException {
    XmlElement publicKeyElement = parent.addElement(XMLStore.PUBLIC_KEY_ELEMENT);
    publicKeyElement.setAttribute(XMLStore.ALIAS_ATTRIBUTE, alias);
    publicKeyElement.setAttribute(XMLStore.ALGORITHM_ATTRIBUTE, publicKey.getAlgorithm());

    this.setBase64Data(publicKeyElement, publicKey.getEncoded());
  }
View Full Code Here

    this.setBase64Data(publicKeyElement, publicKey.getEncoded());
  }

  private void addSecretKeyElement(final XmlElement parent, final String alias, final SecretKey secretKey) throws UnsupportedEncodingException {
    XmlElement publicKeyElement = parent.addElement(XMLStore.SECRET_KEY_ELEMENT);
    publicKeyElement.setAttribute(XMLStore.ALIAS_ATTRIBUTE, alias);
    publicKeyElement.setAttribute(XMLStore.ALGORITHM_ATTRIBUTE, secretKey.getAlgorithm());

    this.setBase64Data(publicKeyElement, secretKey.getEncoded());
  }
View Full Code Here

    PrivateKey privateKey = SecurityUtils.getPrivateKeyFromPKCS8File(data, KeyPairType.getKeyPairType(algorithm));

    List<Certificate> chainList = new ArrayList<Certificate>();
    Certificate[] chain = null;
    XmlElement chainElement = e.getElement(XMLStore.CHAIN_ELEMENT);
    for (XmlElement certificateElement : chainElement.getElements()) {
      Certificate certificate = this.getCertificate(certificateElement, encoding);
      chainList.add(certificate);
    }

    if (chainList.size() > 0) {
View Full Code Here

    SecretKey secretKey = SecurityUtils.getSecretKeyFromFile(data, KeyType.getKeyType(algorithm));
    return secretKey;
  }

  private void addCertificateElement(final XmlElement parent, final String alias, final Certificate certificate) throws CertificateEncodingException, UnsupportedEncodingException {
    XmlElement certificateElement = parent.addElement(XMLStore.CERTIFICATE_ELEMENT);
    certificateElement.setAttribute(XMLStore.ALIAS_ATTRIBUTE, alias);
    certificateElement.setAttribute(XMLStore.ALGORITHM_ATTRIBUTE, certificate.getType());

    this.setBase64Data(certificateElement, certificate.getEncoded());
  }
View Full Code Here

  }

  private void addPrivateKeyElement(final XmlElement parent, final String alias, final PrivateKeyHolder holder) throws CertificateEncodingException, UnsupportedEncodingException {
    PrivateKey privateKey = holder.getPrivateKey();
    Certificate[] chain = holder.getChain();
    XmlElement privateKeyElement = parent.addElement(XMLStore.PRIVATE_KEY_ELEMENT);
    XmlElement chainElement = privateKeyElement.addElement(XMLStore.CHAIN_ELEMENT);
    privateKeyElement.setAttribute(XMLStore.ALIAS_ATTRIBUTE, alias);
    privateKeyElement.setAttribute(XMLStore.ALGORITHM_ATTRIBUTE, privateKey.getAlgorithm());

    this.setBase64Data(privateKeyElement, privateKey.getEncoded());
View Full Code Here

      }
    }
  }

  private void addPublicKeyElement(final XmlElement parent, final String alias, final PublicKey publicKey) throws UnsupportedEncodingException {
    XmlElement publicKeyElement = parent.addElement(XMLStore.PUBLIC_KEY_ELEMENT);
    publicKeyElement.setAttribute(XMLStore.ALIAS_ATTRIBUTE, alias);
    publicKeyElement.setAttribute(XMLStore.ALGORITHM_ATTRIBUTE, publicKey.getAlgorithm());

    this.setBase64Data(publicKeyElement, publicKey.getEncoded());
  }
View Full Code Here

    this.setBase64Data(publicKeyElement, publicKey.getEncoded());
  }

  private void addSecretKeyElement(final XmlElement parent, final String alias, final SecretKey secretKey) throws UnsupportedEncodingException {
    XmlElement publicKeyElement = parent.addElement(XMLStore.SECRET_KEY_ELEMENT);
    publicKeyElement.setAttribute(XMLStore.ALIAS_ATTRIBUTE, alias);
    publicKeyElement.setAttribute(XMLStore.ALGORITHM_ATTRIBUTE, secretKey.getAlgorithm());

    this.setBase64Data(publicKeyElement, secretKey.getEncoded());
  }
View Full Code Here

  @Override
  public void read(final InputStream inputStream, final String password) throws IOException {
    try {
      XmlDocument document = XmlDocument.read(inputStream);
      XmlElement root = document.getRoot();

      String encoding = root.getAttribute(XMLStore.ENCODING_ATTRIBUTE);

      XmlElement certificates = root.getElement(XMLStore.CERTIFICATES_ELEMENT);
      XmlElement privateKeys = root.getElement(XMLStore.PRIVATE_KEYS_ELEMENT);
      XmlElement publicKeys = root.getElement(XMLStore.PUBLIC_KEYS_ELEMENT);
      XmlElement secretKeys = root.getElement(XMLStore.SECRET_KEYS_ELEMENT);

      for (XmlElement certificateElement : certificates.getElements()) {
        String alias = certificateElement.getAttribute(XMLStore.ALIAS_ATTRIBUTE);
        Certificate certificate = this.getCertificate(certificateElement, encoding);
        this.getCertificateMap().put(alias, certificate);
      }

      for (XmlElement privateKeyElement : privateKeys.getElements()) {
        String alias = privateKeyElement.getAttribute(XMLStore.ALIAS_ATTRIBUTE);
        PrivateKeyHolder holder = this.getPrivateKey(privateKeyElement, encoding);
        this.getPrivateKeyMap().put(alias, holder);
      }

      for (XmlElement publicKeyElement : publicKeys.getElements()) {
        String alias = publicKeyElement.getAttribute(XMLStore.ALIAS_ATTRIBUTE);
        PublicKey publicKey = this.getPublicKey(publicKeyElement, encoding);
        this.getPublicKeyMap().put(alias, publicKey);
      }

      for (XmlElement secretKeyElement : secretKeys.getElements()) {
        String alias = secretKeyElement.getAttribute(XMLStore.ALIAS_ATTRIBUTE);
        SecretKey secretKey = this.getSecretKey(secretKeyElement, encoding);
        this.getSecretKeyMap().put(alias, secretKey);
      }
    } catch (GeneralSecurityException e) {
View Full Code Here

TOP

Related Classes of br.net.woodstock.rockframework.xml.dom.XmlElement

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.