Package javax.naming

Examples of javax.naming.NamingEnumeration


        if (log.isTraceEnabled()) {
            log.trace("  Scanning TLDs in " + rootPath + " subdirectory");
        }

        try {
            NamingEnumeration items = resources.list(rootPath);
            while (items.hasMoreElements()) {
                NameClassPair item = (NameClassPair) items.nextElement();
                String resourcePath = rootPath + "/" + item.getName();
                if (!resourcePath.endsWith(".tld")
                        && (resourcePath.startsWith("/WEB-INF/classes")
                            || resourcePath.startsWith("/WEB-INF/lib"))) {
                    continue;
View Full Code Here


                            constraints.setDerefLinkFlag(deref_link);
                            constraints.setCountLimit(count_limit);
                            if (attrList.length > 0) {
                                constraints.setReturningAttributes(attrList);
                            }
                            NamingEnumeration ldapresults = ctx.search(searchbase, filter, constraints);

                            if (!doc_element.equals("")) {
                                transformer.start(doc_element, attr);
                            }

                            while (ldapresults != null && ldapresults.hasMore()) {
                                if (!row_element.equals("")) {
                                    transformer.start(row_element, attr);
                                }
                                SearchResult si = (SearchResult)ldapresults.next();
                                javax.naming.directory.Attributes attrs = si.getAttributes();
                                if (attrs != null) {
                                    NamingEnumeration ae = attrs.getAll();
                                    while (ae.hasMoreElements()) {
                                        Attribute at = (Attribute)ae.next();
                                        Enumeration vals = at.getAll();
                                        String attrID = at.getID();
                                        if (showAttribute) {
                                            transformer.start(attrID, attr);
                                        }
                                        String attrVal = (String)vals.nextElement();
                                        if (query_index > 0) {
                                            switch (transformer.getQuery(query_index-1).current_state) {
                                                case LDAPTransformer.STATE_INSIDE_FILTER_ELEMENT:
                                                    if (!transformer.getQuery(query_index-1).filter.equals("")) {
                                                        transformer.getQuery(query_index-1).filter.concat(", ");
                                                    }
                                                    transformer.getQuery(query_index-1).filter.concat(attrID).concat("=").concat(attrVal);
                                                    break;
                                                default:
                                                    transformer.start(attrID, attr);
                                            }
                                        } else {
                                            transformer.data(String.valueOf(attrVal));
                                        }
                                        if (showAttribute) {
                                            transformer.end(attrID);
                                        }
                                    }
                                }
                                if (!row_element.equals("")) {
                                    transformer.end(row_element);
                                }
                            }
                            if (!doc_element.equals("")) {
                                transformer.end(doc_element);
                            }
                        } catch(Exception e) {
                            if (sax_error) {
                                throw new Exception ("[LDAPTransformer] Error in LDAP-Query: " + e.toString());
                            } else {
                                transformer.start(error_element, attr);
                                transformer.data("[LDAPTransformer] Error in LDAP-Query: " + e);
                                transformer.end(error_element);
                                transformer.getTheLogger().error("[LDAPTransformer] Exception: " + e.toString());
                            }
                        }
                        break;
                    case LDAPTransformer.STATE_INSIDE_EXECUTE_INCREMENT:
                        try {
                            if (scope.equals("OBJECT_SCOPE")) {
                                constraints.setSearchScope(SearchControls.OBJECT_SCOPE);
                            } else if (scope.equals("SUBTREE_SCOPE")) {
                                constraints.setSearchScope(SearchControls.SUBTREE_SCOPE);
                            } else {
                                constraints.setSearchScope(SearchControls.ONELEVEL_SCOPE);
                            }
                            constraints.setTimeLimit(time_limit);
                            constraints.setDerefLinkFlag(deref_link);
                            constraints.setCountLimit(count_limit);
                            if (attrList.length != 1) {
                                transformer.start(error_element, attr);
                                transformer.data("Increment must reference exactly 1 attribute.");
                                transformer.end(error_element);
                            } else {
                                constraints.setReturningAttributes(attrList);
                                NamingEnumeration ldapresults = ctx.search(searchbase, filter, constraints);
                                int attrVal = 0;
                                String attrID = "";
                                SearchResult si = null;
                                while (ldapresults != null && ldapresults.hasMore()) {
                                    si = (SearchResult)ldapresults.next();
                                    javax.naming.directory.Attributes attrs = si.getAttributes();
                                    if (attrs != null) {
                                        NamingEnumeration ae = attrs.getAll();
                                        while (ae.hasMoreElements()) {
                                            Attribute at = (Attribute)ae.next();
                                            Enumeration vals = at.getAll();
                                            attrID = at.getID();
                                            attrVal = Integer.parseInt((String)vals.nextElement());
                                        }
                                    }
View Full Code Here

      if (attributes == null)
          return (Collections.EMPTY_MAP);

      HashMap headerFields = new HashMap(attributes.size());
      NamingEnumeration attributeEnum = attributes.getIDs();
      try {
          while (attributeEnum.hasMore()) {
              String attributeID = (String)attributeEnum.next();
              Attribute attribute = attributes.get(attributeID);
              if (attribute == null) continue;
              ArrayList attributeValueList = new ArrayList(attribute.size());
              NamingEnumeration attributeValues = attribute.getAll();
              while (attributeValues.hasMore()) {
                  Object attrValue = attributeValues.next();
                  attributeValueList.add(getHeaderValueAsString(attrValue));
              }
              attributeValueList.trimToSize(); // should be a no-op if attribute.size() didn't lie
              headerFields.put(attributeID, Collections.unmodifiableList(attributeValueList));
          }
View Full Code Here

        }
       
        if (attributes == null)
            return (null);

        NamingEnumeration attributeEnum = attributes.getIDs();
        try {
            while (attributeEnum.hasMore()) {
                String attributeID = (String)attributeEnum.next();
                if (attributeID.equalsIgnoreCase(name)) {
                    Attribute attribute = attributes.get(attributeID);
                    if (attribute == null) return null;
                    Object attrValue = attribute.get(attribute.size()-1);
                    return getHeaderValueAsString(attrValue);
View Full Code Here

       
        Vector result = new Vector();
       
        if (collection != null) {
            try {
                NamingEnumeration enumeration = context.list(getURL().getFile());
                while (enumeration.hasMoreElements()) {
                    NameClassPair ncp = (NameClassPair) enumeration.nextElement();
                    result.addElement(ncp.getName());
                }
            } catch (NamingException e) {
                // Unexpected exception
                throw new FileNotFoundException(
View Full Code Here

                attribs = new String[]{userRoleName};
            }
            constraints.setReturningAttributes(attribs);


            NamingEnumeration results = context.search(userBase, filter, constraints);

            if (results == null || !results.hasMore()) {
                return false;
            }

            SearchResult result = (SearchResult) results.next();

            if (results.hasMore()) {
                //ignore for now
            }
            NameParser parser = context.getNameParser("");
            Name contextName = parser.parse(context.getNameInNamespace());
            Name baseName = parser.parse(userBase);
View Full Code Here

        if (roleSearchSubtreeBool) {
            constraints.setSearchScope(SearchControls.SUBTREE_SCOPE);
        } else {
            constraints.setSearchScope(SearchControls.ONELEVEL_SCOPE);
        }
        NamingEnumeration results =
                context.search(roleBase, filter, constraints);
        while (results.hasMore()) {
            SearchResult result = (SearchResult) results.next();
            Attributes attrs = result.getAttributes();
            if (attrs == null) {
                continue;
            }
            list = addAttributeValues(roleName, attrs, list);
View Full Code Here

        }
        Attribute attr = attrs.get(attrId);
        if (attr == null) {
            return (values);
        }
        NamingEnumeration e = attr.getAll();
        while (e.hasMore()) {
            String value = (String) e.next();
            values.add(value);
        }
        return values;
    }
View Full Code Here

            String[] attribs = new String[list.size()];
            list.toArray(attribs);
            constraints.setReturningAttributes(attribs);


            NamingEnumeration results = context.search(userBase, filter, constraints);

            if (results == null || !results.hasMore()) {
                return false;
            }

            SearchResult result = (SearchResult) results.next();

            if (results.hasMore()) {
                //ignore for now
            }
            NameParser parser = context.getNameParser("");
            Name contextName = parser.parse(context.getNameInNamespace());
            Name baseName = parser.parse(userBase);
View Full Code Here

        if (roleSearchSubtreeBool) {
            constraints.setSearchScope(SearchControls.SUBTREE_SCOPE);
        } else {
            constraints.setSearchScope(SearchControls.ONELEVEL_SCOPE);
        }
        NamingEnumeration results =
                context.search(roleBase, filter, constraints);
        while (results.hasMore()) {
            SearchResult result = (SearchResult) results.next();
            Attributes attrs = result.getAttributes();
            if (attrs == null) {
                continue;
            }
            list = addAttributeValues(roleName, attrs, list);
View Full Code Here

TOP

Related Classes of javax.naming.NamingEnumeration

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.