Package org.apache.tomcat.util

Examples of org.apache.tomcat.util.XMLTree


      throw new Exception(msg);
  }
    }

    private void processIcon() {
        XMLTree iconTree = this.config.getFirstElement(Constants.ICON);

  if (iconTree != null) {
      // there is icon information

      XMLTree smallIconTree =
          iconTree.getFirstElement(Constants.SMALL_ICON);

      if (smallIconTree != null) {
          this.webApplicationDescriptor.setSmallIconUri(
        smallIconTree.getValue());
      }
     
      XMLTree largeIconTree =
          iconTree.getFirstElement(Constants.LARGE_ICON);

      if (largeIconTree != null) {
          webApplicationDescriptor.setLargeIconUri(
        largeIconTree.getValue());
      }
  }
    }
View Full Code Here


  reset();

  // Parse the input stream into an XMLTree
  XMLParser parser = new XMLParser();
  XMLTree config = parser.process(stream);
  if (!config.getName().equals(Constants.Element.TOMCAT_USERS))
      return;
  Enumeration e;

  // Process the defined users
  e = config.getElements(Constants.Element.USER).elements();
  while (e.hasMoreElements())
      readUser((XMLTree) e.nextElement());

  // Process the defined groups
  e = config.getElements(Constants.Element.GROUP).elements();
  while (e.hasMoreElements())
      readGroup((XMLTree) e.nextElement());

  // Process the defined roles
  e = config.getElements(Constants.Element.ROLE).elements();
  while (e.hasMoreElements())
      readRole((XMLTree) e.nextElement());

    }
View Full Code Here

      }
  }
    }

    private void processDisplayName() {
        XMLTree displayNameTree =
      this.config.getFirstElement(Constants.DISPLAY_NAME);

  if (displayNameTree != null) {
      this.webApplicationDescriptor.setName(
          displayNameTree.getValue());
  }
    }
View Full Code Here

  // Process the associated group memberships
  Enumeration e =
      element.getElements(Constants.Element.USER_MEMBER).elements();
  while (e.hasMoreElements()) {
      XMLTree um = (XMLTree) e.nextElement();
      String username =
    (String) um.getAttribute(Constants.Attribute.NAME);
      FileRealmUser user = getUser(username);
      if (user != null)
    user.addGroup(group);
  }
View Full Code Here

          displayNameTree.getValue());
  }
    }

    private void processDescription() {
        XMLTree descriptionTree =
      this.config.getFirstElement(Constants.DESCRIPTION);

  if (descriptionTree != null) {
      this.webApplicationDescriptor.setDescription(
          descriptionTree.getValue());
  }
    }
View Full Code Here

  Enumeration e = null;

  // Process the associated group memberships
  e = element.getElements(Constants.Element.GROUP_MEMBER).elements();
  while (e.hasMoreElements()) {
      XMLTree gm = (XMLTree) e.nextElement();
      String groupname =
    (String) gm.getAttribute(Constants.Attribute.NAME);
      FileRealmGroup group = getGroup(groupname);
      if (group != null)
    group.addRole(role);
  }

  // Process the associated user memberships
  e = element.getElements(Constants.Element.USER_MEMBER).elements();
  while (e.hasMoreElements()) {
      XMLTree um = (XMLTree) e.nextElement();
      String username =
    (String) um.getAttribute(Constants.Attribute.NAME);
      FileRealmUser user = getUser(username);
      if (user != null)
    user.addRole(role);
  }
View Full Code Here

   }
    }
   
    private void processSecurityConstraints() {
  for (Enumeration e = this.config.elements(Constants.SECURITY_CONSTRAINT); e.hasMoreElements();) {
      XMLTree scTree = (XMLTree) e.nextElement();
      SecurityConstraint sc = (SecurityConstraint) this.factory.createDescriptor(SecurityConstraint.class);
      for (Enumeration ee = scTree.elements(Constants.WEB_RESOURCE_COLLECTION); ee.hasMoreElements();) {
    XMLTree wrcTree = (XMLTree) ee.nextElement();
    WebResourceCollection wrc = (WebResourceCollection) this.factory.createDescriptor(WebResourceCollection.class);
    wrc.setName(wrcTree.getFirstElement(Constants.WEB_RESOURCE_NAME).getValue());
    if (wrcTree.getFirstElement(Constants.DESCRIPTION) != null) {
        wrc.setDescription(wrcTree.getFirstElement(Constants.DESCRIPTION).getValue());
    }
    for (Enumeration eee = wrcTree.elements(Constants.URL_PATTERN); eee.hasMoreElements();) {
        XMLTree upTree = (XMLTree) eee.nextElement();
        wrc.addUrlPattern(upTree.getValue());
    }
    for (Enumeration eee = wrcTree.elements(Constants.HTTP_METHOD); eee.hasMoreElements();) {
        XMLTree hmTree = (XMLTree) eee.nextElement();
        wrc.addHttpMethod(hmTree.getValue());
    }
    sc.addWebResourceCollection(wrc);
      }
      XMLTree acTree = scTree.getFirstElement(Constants.AUTH_CONSTRAINT);
      if (acTree != null) {
    AuthorizationConstraint ac = (AuthorizationConstraint) this.factory.createDescriptor(AuthorizationConstraint.class);
    if (acTree.getFirstElement(Constants.DESCRIPTION) != null) {
        ac.setDescription(acTree.getFirstElement(Constants.DESCRIPTION).getValue());
        for (Enumeration eeee = acTree.elements(Constants.ROLE_NAME); eeee.hasMoreElements();) {
      XMLTree roleNameTree = (XMLTree) eeee.nextElement();
      SecurityRole sr = (SecurityRole) this.factory.createDescriptor(SecurityRole.class);
      sr.setName(roleNameTree.getValue());
      ac.addSecurityRole(sr);
        }
       
    }
    sc.setAuthorizationConstraint(ac);
      }
     
      XMLTree udcTree = scTree.getFirstElement(Constants.USERDATA_CONSTRAINT);
      if (udcTree != null) {
    UserDataConstraint udc = (UserDataConstraint) this.factory.createDescriptor(UserDataConstraint.class);
    if (udcTree.getFirstElement(Constants.DESCRIPTION) != null) {
        udc.setDescription(udcTree.getFirstElement(Constants.DESCRIPTION).getValue());
    }
    udc.setTransportGuarantee(udcTree.getFirstElement(Constants.TRANSPORT_GUARANTEE).getValue());
    sc.setUserDataConstraint(udc);
      }
      this.webApplicationDescriptor.addSecurityConstraint(sc);
  }
    }
View Full Code Here

      this.webApplicationDescriptor.addSecurityConstraint(sc);
  }
    }
   
    private void processLoginConfig() {
  XMLTree flTree = this.config.getFirstElement(Constants.LOGIN_CONFIG);
  if (flTree != null) {
      LoginConfiguration lc = (LoginConfiguration) this.factory.createDescriptor(LoginConfiguration.class);
      if (flTree.getFirstElement(Constants.AUTH_METHOD) != null) {
    lc.setAuthenticationMethod(flTree.getFirstElement(Constants.AUTH_METHOD).getValue());
      }
      if (flTree.getFirstElement(Constants.REALM_NAME) != null) {
    lc.setRealmName(flTree.getFirstElement(Constants.REALM_NAME).getValue());
      }
      if (flTree.getFirstElement(Constants.FORM_LOGIN_CONFIG) != null) {
    XMLTree formTree = flTree.getFirstElement(Constants.FORM_LOGIN_CONFIG);
    lc.setFormLoginPage(formTree.getFirstElement(Constants.FORM_LOGIN_PAGE).getValue());
    lc.setFormErrorPage(formTree.getFirstElement(Constants.FORM_ERROR_PAGE).getValue());
      }
      this.webApplicationDescriptor.setLoginConfiguration(lc);
  }
 
    }
View Full Code Here

    private Vector parseWelcomeFiles(Enumeration welcomeFiles) {
        Vector welcomeFilesV = new Vector();

        while (welcomeFiles.hasMoreElements()) {
      XMLTree x = (XMLTree)welcomeFiles.nextElement();

            welcomeFilesV.addElement((String)x.getValue().trim());
  }

  return welcomeFilesV;
    }
View Full Code Here

    private int getSessionTimeOut(Enumeration sessionTimeOuts) {
        Integer sessionTimeOut = new Integer(-1);

  while (sessionTimeOuts.hasMoreElements()) {
      XMLTree x = (XMLTree)sessionTimeOuts.nextElement();

      try {
          sessionTimeOut = new Integer(x.getValue().trim());
      } catch (Exception e) {
      }
  }
 
  return sessionTimeOut.intValue();
View Full Code Here

TOP

Related Classes of org.apache.tomcat.util.XMLTree

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.