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