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


Java NamingEnumeration.next方法代码示例

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


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

示例1: dnFromUser

import javax.naming.NamingEnumeration; //导入方法依赖的package包/类
private static String dnFromUser(String username) throws NamingException {
    Properties props = new Properties();
    props.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
    props.put(Context.PROVIDER_URL, "ldap://ldap.example.com");
    props.put(Context.REFERRAL, "ignore");

    InitialDirContext context = new InitialDirContext(props);

    SearchControls ctrls = new SearchControls();
    ctrls.setReturningAttributes(new String[]{"givenName", "sn"});
    ctrls.setSearchScope(SearchControls.SUBTREE_SCOPE);

    NamingEnumeration<SearchResult> answers = context.search("dc=People,dc=example,dc=com", "(uid=" + username + ")", ctrls);
    SearchResult result = answers.next();

    return result.getNameInNamespace();
}
 
开发者ID:blackarbiter,项目名称:Android_Code_Arbiter,代码行数:18,代码来源:JndiLdap.java

示例2: configFromJndiConf

import javax.naming.NamingEnumeration; //导入方法依赖的package包/类
private void configFromJndiConf(Object rootContextName) {
    if (rootContextName instanceof String) {
        String name = (String) rootContextName;
        name = name.substring(0, name.lastIndexOf('/')) + "/conf" + name.substring(name.lastIndexOf('/'));
        try {
            InitialContext ctx = new InitialContext();
            NamingEnumeration<Binding> bindings = ctx.listBindings(name);

            while (bindings.hasMore()) {
                Binding bd = bindings.next();
                IntrospectionSupport.setProperty(this, bd.getName(), bd.getObject());
            }

        } catch (Exception ignored) {
            if (LOG.isTraceEnabled()) {
                LOG.trace("exception on config from jndi: " + name, ignored);
            }
        }
    }
}
 
开发者ID:messaginghub,项目名称:pooled-jms,代码行数:21,代码来源:JmsPoolXAConnectionFactory.java

示例3: getAttributeValues

import javax.naming.NamingEnumeration; //导入方法依赖的package包/类
/**
 * Get the values for the given attribute. If the attribute is null
 * or does not contain any values, a zero length byte array is
 * returned. NOTE that it is assumed that all values are byte arrays.
 */
private byte[][] getAttributeValues(Attribute attr)
        throws NamingException {
    byte[][] values;
    if (attr == null) {
        values = BB0;
    } else {
        values = new byte[attr.size()][];
        int i = 0;
        NamingEnumeration<?> enum_ = attr.getAll();
        while (enum_.hasMore()) {
            Object obj = enum_.next();
            if (debug != null) {
                if (obj instanceof String) {
                    debug.println("LDAPCertStore.getAttrValues() "
                        + "enum.next is a string!: " + obj);
                }
            }
            byte[] value = (byte[])obj;
            values[i++] = value;
        }
    }
    return values;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:29,代码来源:LDAPCertStoreImpl.java

示例4: Rdn

import javax.naming.NamingEnumeration; //导入方法依赖的package包/类
/**
 * Constructs an Rdn from the given attribute set. See
 * {@link javax.naming.directory.Attributes Attributes}.
 * <p>
 * The string attribute values are not interpreted as
 * <a href="http://www.ietf.org/rfc/rfc2253.txt">RFC 2253</a>
 * formatted RDN strings. That is, the values are used
 * literally (not parsed) and assumed to be unescaped.
 *
 * @param attrSet The non-null and non-empty attributes containing
 * type/value mappings.
 * @throws InvalidNameException If contents of {@code attrSet} cannot
 *          be used to construct a valid RDN.
 */
public Rdn(Attributes attrSet) throws InvalidNameException {
    if (attrSet.size() == 0) {
        throw new InvalidNameException("Attributes cannot be empty");
    }
    entries = new ArrayList<>(attrSet.size());
    NamingEnumeration<? extends Attribute> attrs = attrSet.getAll();
    try {
        for (int nEntries = 0; attrs.hasMore(); nEntries++) {
            RdnEntry entry = new RdnEntry();
            Attribute attr = attrs.next();
            entry.type = attr.getID();
            entry.value = attr.get();
            entries.add(nEntries, entry);
        }
    } catch (NamingException e) {
        InvalidNameException e2 = new InvalidNameException(
                                    e.getMessage());
        e2.initCause(e);
        throw e2;
    }
    sort(); // arrange entries for comparison
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:37,代码来源:Rdn.java

示例5: getAttributeStrings

import javax.naming.NamingEnumeration; //导入方法依赖的package包/类
private List<String> getAttributeStrings(Attribute attr) {
try {
    ArrayList<String> attrValues = new ArrayList<String>();
    if (attr != null) {
	NamingEnumeration attrEnum = attr.getAll();
	while (attrEnum.hasMore()) {
	    Object attrValue = attrEnum.next();
	    if (attrValue != null) {
		attrValues.add(attrValue.toString());
	    }
	}
	return attrValues;
    }
} catch (NamingException e) {
    log.error("===> Naming exception occurred: " + e.getMessage());
}
return null;
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:LdapService.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) {

    try {
        NamingEnumeration items = namingContext.listBindings("");
        while (items.hasMore()) {
            Binding item = (Binding) items.next();
            if (item.getObject() instanceof javax.naming.Context) {
                printResources
                    (writer, prefix + item.getName() + "/",
                     (javax.naming.Context) item.getObject(), type, clazz);
            } 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) {
        log("ManagerServlet.resources[" + type + "]", t);
        writer.println(sm.getString("managerServlet.exception",
                                    t.toString()));
    }

}
 
开发者ID:c-rainstorm,项目名称:jerrydog,代码行数:35,代码来源:ManagerServlet.java

示例7: 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

示例8: addAttributeValues

import javax.naming.NamingEnumeration; //导入方法依赖的package包/类
/**
 * Add values of a specified attribute to a list
 *
 * @param attrId Attribute name
 * @param attrs Attributes containing the new values
 * @param values ArrayList containing values found so far
 *
 * @exception NamingException if a directory server error occurs
 */
private ArrayList<String> addAttributeValues(String attrId,
                                     Attributes attrs,
                                     ArrayList<String> values)
    throws NamingException{

    if (containerLog.isTraceEnabled())
        containerLog.trace("  retrieving values for attribute " + attrId);
    if (attrId == null || attrs == null)
        return values;
    if (values == null)
        values = new ArrayList<String>();
    Attribute attr = attrs.get(attrId);
    if (attr == null)
        return values;
    NamingEnumeration<?> e = attr.getAll();
    try {
        while(e.hasMore()) {
            String value = (String)e.next();
            values.add(value);
        }
    } catch (PartialResultException ex) {
        if (!adCompat)
            throw ex;
    } finally {
        e.close();
    }
    return values;
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:38,代码来源:JNDIRealm.java

示例9: formatEmailInfo

import javax.naming.NamingEnumeration; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
private Map<String, String> formatEmailInfo(SearchResult sResult, String targetKey) {

    if (null == sResult) {
        return Collections.emptyMap();
    }

    Map<String, String> result = new LinkedHashMap<String, String>();
    try {
        NamingEnumeration namingEnumeration = sResult.getAttributes().getAll();
        while (namingEnumeration.hasMoreElements()) {
            Attribute attr = (Attribute) namingEnumeration.next();
            String attrId = attr.getID();
            String attrValue = attr.getAll().next().toString();
            if (targetKey.equals(attrId)) {
                result.put("email", attrValue);
            }
            if ("cn".equals(attrId)) {
                result.put("name", attrValue);
            }
        }

    }
    catch (Exception e) {
        loggerError("formatEmailInfo 591", "", e);
    }

    return result;
}
 
开发者ID:uavorg,项目名称:uavstack,代码行数:30,代码来源:GUISSOLdapClient.java

示例10: getHeaderField

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

    if (!connected) {
        // Try to connect (silently)
        try {
            connect();
        } catch (IOException e) {
            // Ignore
        }
    }

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

    NamingEnumeration<String> attributeEnum = attributes.getIDs();
    try {
        while (attributeEnum.hasMore()) {
            String attributeID = 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);
            }
        }
    } catch (NamingException ne) {
        // Shouldn't happen
    }

    return (null);

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

示例11: getHeaderField

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

	if (!connected) {
		// Try to connect (silently)
		try {
			connect();
		} catch (IOException e) {
			// Ignore
		}
	}

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

	NamingEnumeration<String> attributeEnum = attributes.getIDs();
	try {
		while (attributeEnum.hasMore()) {
			String attributeID = 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);
			}
		}
	} catch (NamingException ne) {
		// Shouldn't happen
	}

	return (null);

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

示例12: 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

示例13: printResources

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

  try {
    final NamingEnumeration items = namingContext.listBindings("");
    while (items.hasMore()) {
      final Binding item = (Binding) items.next();
      if (item.getObject() instanceof javax.naming.Context) {
        printResources
                (writer, prefix + item.getName() + '/',
                        (javax.naming.Context) item.getObject(), type, clazz);
      } 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) {
    log("ManagerServlet.resources[" + type + ']', t);
    writer.println(sm.getString("managerServlet.exception",
            t.toString()));
  }

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:35,代码来源:ManagerServlet.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:SunburstApps,项目名称:OpenJSharp,代码行数:47,代码来源:BasicAttributes.java

示例15: addAttributeValues

import javax.naming.NamingEnumeration; //导入方法依赖的package包/类
/**
 * Add values of a specified attribute to a list
 *
 * @param attrId Attribute name
 * @param attrs Attributes containing the new values
 * @param values ArrayList containing values found so far
 *
 * @exception NamingException if a directory server error occurs
 */
private ArrayList<String> addAttributeValues(String attrId,
                                     Attributes attrs,
                                     ArrayList<String> values)
    throws NamingException{

    if (containerLog.isTraceEnabled())
        containerLog.trace("  retrieving values for attribute " + attrId);
    if (attrId == null || attrs == null)
        return values;
    if (values == null)
        values = new ArrayList<String>();
    Attribute attr = attrs.get(attrId);
    if (attr == null)
        return (values);
    NamingEnumeration e = attr.getAll();
    try {
        while(e.hasMore()) {
            String value = (String)e.next();
            values.add(value);
        }
    } catch (PartialResultException ex) {
        if (!adCompat)
            throw ex;
    }
    return values;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:36,代码来源:JNDIRealm.java


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