当前位置: 首页>>代码示例>>Java>>正文


Java NamingEnumeration.hasMore方法代码示例

本文整理汇总了Java中javax.naming.NamingEnumeration.hasMore方法的典型用法代码示例。如果您正苦于以下问题:Java NamingEnumeration.hasMore方法的具体用法?Java NamingEnumeration.hasMore怎么用?Java NamingEnumeration.hasMore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.naming.NamingEnumeration的用法示例。


在下文中一共展示了NamingEnumeration.hasMore方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doGet

import javax.naming.NamingEnumeration; //导入方法依赖的package包/类
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {

    resp.setContentType("text/plain;UTF-8");
    PrintWriter out = resp.getWriter();

    try {
        Context ctx = new InitialContext();
        NamingEnumeration<Binding> enm =
            ctx.listBindings("java:comp/env/list");
        while (enm.hasMore()) {
            Binding b = enm.next();
            out.print(b.getObject().getClass().getName());
        }
    } catch (NamingException ne) {
        ne.printStackTrace(out);
    }
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:20,代码来源:TestNamingContext.java

示例2: getRangeRestrictedAttribute

import javax.naming.NamingEnumeration; //导入方法依赖的package包/类
/**
 * Gets the values of a repeating attribute that may have range restriction options. If an attribute is range
 * restricted, it will appear in the attribute set with a ";range=i-j" option, where i and j indicate the start and
 * end index, and j is '*' if it is at the end.
 * 
 * @param attributes
 *            the attributes
 * @param attributeName
 *            the attribute name
 * @return the range restricted attribute
 * @throws NamingException
 *             the naming exception
 */
private Attribute getRangeRestrictedAttribute(Attributes attributes, String attributeName) throws NamingException
{
    Attribute unrestricted = attributes.get(attributeName);
    if (unrestricted != null)
    {
        return unrestricted;
    }
    NamingEnumeration<? extends Attribute> i = attributes.getAll();
    String searchString = attributeName.toLowerCase() + ';';
    while (i.hasMore())
    {
        Attribute attribute = i.next();
        if (attribute.getID().toLowerCase().startsWith(searchString))
        {
            return attribute;
        }
    }
    return null;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:33,代码来源:LDAPUserRegistry.java

示例3: getAllAttributesSorted

import javax.naming.NamingEnumeration; //导入方法依赖的package包/类
/**
    * @param dn
    * @return
    * @throws NamingException
    */
   public TreeMap getAllAttributesSorted(String dn) throws NamingException 
{
       NamingEnumeration enumAll = getAllAttributes(dn);
       TreeMap<String, Object> tree = new TreeMap<String, Object>();
       while (enumAll.hasMore()) 
       {
           Attribute a = (Attribute)enumAll.next();
           tree.put(new String(a.getID()), a.get());
       }
       for (Iterator it = tree.keySet().iterator(); it.hasNext();) 
       {
           String key = (String)it.next();
           Log.logDebug(key+" = "+tree.get(key));
       }
       return tree;
   }
 
开发者ID:costea7,项目名称:ChronoBike,代码行数:22,代码来源:LdapUtil.java

示例4: getUserAttributes

import javax.naming.NamingEnumeration; //导入方法依赖的package包/类
public static Map<String, String> getUserAttributes(DirContext ctx, String searchBase, String userName,
    String principalDomain, String... attributeNames)
    throws NamingException {
  if (StringUtils.isBlank(userName)) {
    throw new IllegalArgumentException("Username and password can not be blank.");
  }

  if (attributeNames.length == 0) {
    return Collections.emptyMap();
  }

  Attributes matchAttr = new BasicAttributes(true);
  BasicAttribute basicAttr = new BasicAttribute("userPrincipalName", userName + principalDomain);
  matchAttr.put(basicAttr);

  NamingEnumeration<? extends SearchResult> searchResult = ctx.search(searchBase, matchAttr, attributeNames);

  if (ctx != null) {
    ctx.close();
  }

  Map<String, String> result = new HashMap<>();

  if (searchResult.hasMore()) {
    NamingEnumeration<? extends Attribute> attributes = searchResult.next().getAttributes().getAll();

    while (attributes.hasMore()) {
      Attribute attr = attributes.next();
      String attrId = attr.getID();
      String attrValue = (String) attr.get();

      result.put(attrId, attrValue);
    }
  }
  return result;
}
 
开发者ID:SirAeroWN,项目名称:premier-wherehows,代码行数:37,代码来源:AuthenticationManager.java

示例5: equals

import javax.naming.NamingEnumeration; //导入方法依赖的package包/类
/**
 * Determines whether this {@code BasicAttributes} is equal to another
 * {@code Attributes}
 * Two {@code Attributes} are equal if they are both instances of
 * {@code Attributes},
 * treat the case of attribute IDs the same way, and contain the
 * same attributes. Each {@code Attribute} in this {@code BasicAttributes}
 * is checked for equality using {@code Object.equals()}, which may have
 * be overridden by implementations of {@code Attribute}).
 * If a subclass overrides {@code equals()},
 * it should override {@code hashCode()}
 * as well so that two {@code Attributes} instances that are equal
 * have the same hash code.
 * @param obj the possibly null object to compare against.
 *
 * @return true If obj is equal to this BasicAttributes.
 * @see #hashCode
 */
public boolean equals(Object obj) {
    if ((obj != null) && (obj instanceof Attributes)) {
        Attributes target = (Attributes)obj;

        // Check case first
        if (ignoreCase != target.isCaseIgnored()) {
            return false;
        }

        if (size() == target.size()) {
            Attribute their, mine;
            try {
                NamingEnumeration<?> theirs = target.getAll();
                while (theirs.hasMore()) {
                    their = (Attribute)theirs.next();
                    mine = get(their.getID());
                    if (!their.equals(mine)) {
                        return false;
                    }
                }
            } catch (NamingException e) {
                return false;
            }
            return true;
        }
    }
    return false;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:47,代码来源:BasicAttributes.java

示例6: printResources

import javax.naming.NamingEnumeration; //导入方法依赖的package包/类
/**
 * List the resources of the given context.
 */
protected void printResources(PrintWriter writer, String prefix, javax.naming.Context namingContext, String type,
		Class<?> clazz, StringManager smClient) {

	try {
		NamingEnumeration<Binding> items = namingContext.listBindings("");
		while (items.hasMore()) {
			Binding item = items.next();
			if (item.getObject() instanceof javax.naming.Context) {
				printResources(writer, prefix + item.getName() + "/", (javax.naming.Context) item.getObject(), type,
						clazz, smClient);
			} else {
				if ((clazz != null) && (!(clazz.isInstance(item.getObject())))) {
					continue;
				}
				writer.print(prefix + item.getName());
				writer.print(':');
				writer.print(item.getClassName());
				// Do we want a description if available?
				writer.println();
			}
		}
	} catch (Throwable t) {
		ExceptionUtils.handleThrowable(t);
		log("ManagerServlet.resources[" + type + "]", t);
		writer.println(smClient.getString("managerServlet.exception", t.toString()));
	}

}
 
开发者ID:how2j,项目名称:lazycat,代码行数:32,代码来源:ManagerServlet.java

示例7: findUserDn

import javax.naming.NamingEnumeration; //导入方法依赖的package包/类
/**
 * Finds a distinguished name(DN) of a user by querying the active directory LDAP context for the
 * specified username.
 */
protected String findUserDn(LdapContextFactory ldapContextFactory, String username) throws NamingException {
    LdapContext ctx = null;
    try {
        // Binds using the system username and password.
        ctx = ldapContextFactory.getSystemLdapContext();

        final SearchControls ctrl = new SearchControls();
        ctrl.setCountLimit(1);
        ctrl.setSearchScope(SearchControls.SUBTREE_SCOPE);
        ctrl.setTimeLimit(searchTimeoutMillis);

        final String filter =
                searchFilter != null ? USERNAME_PLACEHOLDER.matcher(searchFilter)
                                                           .replaceAll(username)
                                     : username;
        final NamingEnumeration<SearchResult> result = ctx.search(searchBase, filter, ctrl);
        try {
            if (!result.hasMore()) {
                throw new AuthenticationException("No username: " + username);
            }
            return result.next().getNameInNamespace();
        } finally {
            result.close();
        }
    } finally {
        LdapUtils.closeContext(ctx);
    }
}
 
开发者ID:line,项目名称:centraldogma,代码行数:33,代码来源:SearchFirstActiveDirectoryRealm.java

示例8: printResources

import javax.naming.NamingEnumeration; //导入方法依赖的package包/类
/**
 * List the resources of the given context.
 */
protected void printResources(PrintWriter writer, String prefix,
                              javax.naming.Context namingContext,
                              String type, Class<?> clazz,
                              StringManager smClient) {

    try {
        NamingEnumeration<Binding> items = namingContext.listBindings("");
        while (items.hasMore()) {
            Binding item = items.next();
            if (item.getObject() instanceof javax.naming.Context) {
                printResources
                    (writer, prefix + item.getName() + "/",
                     (javax.naming.Context) item.getObject(), type, clazz,
                     smClient);
            } else {
                if ((clazz != null) &&
                    (!(clazz.isInstance(item.getObject())))) {
                    continue;
                }
                writer.print(prefix + item.getName());
                writer.print(':');
                writer.print(item.getClassName());
                // Do we want a description if available?
                writer.println();
            }
        }
    } catch (Throwable t) {
        ExceptionUtils.handleThrowable(t);
        log("ManagerServlet.resources[" + type + "]", t);
        writer.println(smClient.getString("managerServlet.exception",
                t.toString()));
    }

}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:38,代码来源:ManagerServlet.java

示例9: getSomeAttributes

import javax.naming.NamingEnumeration; //导入方法依赖的package包/类
/**
    * @param dn
    * @param attributeNames
    * @return
    * @throws NamingException
    */
   public NamingEnumeration getSomeAttributes(String dn, String[] attributeNames) throws NamingException 
{
       Attributes attrs = m_ctx.getAttributes(dn, attributeNames);
       NamingEnumeration enumSome = attrs.getAll();
       while (enumSome.hasMore()) 
       {
           Attribute a = (Attribute)enumSome.next();
           Log.logDebug(a.getID()+" = "+a.get());
       }
       return enumSome;
   }
 
开发者ID:costea7,项目名称:ChronoBike,代码行数:18,代码来源:LdapUtil.java

示例10: getHeaderField

import javax.naming.NamingEnumeration; //导入方法依赖的package包/类
/**
 * Returns the name of the specified header field.
 */
public String getHeaderField(String name) {

    if (!connected) {
        // Try to connect (silently)
        try {
            connect();
        } catch (IOException e) {
        }
    }
    
    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;
                return getHeaderValueAsString(attribute.get(attribute.size()-1));
            }
        }
    } catch (NamingException ne) {
        // Shouldn't happen
    }

    return (null);
    
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:34,代码来源:DirContextURLConnection.java

示例11: enumerate

import javax.naming.NamingEnumeration; //导入方法依赖的package包/类
public static boolean enumerate(Context _ctx, NamingEnumeration e, String string,String __dbtype) throws NamingException {
    while (e.hasMore()) {
        Binding binding = (Binding) e.next();
        Common.debugingLine2D("DataSource binding Name: " + binding.getName());
        // System.out.println("Type: " + binding.getClassName());
        //  System.out.println("Value: " + binding.getObject());

        if(binding.getName().endsWith(__dbtype))
        {
        DataSource _ds1 = (DataSource) _ctx.lookup("jdbc/" + binding.getName());
        addDs(binding.getName(), _ds1);
        }
    }
    return !_m_conn.isEmpty();
}
 
开发者ID:dimasalomatine,项目名称:sdirobot,代码行数:16,代码来源:CManagerMap.java

示例12: hasMoreEnum

import javax.naming.NamingEnumeration; //导入方法依赖的package包/类
private boolean hasMoreEnum(NamingEnumeration<SearchResult> namingEnum)
        throws NamingException {
    boolean hasMore = true;
    try {
        if (!namingEnum.hasMore()) {
            hasMore = false;
        }
    } catch (PartialResultException e) {
        hasMore = false;
        logger.logWarn(Log4jLogger.SYSTEM_LOG, e,
                LogMessageIdentifier.WARN_LDAP_PARTIAL_EXCEPTION);
    }
    return hasMore;
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:15,代码来源:LdapAccessServiceBean.java

示例13: search

import javax.naming.NamingEnumeration; //导入方法依赖的package包/类
/**
 * @return null if there are zero results
 */
private NamingEnumeration<SearchResult> search(DirContext ctx, Name base, String[] returnAttributes, Filter filter,
	boolean recurse)
{
	SearchControls ctls = new SearchControls();
	ctls.setCountLimit(filter.getLimit());
	ctls.setReturningAttributes(returnAttributes);
	ctls.setSearchScope(recurse ? SearchControls.SUBTREE_SCOPE : SearchControls.ONELEVEL_SCOPE);

	try
	{
		// Search for objects using the filter
		String query = filter.toFilter();
		if( LOGGER.isDebugEnabled() )
		{
			LOGGER.debug("Query:" + query + " Base:" + base);
		}
		NamingEnumeration<SearchResult> ne = ctx.search(base, query, ctls);
		if( ne.hasMore() )
		{
			return ne;
		}
	}
	catch( PartialResultException pre )
	{
		LOGGER.info(pre);
	}
	catch( SizeLimitExceededException slee )
	{
		LOGGER.info(slee);
	}
	catch( Exception e )
	{
		LOGGER.warn(e);
	}

	return null;
}
 
开发者ID:equella,项目名称:Equella,代码行数:41,代码来源:LDAP.java

示例14: equals

import javax.naming.NamingEnumeration; //导入方法依赖的package包/类
/**
 * Determines whether this <tt>BasicAttributes</tt> is equal to another
 * <tt>Attributes</tt>
 * Two <tt>Attributes</tt> are equal if they are both instances of
 * <tt>Attributes</tt>,
 * treat the case of attribute IDs the same way, and contain the
 * same attributes. Each <tt>Attribute</tt> in this <tt>BasicAttributes</tt>
 * is checked for equality using <tt>Object.equals()</tt>, which may have
 * be overridden by implementations of <tt>Attribute</tt>).
 * If a subclass overrides <tt>equals()</tt>,
 * it should override <tt>hashCode()</tt>
 * as well so that two <tt>Attributes</tt> instances that are equal
 * have the same hash code.
 * @param obj the possibly null object to compare against.
 *
 * @return true If obj is equal to this BasicAttributes.
 * @see #hashCode
 */
public boolean equals(Object obj) {
    if ((obj != null) && (obj instanceof Attributes)) {
        Attributes target = (Attributes)obj;

        // Check case first
        if (ignoreCase != target.isCaseIgnored()) {
            return false;
        }

        if (size() == target.size()) {
            Attribute their, mine;
            try {
                NamingEnumeration<?> theirs = target.getAll();
                while (theirs.hasMore()) {
                    their = (Attribute)theirs.next();
                    mine = get(their.getID());
                    if (!their.equals(mine)) {
                        return false;
                    }
                }
            } catch (NamingException e) {
                return false;
            }
            return true;
        }
    }
    return false;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:47,代码来源:BasicAttributes.java

示例15: getLDAPGroupNames

import javax.naming.NamingEnumeration; //导入方法依赖的package包/类
private Collection<Name> getLDAPGroupNames(DirContext ctx, Attributes useratt)
{
	Set<Name> foundGroups = new HashSet<Name>();
	if( !Check.isEmpty(memberOfField) )
	{
		Attribute attribute = useratt.get(memberOfField);
		try
		{
			NameParser parser = ctx.getNameParser(""); //$NON-NLS-1$
			if( attribute != null )
			{
				NamingEnumeration<?> enumeration = attribute.getAll();
				while( enumeration != null && enumeration.hasMore() )
				{
					String role = (String) enumeration.next();
					Name compound = parser.parse(role);
					foundGroups.add(compound);
				}
			}
		}
		catch( NamingException e )
		{
			throw new RuntimeException("Couldn't get memberField", e);
		}
	}
	return foundGroups;
}
 
开发者ID:equella,项目名称:Equella,代码行数:28,代码来源:MemberOfGroupSearch.java


注:本文中的javax.naming.NamingEnumeration.hasMore方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。