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

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


      WebLog.getInstance().getLog().info("Class " + clazz.getCanonicalName() + " is not not a child of " + JspTag.class.getCanonicalName());
    }

    Tag tag = clazz.getAnnotation(Tag.class);

    XmlDocument document = new XmlDocument("tag");
    XmlElement root = document.getRoot();

    if (ConditionUtils.isNotEmpty(tag.description())) {
      root.addElement("description").setData(tag.description());
    }

    root.addElement("name").setData(tag.name());
    root.addElement("tag-class").setData(clazz.getCanonicalName());
    root.addElement("body-content").setData(tag.content());

    if (tag.dynamicAttributes()) {
      root.addElement("dynamic-attributes").setData(Boolean.valueOf(tag.dynamicAttributes()));
    }

    BeanDescriptor beanDescriptor = new BeanDescriptorBuilder(clazz).getBeanDescriptor();

    for (PropertyDescriptor propertyDescriptor : beanDescriptor.getProperties()) {
      if (!propertyDescriptor.isAnnotationPresent(Attribute.class)) {
        continue;
      }

      Attribute tldAttribute = propertyDescriptor.getAnnotation(Attribute.class);
      XmlElement e = root.addElement("attribute");

      if (ConditionUtils.isNotEmpty(tldAttribute.description())) {
        e.addElement("description").setData(tldAttribute.description());
      }

      e.addElement("name").setData(propertyDescriptor.getName());
      e.addElement("required").setData(Boolean.valueOf(tldAttribute.required()));
      e.addElement("rtexprvalue").setData(Boolean.valueOf(tldAttribute.rtexprvalue()));
      if ((!tldAttribute.rtexprvalue()) && (tldAttribute.type() != String.class)) {
        e.addElement("type").setData(tldAttribute.type().getCanonicalName());
      }
    }

    return document.toString();
  }
View Full Code Here


    return this.toXML(bytes);
  }

  private String toXML(final byte[] bytes) throws IOException {
    try {
      XmlDocument document = XmlDocument.read(new ByteArrayInputStream(bytes));
      String xml = document.toString();
      return xml;
    } catch (SAXException e) {
      throw new ExecutionException(e);
    }
  }
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);
View Full Code Here

  }

  @Override
  public void write(final OutputStream outputStream, final String password) throws IOException {
    try {
      XmlDocument document = new XmlDocument(XMLStore.STORE_ELEMENT);

      XmlElement root = document.getRoot();
      root.setAttribute(XMLStore.ENCODING_ATTRIBUTE, XMLStore.ENCODING);

      XmlElement certificates = root.addElement(XMLStore.CERTIFICATES_ELEMENT);
      XmlElement privateKeys = root.addElement(XMLStore.PRIVATE_KEYS_ELEMENT);
      XmlElement publicKeys = root.addElement(XMLStore.PUBLIC_KEYS_ELEMENT);
      XmlElement secretKeys = root.addElement(XMLStore.SECRET_KEYS_ELEMENT);
      for (Entry<String, Certificate> entry : this.getCertificateMap().entrySet()) {
        String alias = entry.getKey();
        Certificate certificate = entry.getValue();
        this.addCertificateElement(certificates, alias, certificate);
      }
      for (Entry<String, Identity> entry : this.getPrivateKeyMap().entrySet()) {
        String alias = entry.getKey();
        Identity identity = entry.getValue();
        this.addPrivateKeyElement(privateKeys, alias, identity);
      }
      for (Entry<String, PublicKey> entry : this.getPublicKeyMap().entrySet()) {
        String alias = entry.getKey();
        PublicKey publicKey = entry.getValue();
        this.addPublicKeyElement(publicKeys, alias, publicKey);
      }
      for (Entry<String, SecretKey> entry : this.getSecretKeyMap().entrySet()) {
        String alias = entry.getKey();
        SecretKey secretKey = entry.getValue();
        this.addSecretKeyElement(secretKeys, alias, secretKey);
      }
      document.write(outputStream);
    } catch (GeneralSecurityException e) {
      throw new StoreException(e);
    }
  }
View Full Code Here

    this.baseName = baseName;
  }

  public XmlDocument toXML() {
    ClassFinder classFinder = new ClassFinderImpl(this.baseName, new AnnotationClassFilter(Entity.class));
    XmlDocument document = new XmlDocument(AnnotationToXML.XML_NAMESPACE, AnnotationToXML.XML_LOCATION, AnnotationToXML.XML_ROOT);
    XmlElement entityMappings = document.getRoot();

    for (Class<?> clazz : classFinder.getClasses()) {
      XmlElement entity = entityMappings.addElement("entity");
      entity.setAttribute("class", clazz.getCanonicalName());
      entity.setAttribute("access", "PROPERTY");
View Full Code Here

  public void write(final SyncCrypter crypter, final OutputStream outputStream) {
    Assert.notNull(crypter, "crypter");
    Assert.notNull(outputStream, "outputStream");
    try {
      SecretKey key = crypter.getSecretKey();
      XmlDocument document = new XmlDocument(CrypterIOHelper.SYNC_CRYPTER_ELEMENT);
      XmlElement root = document.getRoot();
      root.addElement(CrypterIOHelper.KEY_ALGORITHM_ELEMENT).setData(crypter.getAlgorithm());
      CrypterIOHelper.addKey(root, CrypterIOHelper.SECRET_KEY_ELEMENT, key);
      document.write(outputStream);
    } catch (IOException e) {
      throw new CrypterException(e);
    }
  }
View Full Code Here

  @Override
  public AsyncCrypter read(final InputStream inputStream) {
    Assert.notNull(inputStream, "inputStream");
    try {
      XmlDocument document = XmlDocument.read(inputStream);
      XmlElement root = document.getRoot();
      String algorithm = CrypterIOHelper.getElementData(root, CrypterIOHelper.KEY_ALGORITHM_ELEMENT);

      KeyFactory factory = KeyFactory.getInstance(algorithm);
      PrivateKey privateKey = null;
      PublicKey publicKey = null;
View Full Code Here

  @Override
  public SyncCrypter read(final InputStream inputStream) {
    Assert.notNull(inputStream, "inputStream");
    try {
      XmlDocument document = XmlDocument.read(inputStream);
      XmlElement root = document.getRoot();
      String algorithm = CrypterIOHelper.getElementData(root, CrypterIOHelper.KEY_ALGORITHM_ELEMENT);
      byte[] bytes = CrypterIOHelper.getKey(root, CrypterIOHelper.SECRET_KEY_ELEMENT);

      SecretKeySpec keySpec = new SecretKeySpec(bytes, algorithm);
      SyncCrypter crypter = new SyncCrypter(keySpec);
View Full Code Here

    Assert.notNull(outputStream, "outputStream");
    try {
      PrivateKey privateKey = crypter.getPrivateKey();
      PublicKey publicKey = crypter.getPublicKey();

      XmlDocument document = new XmlDocument(CrypterIOHelper.ASYNC_CRYPTER_ELEMENT);
      XmlElement root = document.getRoot();
      root.addElement(CrypterIOHelper.KEY_ALGORITHM_ELEMENT).setData(crypter.getAlgorithm());

      if (privateKey != null) {
        CrypterIOHelper.addKey(root, CrypterIOHelper.PRIVATE_KEY_ELEMENT, privateKey);
      } else {
        SecurityLog.getInstance().getLogger().info("Private key is null and not will be writed");
      }
      if (publicKey != null) {
        CrypterIOHelper.addKey(root, CrypterIOHelper.PUBLIC_KEY_ELEMENT, publicKey);
      } else {
        SecurityLog.getInstance().getLogger().info("Public key is null and not will be writed");
      }
      document.write(outputStream);
    } catch (IOException e) {
      throw new CrypterException(e);
    }
  }
View Full Code Here

TOP

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

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.