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

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


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


public abstract class AbstractULMenuTransformer implements MenuTransformer {

  @Override
  public String toText(final List<MenuItemBean> list) {
    XmlDocument document = new XmlDocument("ul");
    XmlElement root = document.getRoot();
    for (MenuItemBean bean : list) {
      XmlElement e = root.addElement("li");
      this.setElementData(e, bean);
      if ((bean.getChilds() != null) && (bean.getChilds().size() > 0)) {
        this.setChilds(e, bean.getChilds());
      }
    }
View Full Code Here

    String str = document.toString();
    return str.substring(str.indexOf('\n') + 1);
  }

  private void setChilds(final XmlElement parent, final List<MenuItemBean> list) {
    XmlElement ul = parent.addElement("ul");
    for (MenuItemBean bean : list) {
      XmlElement e = ul.addElement("li");
      this.setElementData(e, bean);
      if ((bean.getChilds() != null) && (bean.getChilds().size() > 0)) {
        this.setChilds(e, bean.getChilds());
      }
    }
View Full Code Here

public class SimpleULMenuTransformer extends AbstractULMenuTransformer {

  @Override
  protected void setElementData(final XmlElement parent, final MenuItemBean bean) {
    XmlElement e = parent.addElement("a");
    e.setData(bean.getName());
    if (ConditionUtils.isNotEmpty(bean.getUrl())) {
      e.setAttribute("href", bean.getUrl());
    }
  }
View Full Code Here

    }

    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

    }

    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

  @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);
        Identity 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

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

    PrivateKey privateKey = KeyUtils.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 = KeyUtils.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

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.