本文整理匯總了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();
}
示例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);
}
}
}
}
示例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;
}
示例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
}
示例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;
}
示例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()));
}
}
示例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()));
}
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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();
}
示例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()));
}
}
示例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;
}
示例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;
}