List of usage examples for javax.naming NamingEnumeration hasMoreElements
boolean hasMoreElements();
From source file:com.funambol.LDAP.dao.impl.ContactDAO.java
/** * Here's the place where all the magic happens: This method transforms a * LDAP entry to a <i>Contact</i> object. * /*from w w w . j a va 2 s. c o m*/ * @param entry * The LDAP entry * @return contact from the LDAP server */ public Contact createContact(Attributes attrs) { if (attrs == null) { logger.warn("Entry from LDAP is null so won't be able to create a contact"); return null; } try { if (logger.isDebugEnabled()) logger.debug("Getting attribute cn"); String cn = (attrs.get("cn") != null) ? (String) attrs.get("cn").get() : "null"; // logger.info("Getting attribute " + ldapId); // String entryId = ( attrs.get(ldapId) != null ) ? (String) // attrs.get(ldapId).get() : "null"; if (logger.isDebugEnabled()) { logger.debug("Creating Contact for " + cn // + ". Id is ( "+ entryId + " )" ); } Contact contact = new Contact(); /* Set name */ Name name = new Name(); if (attrs.get("cn") != null) { name.getDisplayName().setPropertyValue(cn); } if (attrs.get("givenName") != null) { name.getFirstName().setPropertyValue((String) attrs.get("givenName").get()); } if (attrs.get("sn") != null) { name.getLastName().setPropertyValue((String) attrs.get("sn").get()); } if (attrs.get("middleName") != null) { name.getMiddleName().setPropertyValue((String) attrs.get("middleName").get()); } if (attrs.get("title") != null) { name.getSalutation().setPropertyValue((String) attrs.get("title").get()); } if (attrs.get("nickName") != null) { name.getNickname().setPropertyValue((String) attrs.get("nickName").get()); } contact.setName(name); /* Set personal details */ PersonalDetail personal = new PersonalDetail(); BusinessDetail business = new BusinessDetail(); /* Set email */ if (attrs.get("mail") != null) { Email email = new Email(); email.setEmailType("Email1Address"); email.setPropertyValue((String) attrs.get("mail").get()); personal.addEmail(email); } if (attrs.get("mailAlternateAddress") != null) { Email email = new Email(); email.setEmailType("Email2Address"); email.setPropertyValue((String) attrs.get("mailAlternateAddress").get()); personal.addEmail(email); } // (Other, Home, Business) x (Telephone,Mobile) x Number /* Set phone phones */ ArrayList<Phone> allPhones = new ArrayList<Phone>(); // telephone: home, work, if (attrs.get("homePhone") != null) { Phone homePhone = new Phone(); homePhone.setPropertyValue((String) attrs.get("homePhone").get()); homePhone.setPhoneType("HomeTelephoneNumber"); allPhones.add(homePhone); } if (attrs.get("mobile") != null) { Phone mobile = new Phone(); mobile.setPropertyValue((String) attrs.get("mobile").get()); mobile.setPhoneType("MobileTelephoneNumber"); allPhones.add(mobile); } String val = LdapUtils.getPrintableAttribute(attrs.get("telephoneNumber")); if (StringUtils.isNotEmpty(val)) { Phone phone = new Phone(); phone.setPhoneType("BusinessTelephoneNumber"); phone.setPropertyValue(val); business.addPhone(phone); } val = LdapUtils.getPrintableAttribute(attrs.get("facsimileTelephoneNumber")); if (StringUtils.isNotEmpty(val)) { Phone phone = new Phone(); phone.setPhoneType("BusinessFaxNumber"); phone.setPropertyValue(val); business.addPhone(phone); } personal.setPhones(allPhones); /* * Set address *//* * if(entry.getAttribute("postalCode")!= null) { * personal.getAddress().getPostalCode().setPropertyValue( * entry.getAttribute("postalCode").getStringValue()); } * * if(entry.getAttribute("l")!= null) { * personal.getAddress().getCity().setPropertyValue( * entry.getAttribute("l").getStringValue()); } * * if(entry.getAttribute("postalAddress")!= null) { * personal.getAddress().getStreet().setPropertyValue( * entry.getAttribute("postalAddress").getStringValue()); } */ /* title */ if (attrs.get("title") != null) { NamingEnumeration<?> values = attrs.get("title").getAll(); ArrayList<Title> titles = new ArrayList<Title>(); while (values.hasMoreElements()) { titles.add(new Title((String) values.nextElement())); } business.setTitles(titles); } if (attrs.get("street") != null) { NamingEnumeration<?> streets = attrs.get("street").getAll(); while (streets.hasMoreElements()) { business.getAddress().getStreet().setPropertyValue((String) streets.nextElement()); } } if (attrs.get("c") != null) { business.getAddress().getCountry().setPropertyValue((String) attrs.get("c").get()); } if (attrs.get("l") != null) { business.getAddress().getCity().setPropertyValue((String) attrs.get("l").get()); } if (attrs.get("postalCode") != null) { business.getAddress().getPostalCode().setPropertyValue((String) attrs.get("postalCode").get()); } if (attrs.get("postalAddress") != null) { business.getAddress().getStreet().setPropertyValue((String) attrs.get("postalAddress").get()); } if (attrs.get("o") != null) { business.getCompany().setPropertyValue((String) attrs.get("o").get()); } if (attrs.get("calFbUrl") != null) { contact.setFreeBusy((String) attrs.get("calFbUrl").get()); } contact.setPersonalDetail(personal); contact.setBusinessDetail(business); // contact.setUid(entryId); return contact; } catch (Exception e) { logger.warn("Error in getting entry values: ", e); return null; } }
From source file:com.wfp.utils.LDAPUtils.java
@SuppressWarnings("unchecked") public static void parseData(NamingEnumeration searchResults) { int totalResultLogger = 0; if (searchResults == null) { return;/* w ww . j ava 2s. co m*/ } // Loop through the search results while (searchResults.hasMoreElements()) { SearchResult sr = null; try { sr = (SearchResult) searchResults.next(); } catch (NamingException e1) { Logger.error("No Search results on LDAP ", LDAPUtils.class); } if (sr == null) { Logger.error("No Search results on LDAP ", LDAPUtils.class); return; } Attributes attrs = sr.getAttributes(); if (attrs != null) { try { for (NamingEnumeration ae = attrs.getAll(); ae.hasMore();) { Attribute attr = (Attribute) ae.next(); for (NamingEnumeration e = attr.getAll(); e.hasMore(); totalResultLogger++) { } } } catch (NamingException e) { Logger.error("Error ocuring while reading the attributes ", LDAPUtils.class, e); } } else { Logger.info("No attributes found on LDAP", LDAPUtils.class); } } }
From source file:fedora.server.security.servletfilters.ldap.FilterLdap.java
private NamingEnumeration getNamingEnumeration(String userid, String password, String filter, SearchControls searchControls, Hashtable env) throws NamingException, Exception { String m = FilterSetup.getFilterNameAbbrev(FILTER_NAME) + " getNamingEnumeration() "; log.debug(m + ">"); // this condition is to -further- protect against behavior suggested by // log from hull (see below for first-line protection) // the idea here is to steer clear of possible trouble in underlying // code and avoid calling ldap w/o a needed and practical password String msg = "[LDAP: error code 49 - Bind failed: "; if (!individualUserBind()) { log.info(m + "-not- binding individual user"); } else {/* ww w . j ava 2 s . c o m*/ log.info(m + "-binding- individual user"); if (password == null) { log.debug(m + "null password"); if (USE_FILTER.equalsIgnoreCase(PW_NULL)) { log.debug(m + "-no- pre null password handling"); } else { if (AUTHENTICATE) { log.info(m + "-doing- pre null password handling"); if (UNAUTHENTICATE_USER_UNCONDITIONALLY.equalsIgnoreCase(PW_NULL)) { log.info(m + "pre unauthenticating for null password"); throw new NamingException(msg + "null password]"); } else if (SKIP_FILTER.equalsIgnoreCase(PW_NULL)) { log.info(m + "pre ignoring for null passwd"); throw new Exception(msg + "null password]"); } else { assert true : "bad value for PW_NULL==" + PW_NULL; } } } } else if ("".equals(password)) { log.debug(m + "0-length password"); if (USE_FILTER.equalsIgnoreCase(PW_0)) { log.debug(m + "-no- pre 0-length password handling"); } else { if (AUTHENTICATE) { log.info(m + "-doing- pre 0-length password handling"); if (UNAUTHENTICATE_USER_UNCONDITIONALLY.equalsIgnoreCase(PW_0)) { log.info(m + "pre unauthenticating for 0-length password"); throw new NamingException(msg + "0-length password]"); } else if (SKIP_FILTER.equalsIgnoreCase(PW_0)) { log.info(m + "pre ignoring for 0-length passwd"); throw new Exception(msg + "0-length password]"); } else { assert true : "bad value for PW_0==" + PW_0; } } } } else { assert password.length() > 0; } } NamingEnumeration ne = null; try { ne = getBasicNamingEnumeration(userid, password, filter, searchControls, env); assert ne != null; if (ne.hasMoreElements()) { log.debug(m + "enumeration has elements"); } else { log.debug(m + "enumeration has no elements, yet no exceptions"); if (bindRequired() && !individualUserBind()) { log.debug(m + "failed security bind"); throw new NamingException(msg + "failed security bind]"); } if (!AUTHENTICATE) { log.debug(m + "user authentication -not- done by this filter"); } else { log.debug(m + "user authentication -done- by this filter"); if (!bindRequired()) { log.debug(m + "but -not- binding"); } else { log.debug(m + "-and- binding"); if (SKIP_FILTER.equalsIgnoreCase(EMPTY_RESULTS)) { log.debug(m + "passing thru for EMPTY_RESULTS"); throw new Exception(msg + "null password]"); } else if (UNAUTHENTICATE_USER_UNCONDITIONALLY.equalsIgnoreCase(EMPTY_RESULTS)) { log.debug(m + "failing for EMPTY_RESULTS"); throw new NamingException(msg + "null password]"); } else if (USE_FILTER.equalsIgnoreCase(EMPTY_RESULTS)) { log.debug(m + "passing for EMPTY_RESULTS"); //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX } else if (UNAUTHENTICATE_USER_CONDITIONALLY.equalsIgnoreCase(EMPTY_RESULTS)) { if (ATTRIBUTES2RETURN == null || ATTRIBUTES2RETURN.length < 1) { log.debug(m + "fair enough"); } else { throw new NamingException(msg + "expected some"); } } else { assert true : "bad value for EMPTY_RESULTS==" + EMPTY_RESULTS; } } } } } finally { log.debug(m + "< " + ne); } return ne; }
From source file:com.nridge.core.app.ldap.ADQuery.java
/** * This method will perform multiple queries into Active Directory * in order to resolve what groups a user is a member of. The * logic will identify nested groups and add them to the table. * <p>//from w ww . j av a 2s .c o m * The LDAP_ACCOUNT_NAME field must be populated in the user bag * prior to invoking this method. Any site specific fields can be * assigned to the user bag will be included in the attribute query. * </p> * <p> * Any site specific fields can be assigned to the group bag will * be included in the attribute query. * </p> * * @param aUserBag Active Directory user attributes. * @param aGroupBag Active Directory group attributes. * * @return Table of groups that the user is a member of. * * @throws NSException Thrown if an LDAP naming exception is occurs. */ @SuppressWarnings("StringConcatenationInsideStringBufferAppend") public DataTable loadUserGroupsByAccountName(DataBag aUserBag, DataBag aGroupBag) throws NSException { byte[] objectSid; DataBag groupBag; Attribute responseAttribute; String fieldName, fieldValue; Logger appLogger = mAppMgr.getLogger(this, "loadUserGroupsByAccountName"); appLogger.trace(mAppMgr.LOGMSG_TRACE_ENTER); if (mLdapContext == null) { String msgStr = "LDAP context has not been established."; appLogger.error(msgStr); throw new NSException(msgStr); } // First, we will populate our user bag so that we can obtain the distinguished name. loadUserByAccountName(aUserBag); // Now we will use the DN to find all of the groups the user is a member of. String distinguishedName = aUserBag.getValueAsString(LDAP_DISTINGUISHED_NAME); if (StringUtils.isEmpty(distinguishedName)) distinguishedName = getPropertyValue("user_searchbasedn", null); // Next, we will initialize our group membership table. DataTable memberTable = new DataTable(aUserBag); memberTable.setName(String.format("%s Group Membership", aUserBag.getValueAsString(LDAP_COMMON_NAME))); // The next logic section will query AD for all of the groups the user is a member // of. Because we are following tokenGroups, we will gain access to nested groups. String groupSearchBaseDN = getPropertyValue("group_searchbasedn", null); SearchControls userSearchControls = new SearchControls(); userSearchControls.setSearchScope(SearchControls.OBJECT_SCOPE); StringBuffer groupsSearchFilter = null; String ldapAttrNames[] = { "tokenGroups" }; userSearchControls.setReturningAttributes(ldapAttrNames); try { NamingEnumeration<?> userSearchResponse = mLdapContext.search(distinguishedName, "(objectClass=user)", userSearchControls); if ((userSearchResponse != null) && (userSearchResponse.hasMoreElements())) { groupsSearchFilter = new StringBuffer(); groupsSearchFilter.append("(|"); SearchResult userSearchResult = (SearchResult) userSearchResponse.next(); Attributes userResultAttributes = userSearchResult.getAttributes(); if (userResultAttributes != null) { try { for (NamingEnumeration<?> searchResultAttributesAll = userResultAttributes .getAll(); searchResultAttributesAll.hasMore();) { Attribute attr = (Attribute) searchResultAttributesAll.next(); for (NamingEnumeration<?> namingEnumeration = attr.getAll(); namingEnumeration .hasMore();) { objectSid = (byte[]) namingEnumeration.next(); groupsSearchFilter.append("(objectSid=" + objectSidToString2(objectSid) + ")"); } groupsSearchFilter.append(")"); } } catch (NamingException e) { String msgStr = String.format("LDAP Listing Member Exception: %s", e.getMessage()); appLogger.error(msgStr, e); throw new NSException(msgStr); } } userSearchResponse.close(); // Finally, we will query each group in the search filter and add it to the table. SearchControls groupSearchControls = new SearchControls(); groupSearchControls.setSearchScope(SearchControls.SUBTREE_SCOPE); int field = 0; int attrCount = aGroupBag.count(); String[] groupsReturnedAtts = new String[attrCount]; for (DataField complexField : aGroupBag.getFields()) { fieldName = complexField.getName(); groupsReturnedAtts[field++] = fieldName; } groupSearchControls.setReturningAttributes(groupsReturnedAtts); NamingEnumeration<?> groupSearchResponse = mLdapContext.search(groupSearchBaseDN, groupsSearchFilter.toString(), groupSearchControls); while ((groupSearchResponse != null) && (groupSearchResponse.hasMoreElements())) { SearchResult groupSearchResult = (SearchResult) groupSearchResponse.next(); Attributes groupResultAttributes = groupSearchResult.getAttributes(); if (groupResultAttributes != null) { groupBag = new DataBag(aGroupBag); for (DataField complexField : groupBag.getFields()) { fieldName = complexField.getName(); responseAttribute = groupResultAttributes.get(fieldName); if (responseAttribute != null) { if (fieldName.equals(LDAP_OBJECT_SID)) { objectSid = (byte[]) responseAttribute.get(); fieldValue = objectSidToString2(objectSid); } else fieldValue = (String) responseAttribute.get(); if (StringUtils.isNotEmpty(fieldValue)) complexField.setValue(fieldValue); } } memberTable.addRow(groupBag); } } if (groupSearchResponse != null) groupSearchResponse.close(); } } catch (NamingException e) { String msgStr = String.format("LDAP Search Error (%s): %s", distinguishedName, e.getMessage()); appLogger.error(msgStr, e); throw new NSException(msgStr); } appLogger.trace(mAppMgr.LOGMSG_TRACE_DEPART); return memberTable; }
From source file:com.wfp.utils.LDAPUtils.java
@SuppressWarnings("unchecked") public static Map<String, String> parseDataAsMap(NamingEnumeration searchResults) { Map<String, String> resultAttrMap = null; int totalResultLogger = 0; if (searchResults == null) { return null; }/*from w ww . j a va2 s . c om*/ // Loop through the search results while (searchResults.hasMoreElements()) { SearchResult sr = null; try { sr = (SearchResult) searchResults.next(); } catch (NamingException e1) { Logger.error("No Search results on LDAP ", LDAPUtils.class); } if (sr == null) { Logger.error("No Search results on LDAP ", LDAPUtils.class); return null; } Attributes attrs = sr.getAttributes(); if (attrs != null) { if (resultAttrMap == null) { resultAttrMap = new HashMap<String, String>(); } try { for (NamingEnumeration ae = attrs.getAll(); ae.hasMore();) { Attribute attr = (Attribute) ae.next(); for (NamingEnumeration e = attr.getAll(); e.hasMore(); totalResultLogger++) { String attrValue = (String) e.next(); resultAttrMap.put(attr.getID(), attrValue); } } } catch (NamingException e) { Logger.error("Error ocuring while reading the attributes ", LDAPUtils.class, e); } } else { Logger.info("No attributes found on LDAP", LDAPUtils.class); } } return resultAttrMap; }
From source file:org.apache.manifoldcf.authorities.authorities.sharepoint.SharePointADAuthority.java
/** Obtain the DistinguishedName for a given user logon name. *@param ctx is the ldap context to use.//from w ww. java2s . c om *@param userName (Domain Logon Name) is the user name or identifier. *@param searchBase (Full Domain Name for the search ie: DC=qa-ad-76,DC=metacarta,DC=com) *@return DistinguishedName for given domain user logon name. * (Should throws an exception if user is not found.) */ protected String getDistinguishedName(LdapContext ctx, String userName, String searchBase, String userACLsUsername) throws ManifoldCFException { String returnedAtts[] = { "distinguishedName" }; String searchFilter = "(&(objectClass=user)(" + userACLsUsername + "=" + userName + "))"; SearchControls searchCtls = new SearchControls(); searchCtls.setReturningAttributes(returnedAtts); //Specify the search scope searchCtls.setSearchScope(SearchControls.SUBTREE_SCOPE); searchCtls.setReturningAttributes(returnedAtts); try { NamingEnumeration answer = ctx.search(searchBase, searchFilter, searchCtls); while (answer.hasMoreElements()) { SearchResult sr = (SearchResult) answer.next(); Attributes attrs = sr.getAttributes(); if (attrs != null) { String dn = attrs.get("distinguishedName").get().toString(); return dn; } } return null; } catch (NamingException e) { throw new ManifoldCFException(e.getMessage(), e); } }
From source file:fedora.server.security.servletfilters.ldap.FilterLdap.java
private Boolean processNamingEnumeration(NamingEnumeration ne, String password, Boolean authenticated, Map map) {//from w ww. jav a 2 s . c o m String m = FilterSetup.getFilterNameAbbrev(FILTER_NAME) + " processNamingEnumeration() "; log.debug(m + ">"); try { boolean errorOnSomeComparison = false; while (ne.hasMoreElements()) { log.debug(m + "another element"); SearchResult s = null; try { Object o = ne.nextElement(); log.debug(m + "got a " + o.getClass().getName()); s = (SearchResult) o; } catch (Throwable th) { log.error(m + "naming enum contains obj not SearchResult"); continue; } Attributes attributes = s.getAttributes(); getAttributes(attributes, map); if (individualUserComparison()) { Boolean temp = null; try { temp = comparePassword(attributes, password, PASSWORD); log.debug(m + "-this- comp yields " + temp); if (authenticated != null && !authenticated) { log.debug(m + "keeping prev failed authn"); } else { log.debug(m + "replacing prvsuccess or null authn"); if (errorOnSomeComparison) { log.debug(m + "errorOnSomeComparison==" + errorOnSomeComparison); } else { authenticated = temp; } } } catch (Throwable th) { log.debug(m + "in iUC conditional, caught throwable th==" + th); errorOnSomeComparison = true; authenticated = null; } } } if (individualUserComparison()) { if (errorOnSomeComparison) { log.debug(m + "exception, so assuring authenticated==" + authenticated); authenticated = null; map.clear(); } else if (authenticated == null) { authenticated = Boolean.FALSE; log.debug(m + "no passwd attr found, so authenticated==" + authenticated); } } } catch (Throwable th) { // play it safe: map.clear(); if (authenticated != null && authenticated) { // drop an earlier authentication, before exception was thrown authenticated = null; } // but leave alone a earlier -failed- authentication if (LOG_STACK_TRACES) { log.error(m + "ldap filter failure", th); } else { log.error(m + "ldap filter failure" + th.getMessage()); } } finally { log.debug(m + "< authenticated==" + authenticated + " map==" + map); } return authenticated; }
From source file:com.wfp.utils.LDAPUtils.java
@SuppressWarnings("unchecked") public static List parseDataAsList(NamingEnumeration searchResults) { //Logger.info("Formatting the data as List", LDAPUtils.class ); List<String> resultAttr = null; int totalResultLogger = 0; if (searchResults == null) { return null; }/* w w w .j ava2s . co m*/ // Loop through the search results while (searchResults.hasMoreElements()) { SearchResult sr = null; try { sr = (SearchResult) searchResults.next(); } catch (NamingException e1) { Logger.error("No Search results on LDAP ", LDAPUtils.class); } if (sr == null) { Logger.error("No Search results on LDAP ", LDAPUtils.class); return null; } Attributes attrs = sr.getAttributes(); if (attrs != null) { if (resultAttr == null) { resultAttr = new ArrayList(); } try { for (NamingEnumeration ae = attrs.getAll(); ae.hasMore();) { Attribute attr = (Attribute) ae.next(); for (NamingEnumeration e = attr.getAll(); e.hasMore(); totalResultLogger++) { String attrValue = (String) e.next(); resultAttr.add(attrValue); } } } catch (NamingException e) { Logger.error("Error ocuring while reading the attributes ", LDAPUtils.class, e); } } else { Logger.info("No attributes found on LDAP", LDAPUtils.class); } } return resultAttr; }
From source file:com.wfp.utils.LDAPUtils.java
public static Map<String, Object> parseDataAsMap(NamingEnumeration searchResults, String listValues) { //Logger.info("Formatting the data as MAP", LDAPUtils.class); Map<String, Object> resultAttrMap = null; int totalResultLogger = 0; if (searchResults == null) { return null; }//from w w w .j ava2 s .c o m // Loop through the search results while (searchResults.hasMoreElements()) { SearchResult sr = null; try { sr = (SearchResult) searchResults.next(); } catch (NamingException e1) { Logger.error("No Search results on LDAP ", LDAPUtils.class); } if (sr == null) { Logger.error("No Search results on LDAP ", LDAPUtils.class); return null; } Attributes attrs = sr.getAttributes(); if (attrs != null) { if (resultAttrMap == null) { resultAttrMap = new HashMap<String, Object>(); } try { for (NamingEnumeration ae = attrs.getAll(); ae.hasMore();) { Attribute attr = (Attribute) ae.next(); for (NamingEnumeration e = attr.getAll(); e.hasMore(); totalResultLogger++) { String attrValue = (String) e.next(); List<String> attrValuesList = null; if (listValues.indexOf(attr.getID()) >= 0) { attrValuesList = resultAttrMap.get(attr.getID()) == null ? null : (List<String>) resultAttrMap.get(attr.getID()); if (attrValuesList == null) { attrValuesList = new ArrayList<String>(); } attrValuesList.add(attrValue); resultAttrMap.put(attr.getID(), attrValuesList); } else { resultAttrMap.put(attr.getID(), attrValue); } } } } catch (NamingException e) { Logger.error("Error ocuring while reading the attributes ", LDAPUtils.class, e); } } else { Logger.info("No attributes found on LDAP", LDAPUtils.class); } } return resultAttrMap; }
From source file:catalina.startup.ContextConfig.java
/** * Accumulate and return a Set of resource paths to be analyzed for * tag library descriptors. Each element of the returned set will be * the context-relative path to either a tag library descriptor file, * or to a JAR file that may contain tag library descriptors in its * <code>META-INF</code> subdirectory. * * @exception IOException if an input/output error occurs while * accumulating the list of resource paths *//*from w w w . jav a2s. c o m*/ private Set tldScanResourcePaths() throws IOException { if (debug >= 1) { log(" Accumulating TLD resource paths"); } Set resourcePaths = new HashSet(); // Accumulate resource paths explicitly listed in the web application // deployment descriptor if (debug >= 2) { log(" Scanning <taglib> elements in web.xml"); } String taglibs[] = context.findTaglibs(); for (int i = 0; i < taglibs.length; i++) { String resourcePath = context.findTaglib(taglibs[i]); // FIXME - Servlet 2.3 DTD implies that the location MUST be // a context-relative path starting with '/'? if (!resourcePath.startsWith("/")) { resourcePath = "/WEB-INF/web.xml/../" + resourcePath; } if (debug >= 3) { log(" Adding path '" + resourcePath + "' for URI '" + taglibs[i] + "'"); } resourcePaths.add(resourcePath); } // Scan TLDs in the /WEB-INF subdirectory of the web application if (debug >= 2) { log(" Scanning TLDs in /WEB-INF subdirectory"); } DirContext resources = context.getResources(); try { NamingEnumeration items = resources.list("/WEB-INF"); while (items.hasMoreElements()) { NameClassPair item = (NameClassPair) items.nextElement(); String resourcePath = "/WEB-INF/" + item.getName(); // FIXME - JSP 1.2 is not explicit about whether we should // scan subdirectories of /WEB-INF for TLDs also if (!resourcePath.endsWith(".tld")) { continue; } if (debug >= 3) { log(" Adding path '" + resourcePath + "'"); } resourcePaths.add(resourcePath); } } catch (NamingException e) { ; // Silent catch: it's valid that no /WEB-INF directory exists } // Scan JARs in the /WEB-INF/lib subdirectory of the web application if (debug >= 2) { log(" Scanning JARs in /WEB-INF/lib subdirectory"); } try { NamingEnumeration items = resources.list("/WEB-INF/lib"); while (items.hasMoreElements()) { NameClassPair item = (NameClassPair) items.nextElement(); String resourcePath = "/WEB-INF/lib/" + item.getName(); if (!resourcePath.endsWith(".jar")) { continue; } if (debug >= 3) { log(" Adding path '" + resourcePath + "'"); } resourcePaths.add(resourcePath); } } catch (NamingException e) { ; // Silent catch: it's valid that no /WEB-INF/lib directory exists } // Return the completed set return (resourcePaths); }