當前位置: 首頁>>代碼示例>>Java>>正文


Java Attribute.getAll方法代碼示例

本文整理匯總了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;
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:34,代碼來源:LDAPUserRegistry.java

示例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;
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:19,代碼來源:LdapService.java

示例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;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:29,代碼來源:LDAPCertStore.java

示例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 "" ;
   }
 
開發者ID:costea7,項目名稱:ChronoBike,代碼行數:31,代碼來源:LdapUtil.java

示例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;
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:38,代碼來源:JNDIRealm.java

示例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);
	}
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:28,代碼來源:MemberOfGroupSearch.java

示例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;
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:28,代碼來源:MemberOfGroupSearch.java

示例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;
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:34,代碼來源:MemberOfGroupSearch.java

示例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;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:36,代碼來源:JNDIRealm.java

示例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);

}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:40,代碼來源:DirContextURLConnection.java

示例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;
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:39,代碼來源:MTableUtils.java

示例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;
}
 
開發者ID:uavorg,項目名稱:uavstack,代碼行數:35,代碼來源:GUISSOLdapClient.java

示例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;
}
 
開發者ID:how2j,項目名稱:lazycat,代碼行數:40,代碼來源:JNDIRealm.java

示例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);

}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:44,代碼來源:DirContextURLConnection.java

示例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);

}
 
開發者ID:how2j,項目名稱:lazycat,代碼行數:45,代碼來源:DirContextURLConnection.java


注:本文中的javax.naming.directory.Attribute.getAll方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。