本文整理汇总了Java中javax.naming.directory.Attribute.getAll方法的典型用法代码示例。如果您正苦于以下问题:Java Attribute.getAll方法的具体用法?Java Attribute.getAll怎么用?Java Attribute.getAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.naming.directory.Attribute
的用法示例。
在下文中一共展示了Attribute.getAll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: hasAttributeValue
import javax.naming.directory.Attribute; //导入方法依赖的package包/类
/**
* Does a case-insensitive search for the given value in an attribute.
*
* @param attribute
* the attribute
* @param value
* the value to search for
* @return <code>true</code>, if the value was found
* @throws NamingException
* if there is a problem accessing the attribute values
*/
private boolean hasAttributeValue(Attribute attribute, String value) throws NamingException
{
if (attribute != null)
{
NamingEnumeration<?> values = attribute.getAll();
while (values.hasMore())
{
try
{
if (value.equalsIgnoreCase((String) values.next()))
{
return true;
}
}
catch (ClassCastException e)
{
// Not a string value. ignore and continue
}
}
}
return false;
}
示例2: getAttributeStrings
import javax.naming.directory.Attribute; //导入方法依赖的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;
}
示例3: getAttributeValues
import javax.naming.directory.Attribute; //导入方法依赖的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: getOneAttribute
import javax.naming.directory.Attribute; //导入方法依赖的package包/类
/**
* @param dn
* @param attributeName
* @return
* @throws NamingException
*/
public String getOneAttribute(String dn, String attributeName)
{
try
{
Attributes attrs = m_ctx.getAttributes(dn);
Attribute attr = attrs.get(attributeName);
if (attr != null)
{
Log.logDebug("getID : " + attr.getID());
NamingEnumeration enumeration = attr.getAll();
while (enumeration.hasMore())
{
Log.logDebug("getAll : " + enumeration.next());
}
return (String) attr.get();
}
}
catch (NamingException e)
{
e.printStackTrace();
return "" ;
}
return "" ;
}
示例5: addAttributeValues
import javax.naming.directory.Attribute; //导入方法依赖的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;
}
示例6: collectAllSubGroups
import javax.naming.directory.Attribute; //导入方法依赖的package包/类
private void collectAllSubGroups(Set<String> results, DirContext ctx, Attributes parent)
{
Attribute attribute = parent.get(memberField);
try
{
NamingEnumeration<?> enumeration = attribute.getAll();
int limit = ldap.config.getSearchLimit();
while( enumeration != null && enumeration.hasMore() && (limit == 0 || results.size() < limit) )
{
String groupName = (String) enumeration.next();
LDAPResult result = ldap.searchFirstResultAllBases(ctx, ldap.getGroupNameFilter(groupName),
new LdapResultHitsCollector(ldap.getExtGroupAttributes()), true);
if( result != null && results.add(getGroupName(result)) )
{
collectAllSubGroups(results, ctx, result.getAttributes());
}
}
}
catch( Exception e )
{
LOGGER.error("", e);
}
}
示例7: getLDAPGroupNames
import javax.naming.directory.Attribute; //导入方法依赖的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;
}
示例8: getParentGroups
import javax.naming.directory.Attribute; //导入方法依赖的package包/类
public List<SubgroupResult> getParentGroups()
{
if( !Check.isEmpty(memberOfField) )
{
Attribute attribute = attributes.get(memberOfField);
if( attribute != null )
{
try
{
NamingEnumeration<?> atts = attribute.getAll();
List<SubgroupResult> results = Lists.newArrayList();
while( atts.hasMoreElements() )
{
String n = atts.nextElement().toString();
Name parentGroupName = LDAP.parse(n);
results.add(new SubgroupResult(parentGroupName, ldap.getAttributes(ctx,
parentGroupName, returnAttributes)));
}
return results;
}
catch( NamingException e )
{
throw new RuntimeException(e);
}
}
}
else if( !Check.isEmpty(memberField) )
{
return ldap.searchAllBases(ctx, getMemberFilter(name.toString()),
new SubgroupResultHitsCollector(), true);
}
return null;
}
示例9: addAttributeValues
import javax.naming.directory.Attribute; //导入方法依赖的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;
}
示例10: getHeaderFields
import javax.naming.directory.Attribute; //导入方法依赖的package包/类
/**
* Returns an unmodifiable Map of the header fields.
*/
public Map getHeaderFields() {
if (!connected) {
// Try to connect (silently)
try {
connect();
} catch (IOException e) {
}
}
if (attributes == null)
return (Collections.EMPTY_MAP);
HashMap headerFields = new HashMap(attributes.size());
NamingEnumeration attributeEnum = attributes.getIDs();
try {
while (attributeEnum.hasMore()) {
String attributeID = (String)attributeEnum.next();
Attribute attribute = attributes.get(attributeID);
if (attribute == null) continue;
ArrayList attributeValueList = new ArrayList(attribute.size());
NamingEnumeration attributeValues = attribute.getAll();
while (attributeValues.hasMore()) {
Object attrValue = attributeValues.next();
attributeValueList.add(getHeaderValueAsString(attrValue));
}
attributeValueList.trimToSize(); // should be a no-op if attribute.size() didn't lie
headerFields.put(attributeID, Collections.unmodifiableList(attributeValueList));
}
} catch (NamingException ne) {
// Shouldn't happen
}
return Collections.unmodifiableMap(headerFields);
}
示例11: reverseDNS
import javax.naming.directory.Attribute; //导入方法依赖的package包/类
/**
* This method uses JNDI to look up an address in DNS and return its name
*
* @return the host name associated with the address or null if lookup isn't possible or there is
* no host name for this address
*/
private static String reverseDNS(InetAddress addr) {
byte[] addrBytes = addr.getAddress();
// reverse the address suitable for reverse lookup
StringBuilder sb = new StringBuilder();
for (int index = addrBytes.length - 1; index >= 0; index--) {
// lookup = lookup + (addrBytes[index] & 0xff) + '.';
sb.append((addrBytes[index] & 0xff)).append('.');
}
sb.append("in-addr.arpa");
String lookup = sb.toString();
try {
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.dns.DnsContextFactory");
DirContext ctx = new InitialDirContext(env);
Attributes attrs = ctx.getAttributes(lookup, new String[] {"PTR"});
for (NamingEnumeration ae = attrs.getAll(); ae.hasMoreElements();) {
Attribute attr = (Attribute) ae.next();
for (Enumeration vals = attr.getAll(); vals.hasMoreElements();) {
Object elem = vals.nextElement();
if ("PTR".equals(attr.getID()) && elem != null) {
return elem.toString();
}
}
}
ctx.close();
} catch (Exception e) {
// ignored
}
return null;
}
示例12: formatUserEnName
import javax.naming.directory.Attribute; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
private List<String> formatUserEnName(Attribute attr) {
if (null == attr) {
return Collections.emptyList();
}
List<String> result = new ArrayList<String>();
String formatCN = "=";
try {
NamingEnumeration members = attr.getAll();
while (members.hasMore()) {
String memberValue = members.next().toString();
int indexStart = memberValue.indexOf(formatCN);
if (indexStart == -1) {
result.add(memberValue);
continue;
}
int indexEnd = memberValue.indexOf(",");
String memberCN = memberValue.substring(indexStart + formatCN.length(), indexEnd);
result.add(memberCN);
}
}
catch (
Exception e) {
loggerError("formatUserEnName 648", "", e);
}
return result;
}
示例13: addAttributeValues
import javax.naming.directory.Attribute; //导入方法依赖的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;
}
示例14: getHeaderFields
import javax.naming.directory.Attribute; //导入方法依赖的package包/类
/**
* Returns an unmodifiable Map of the header fields.
*/
@Override
public Map<String,List<String>> getHeaderFields() {
if (!connected) {
// Try to connect (silently)
try {
connect();
} catch (IOException e) {
//Ignore
}
}
if (attributes == null)
return (Collections.emptyMap());
HashMap<String,List<String>> headerFields =
new HashMap<String,List<String>>(attributes.size());
NamingEnumeration<String> attributeEnum = attributes.getIDs();
try {
while (attributeEnum.hasMore()) {
String attributeID = attributeEnum.next();
Attribute attribute = attributes.get(attributeID);
if (attribute == null) continue;
ArrayList<String> attributeValueList =
new ArrayList<String>(attribute.size());
NamingEnumeration<?> attributeValues = attribute.getAll();
while (attributeValues.hasMore()) {
Object attrValue = attributeValues.next();
attributeValueList.add(getHeaderValueAsString(attrValue));
}
attributeValueList.trimToSize(); // should be a no-op if attribute.size() didn't lie
headerFields.put(attributeID, Collections.unmodifiableList(attributeValueList));
}
} catch (NamingException ne) {
// Shouldn't happen
}
return Collections.unmodifiableMap(headerFields);
}
示例15: getHeaderFields
import javax.naming.directory.Attribute; //导入方法依赖的package包/类
/**
* Returns an unmodifiable Map of the header fields.
*/
@Override
public Map<String, List<String>> getHeaderFields() {
if (!connected) {
// Try to connect (silently)
try {
connect();
} catch (IOException e) {
// Ignore
}
}
if (attributes == null)
return (Collections.emptyMap());
HashMap<String, List<String>> headerFields = new HashMap<String, List<String>>(attributes.size());
NamingEnumeration<String> attributeEnum = attributes.getIDs();
try {
while (attributeEnum.hasMore()) {
String attributeID = attributeEnum.next();
Attribute attribute = attributes.get(attributeID);
if (attribute == null)
continue;
ArrayList<String> attributeValueList = new ArrayList<String>(attribute.size());
NamingEnumeration<?> attributeValues = attribute.getAll();
while (attributeValues.hasMore()) {
Object attrValue = attributeValues.next();
attributeValueList.add(getHeaderValueAsString(attrValue));
}
attributeValueList.trimToSize(); // should be a no-op if
// attribute.size() didn't
// lie
headerFields.put(attributeID, Collections.unmodifiableList(attributeValueList));
}
} catch (NamingException ne) {
// Shouldn't happen
}
return Collections.unmodifiableMap(headerFields);
}