當前位置: 首頁>>代碼示例>>Java>>正文


Java NamingEnumeration.nextElement方法代碼示例

本文整理匯總了Java中javax.naming.NamingEnumeration.nextElement方法的典型用法代碼示例。如果您正苦於以下問題:Java NamingEnumeration.nextElement方法的具體用法?Java NamingEnumeration.nextElement怎麽用?Java NamingEnumeration.nextElement使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.naming.NamingEnumeration的用法示例。


在下文中一共展示了NamingEnumeration.nextElement方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: list

import javax.naming.NamingEnumeration; //導入方法依賴的package包/類
/**
 * List children of this collection. The names given are relative to this
 * URI's path. The full uri of the children is then : path + "/" + name.
 */
public Enumeration<String> list()
    throws IOException {

    if (!connected) {
        connect();
    }

    if ((resource == null) && (collection == null)) {
        throw new FileNotFoundException(
                getURL() == null ? "null" : getURL().toString());
    }

    Vector<String> result = new Vector<String>();

    if (collection != null) {
        try {
            NamingEnumeration<NameClassPair> enumeration =
                collection.list("/");
            UEncoder urlEncoder = new UEncoder(UEncoder.SafeCharsSet.WITH_SLASH);
            while (enumeration.hasMoreElements()) {
                NameClassPair ncp = enumeration.nextElement();
                String s = ncp.getName();
                result.addElement(
                        urlEncoder.encodeURL(s, 0, s.length()).toString());
            }
        } catch (NamingException e) {
            // Unexpected exception
            throw new FileNotFoundException(
                    getURL() == null ? "null" : getURL().toString());
        }
    }

    return result.elements();

}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:40,代碼來源:DirContextURLConnection.java

示例2: tldScanResourcePathsWebInf

import javax.naming.NamingEnumeration; //導入方法依賴的package包/類
private void tldScanResourcePathsWebInf(DirContext resources,
                                        String rootPath,
                                        Set tldPaths) 
        throws IOException {

    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;
            }
            if (resourcePath.endsWith(".tld")) {
                if (log.isTraceEnabled()) {
                    log.trace("   Adding path '" + resourcePath + "'");
                }
                tldPaths.add(resourcePath);
            } else {
                tldScanResourcePathsWebInf(resources, resourcePath,
                                           tldPaths);
            }
        }
    } catch (NamingException e) {
        ; // Silent catch: it's valid that no /WEB-INF directory exists
    }
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:34,代碼來源:TldConfig.java

示例3: list

import javax.naming.NamingEnumeration; //導入方法依賴的package包/類
/**
 * List children of this collection. The names given are relative to this
 * URI's path. The full uri of the children is then : path + "/" + name.
 */
public Enumeration list()
    throws IOException {
    
    if (!connected) {
        connect();
    }
    
    if ((resource == null) && (collection == null)) {
        throw new FileNotFoundException();
    }
    
    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();
        }
    }
    
    return result.elements();
    
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:34,代碼來源:DirContextURLConnection.java

示例4: list

import javax.naming.NamingEnumeration; //導入方法依賴的package包/類
/**
 * List children of this collection. The names given are relative to this
 * URI's path. The full uri of the children is then : path + "/" + name.
 */
public Enumeration list()
    throws IOException {
    
    if (!connected) {
        connect();
    }
    
    if ((resource == null) && (collection == null)) {
        throw new FileNotFoundException();
    }
    
    Vector result = new Vector();
    
    if (collection != null) {
        try {
            NamingEnumeration _enum = context.list(getURL().getFile());

            while (_enum.hasMoreElements()) {
                NameClassPair ncp = (NameClassPair) _enum.nextElement();
                result.addElement(ncp.getName());
            }
        } catch (NamingException e) {
            // Unexpected exception
            throw new FileNotFoundException();
        }
    }
    
    return result.elements();
    
}
 
開發者ID:c-rainstorm,項目名稱:jerrydog,代碼行數:35,代碼來源:DirContextURLConnection.java

示例5: getUserLogin

import javax.naming.NamingEnumeration; //導入方法依賴的package包/類
/**
 * @param csUser: specific user we want to login
 * @param csPassword: specific password
 * @param bUseGenericUser: true if connecting using generic user, not the specific user (csUser / csPassword); in that case csUser/csPassword is ignored   
 * @return String UserDN; set to null or empty if user did not login correctly.
 */
public String getUserLogin(String csUser, String csPassword, boolean bUseGenericUser)
{
	String csUserLogin = csUser;
	String csPasswordLogin = csPassword;
	if (bUseGenericUser)
	{
		csUserLogin = m_csLDAPGenericUser;
		csPasswordLogin = m_csLDAPGenericPassword;
	}
	
	if (!validateLogin(csUserLogin, csPasswordLogin))
	{
		return null ;
	}
	if (m_ldap == null)
	{
		return null ;
	}
	
	NamingEnumeration enumer = m_ldap.searchSubtree(m_csLDAPRootOU, "sAMAccountName="+csUser) ;
	if (enumer.hasMoreElements())
	{
		SearchResult res = (SearchResult)enumer.nextElement() ;
		String name = res.getNameInNamespace() ;
		return name ;
	}
	return null;
}
 
開發者ID:costea7,項目名稱:ChronoBike,代碼行數:35,代碼來源:LdapRequester.java

示例6: doGetGroups

import javax.naming.NamingEnumeration; //導入方法依賴的package包/類
List<String> doGetGroups(String user) throws NamingException {
  List<String> groups = new ArrayList<String>();

  DirContext ctx = getDirContext();

  // Search for the user. We'll only ever need to look at the first result
  NamingEnumeration<SearchResult> results = ctx.search(baseDN,
      userSearchFilter,
      new Object[]{user},
      SEARCH_CONTROLS);
  if (results.hasMoreElements()) {
    SearchResult result = results.nextElement();
    String userDn = result.getNameInNamespace();

    NamingEnumeration<SearchResult> groupResults =
        ctx.search(baseDN,
            "(&" + groupSearchFilter + "(" + groupMemberAttr + "={0}))",
            new Object[]{userDn},
            SEARCH_CONTROLS);
    while (groupResults.hasMoreElements()) {
      SearchResult groupResult = groupResults.nextElement();
      Attribute groupName = groupResult.getAttributes().get(groupNameAttr);
      groups.add(groupName.get().toString());
    }
  }

  return groups;
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:29,代碼來源:LdapGroupsMapping.java

示例7: ldapApiQuery

import javax.naming.NamingEnumeration; //導入方法依賴的package包/類
private List<SearchResult> ldapApiQuery(String action, String name, String filter) {

        String logMsg = action + " " + filter;
        List<SearchResult> result = new ArrayList<SearchResult>();
        try {
            initLdapContext(action);
            LdapContext ldapCtx = ldapContexts.get(action);

            SearchControls constraints = new SearchControls();
            constraints.setSearchScope(SearchControls.SUBTREE_SCOPE);
            NamingEnumeration<SearchResult> en = ldapCtx.search(name, filter, constraints);

            // means all nodes
            if (en == null) {
                loggerInfo("LDAP信息", "獲取", "結果為空", logMsg);
                return Collections.emptyList();
            }
            if (!en.hasMoreElements()) {
                loggerInfo("LDAP信息", "獲取", "結果為空", logMsg);
                return Collections.emptyList();
            }

            while (en != null && en.hasMoreElements()) {// maybe more than one element
                Object obj = en.nextElement();
                if (obj instanceof SearchResult) {
                    SearchResult si = (SearchResult) obj;
                    result.add(si);
                }
            }
        }
        catch (Exception e) {
            loggerError("LDAP用戶信息獲取", logMsg, e);
            clearLdapContext(action);
        }

        if (!result.isEmpty()) {
            loggerInfo("LDAP信息", "獲取", "成功", logMsg);
        }
        return result;
    }
 
開發者ID:uavorg,項目名稱:uavstack,代碼行數:41,代碼來源:GUISSOLdapClient.java

示例8: convert

import javax.naming.NamingEnumeration; //導入方法依賴的package包/類
@Override
public Optional<Group> convert(final String dn, final Attributes ldapGroup) throws NamingException {
    LOG.info("Working on LDAP group: {}", dn);
    GroupBuilder builder = new GroupBuilder()
            .withDn(dn)
            .withLdapServer(server.getName())
            .withOcpName(calculateOCPGroupName(ldapGroup));


    try {
        @SuppressWarnings("unchecked")
        NamingEnumeration<String> members = (NamingEnumeration<String>) ldapGroup.get(MEMBER_ATTRIBUTE).getAll();
        LOG.info("Group has members: group={}, members={}", dn, members);

        while (members.hasMoreElements()) {
            String memberDn = members.nextElement();
            LOG.debug("Working on member: {}", memberDn);

            Attributes memberEntry = server.getByDn(memberDn);

            if (isUser(memberEntry)) {
                LOG.trace("Member is an user: dn={}", memberDn);
                Optional<User> memberUser = userConverter.convert(memberDn, memberEntry);
                memberUser.ifPresent(builder::addUser);
            } else { /* need to load the new group data ... */
                LOG.trace("Member is a group: dn={}", memberDn);
                Optional<Group> memberGroup = convert(memberDn, memberEntry);
                memberGroup.ifPresent(builder::addGroup);
            }
        }
    } catch (NullPointerException e) {
        LOG.debug("LDAP Group has no members: {}", dn);
    }

    return Optional.of(builder.build());
}
 
開發者ID:klenkes74,項目名稱:openshift-ldapsync,代碼行數:37,代碼來源:LdapGroupConverter.java

示例9: list

import javax.naming.NamingEnumeration; //導入方法依賴的package包/類
/**
 * List children of this collection. The names given are relative to this
 * URI's path. The full uri of the children is then : path + "/" + name.
 */
public Enumeration<String> list() throws IOException {

	if (!connected) {
		connect();
	}

	if ((resource == null) && (collection == null)) {
		throw new FileNotFoundException(getURL() == null ? "null" : getURL().toString());
	}

	Vector<String> result = new Vector<String>();

	if (collection != null) {
		try {
			NamingEnumeration<NameClassPair> enumeration = collection.list("/");
			UEncoder urlEncoder = new UEncoder(UEncoder.SafeCharsSet.WITH_SLASH);
			while (enumeration.hasMoreElements()) {
				NameClassPair ncp = enumeration.nextElement();
				String s = ncp.getName();
				result.addElement(urlEncoder.encodeURL(s, 0, s.length()).toString());
			}
		} catch (NamingException e) {
			// Unexpected exception
			throw new FileNotFoundException(getURL() == null ? "null" : getURL().toString());
		}
	}

	return result.elements();

}
 
開發者ID:how2j,項目名稱:lazycat,代碼行數:35,代碼來源:DirContextURLConnection.java

示例10: doGetGroups

import javax.naming.NamingEnumeration; //導入方法依賴的package包/類
List<String> doGetGroups(String user) throws NamingException {
  List<String> groups = new ArrayList<String>();

  DirContext ctx = getDirContext();

  // Search for the user. We'll only ever need to look at the first result
  NamingEnumeration<SearchResult> results = ctx.search(baseDN,
      userSearchFilter,
      new Object[]{user},
      SEARCH_CONTROLS);
  if (results.hasMoreElements()) {
    SearchResult result = results.nextElement();
    String userDn = result.getNameInNamespace();

    NamingEnumeration<SearchResult> groupResults = null;

    if (isPosix) {
      String gidNumber = null;
      String uidNumber = null;
      Attribute gidAttribute = result.getAttributes().get(posixGidAttr);
      Attribute uidAttribute = result.getAttributes().get(posixUidAttr);
      if (gidAttribute != null) {
        gidNumber = gidAttribute.get().toString();
      }
      if (uidAttribute != null) {
        uidNumber = uidAttribute.get().toString();
      }
      if (uidNumber != null && gidNumber != null) {
        groupResults =
            ctx.search(baseDN,
                "(&"+ groupSearchFilter + "(|(" + posixGidAttr + "={0})" +
                    "(" + groupMemberAttr + "={1})))",
                new Object[] { gidNumber, uidNumber },
                SEARCH_CONTROLS);
      }
    } else {
      groupResults =
          ctx.search(baseDN,
              "(&" + groupSearchFilter + "(" + groupMemberAttr + "={0}))",
              new Object[]{userDn},
              SEARCH_CONTROLS);
    }
    if (groupResults != null) {
      while (groupResults.hasMoreElements()) {
        SearchResult groupResult = groupResults.nextElement();
        Attribute groupName = groupResult.getAttributes().get(groupNameAttr);
        groups.add(groupName.get().toString());
      }
    }
  }

  return groups;
}
 
開發者ID:nucypher,項目名稱:hadoop-oss,代碼行數:54,代碼來源:LdapGroupsMapping.java


注:本文中的javax.naming.NamingEnumeration.nextElement方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。