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


Java Attribute.get方法代碼示例

本文整理匯總了Java中javax.naming.directory.Attribute.get方法的典型用法代碼示例。如果您正苦於以下問題:Java Attribute.get方法的具體用法?Java Attribute.get怎麽用?Java Attribute.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.naming.directory.Attribute的用法示例。


在下文中一共展示了Attribute.get方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getGroupName

import javax.naming.directory.Attribute; //導入方法依賴的package包/類
private String getGroupName(final DirContextOperations ctx) {
    final String name;

    if (useDnForGroupName) {
        name = ctx.getDn().toString();
    } else {
        final Attribute attributeName = ctx.getAttributes().get(groupNameAttribute);
        if (attributeName == null) {
            throw new AuthorizationAccessException("Group identity attribute [" + groupNameAttribute + "] does not exist.");
        }

        try {
            name = (String) attributeName.get();
        } catch (NamingException e) {
            throw new AuthorizationAccessException("Error while retrieving group name attribute [" + groupNameAttribute + "].");
        }
    }

    return name;
}
 
開發者ID:apache,項目名稱:nifi-registry,代碼行數:21,代碼來源:LdapUserGroupProvider.java

示例2: getValue

import javax.naming.directory.Attribute; //導入方法依賴的package包/類
private String getValue(Attributes answer, String name)
{
	Attribute attr = null;
	if( name != null )
	{
		attr = answer.get(name);
	}

	if( attr == null )
	{
		return "";
	}

	try
	{
		return (String) attr.get();
	}
	catch( NamingException ne )
	{
		return "";
	}
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:23,代碼來源:LDAP.java

示例3: getAttributeValue

import javax.naming.directory.Attribute; //導入方法依賴的package包/類
/**
 * Return a String representing the value of the specified attribute.
 *
 * @param attrId Attribute name
 * @param attrs Attributes containing the required value
 *
 * @exception NamingException if a directory server error occurs
 */
private String getAttributeValue(String attrId, Attributes attrs)
    throws NamingException {

    if (containerLog.isTraceEnabled())
        containerLog.trace("  retrieving attribute " + attrId);

    if (attrId == null || attrs == null)
        return null;

    Attribute attr = attrs.get(attrId);
    if (attr == null)
        return (null);
    Object value = attr.get();
    if (value == null)
        return (null);
    String valueString = null;
    if (value instanceof byte[])
        valueString = new String((byte[]) value);
    else
        valueString = value.toString();

    return valueString;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:32,代碼來源:JNDIRealm.java

示例4: getReferencedGroupValue

import javax.naming.directory.Attribute; //導入方法依賴的package包/類
private String getReferencedGroupValue(final DirContextOperations ctx) {
    final String referencedGroupValue;

    if (StringUtils.isBlank(userGroupReferencedGroupAttribute)) {
        referencedGroupValue = ctx.getDn().toString();
    } else {
        final Attribute attributeName = ctx.getAttributes().get(userGroupReferencedGroupAttribute);
        if (attributeName == null) {
            throw new AuthorizationAccessException("Referenced group value attribute [" + userGroupReferencedGroupAttribute + "] does not exist.");
        }

        try {
            referencedGroupValue = (String) attributeName.get();
        } catch (NamingException e) {
            throw new AuthorizationAccessException("Error while retrieving referenced group value attribute [" + userGroupReferencedGroupAttribute + "].");
        }
    }

    return referencedGroupValue;
}
 
開發者ID:apache,項目名稱:nifi-registry,代碼行數:21,代碼來源:LdapUserGroupProvider.java

示例5: uid2ext

import javax.naming.directory.Attribute; //導入方法依賴的package包/類
public String uid2ext(String uid) {
    try {
        DirContext ctx = null;
        try {
            ctx = getDirContext();
            Attributes attributes = ctx.getAttributes(
            		ApplicationProperties.getProperty("tmtbl.authenticate.ldap.uid2ext").replaceAll("%", uid),
            		new String[] {
            			ApplicationProperties.getProperty("tmtbl.authenticate.ldap.externalId", "puid")
            		});
            if (attributes!=null) {
                Attribute puid = attributes.get(ApplicationProperties.getProperty("tmtbl.authenticate.ldap.externalId", "puid"));
                if (puid!=null) return (String)puid.get();
            }
        } finally {
            if (ctx!=null) ctx.close();
        }
    } catch (Exception e) {
        Debug.error("Unable to translate uid to ext, "+e.getMessage());
    }
    return null;
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:23,代碼來源:LdapExternalUidTranslation.java

示例6: ext2uid

import javax.naming.directory.Attribute; //導入方法依賴的package包/類
public String ext2uid(String puid) {
    try {
        DirContext ctx = null;
        try {
            ctx = getDirContext();
            Attributes attributes = ctx.getAttributes(
            		ApplicationProperties.getProperty("tmtbl.authenticate.ldap.ext2uid").replaceAll("%", puid),
            		new String[] {
            			ApplicationProperties.getProperty("tmtbl.authenticate.ldap.login", "uid")
            		});
            if (attributes!=null) {
                Attribute uid = attributes.get(ApplicationProperties.getProperty("tmtbl.authenticate.ldap.login", "uid"));
                if (uid!=null) return (String)uid.get();
            }
        } finally {
            if (ctx!=null) ctx.close();
        }
    } catch (Exception e) {
        Debug.error("Unable to translate ext to uid, "+e.getMessage());
    }
    return null;
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:23,代碼來源:LdapExternalUidTranslation.java

示例7: Rdn

import javax.naming.directory.Attribute; //導入方法依賴的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 <tt>attrSet</tt> 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:SunburstApps,項目名稱:OpenJSharp,代碼行數:37,代碼來源:Rdn.java

示例8: getAttributeValue

import javax.naming.directory.Attribute; //導入方法依賴的package包/類
/**
 * Return a String representing the value of the specified attribute.
 *
 * @param attrId Attribute name
 * @param attrs Attributes containing the required value
 *
 * @exception NamingException if a directory server error occurs
 */
private String getAttributeValue(String attrId, Attributes attrs)
    throws NamingException {

    if (debug >= 3)
        log("  retrieving attribute " + attrId);

    if (attrId == null || attrs == null)
        return null;

    Attribute attr = attrs.get(attrId);
    if (attr == null)
        return (null);
    Object value = attr.get();
    if (value == null)
        return (null);
    String valueString = null;
    if (value instanceof byte[])
        valueString = new String((byte[]) value);
    else
        valueString = value.toString();
    
    return valueString;
}
 
開發者ID:c-rainstorm,項目名稱:jerrydog,代碼行數:32,代碼來源:JNDIRealm.java

示例9: getAttributeValue

import javax.naming.directory.Attribute; //導入方法依賴的package包/類
/**
 * Return a String representing the value of the specified attribute.
 *
 * @param attrId Attribute name
 * @param attrs Attributes containing the required value
 *
 * @exception NamingException if a directory server error occurs
 */
private String getAttributeValue(String attrId, Attributes attrs)
    throws NamingException {

    if (containerLog.isTraceEnabled())
        containerLog.trace("  retrieving attribute " + attrId);

    if (attrId == null || attrs == null)
        return null;

    Attribute attr = attrs.get(attrId);
    if (attr == null)
        return null;
    Object value = attr.get();
    if (value == null)
        return null;
    String valueString = null;
    if (value instanceof byte[])
        valueString = new String((byte[]) value);
    else
        valueString = value.toString();

    return valueString;
}
 
開發者ID:sunmingshuai,項目名稱:apache-tomcat-7.0.73-with-comment,代碼行數:32,代碼來源:JNDIRealm.java

示例10: getAttributeValue

import javax.naming.directory.Attribute; //導入方法依賴的package包/類
/**
 * Return a String representing the value of the specified attribute.
 *
 * @param attrId
 *            Attribute name
 * @param attrs
 *            Attributes containing the required value
 *
 * @exception NamingException
 *                if a directory server error occurs
 */
private String getAttributeValue(String attrId, Attributes attrs) throws NamingException {

	if (containerLog.isTraceEnabled())
		containerLog.trace("  retrieving attribute " + attrId);

	if (attrId == null || attrs == null)
		return null;

	Attribute attr = attrs.get(attrId);
	if (attr == null)
		return null;
	Object value = attr.get();
	if (value == null)
		return null;
	String valueString = null;
	if (value instanceof byte[])
		valueString = new String((byte[]) value);
	else
		valueString = value.toString();

	return valueString;
}
 
開發者ID:how2j,項目名稱:lazycat,代碼行數:34,代碼來源:JNDIRealm.java

示例11: getUserAttributes

import javax.naming.directory.Attribute; //導入方法依賴的package包/類
public static Map<String, String> getUserAttributes(DirContext ctx, String searchBase, String userName,
    String principalDomain, String... attributeNames)
    throws NamingException {
  if (StringUtils.isBlank(userName)) {
    throw new IllegalArgumentException("Username and password can not be blank.");
  }

  if (attributeNames.length == 0) {
    return Collections.emptyMap();
  }

  Attributes matchAttr = new BasicAttributes(true);
  BasicAttribute basicAttr = new BasicAttribute("userPrincipalName", userName + principalDomain);
  matchAttr.put(basicAttr);

  NamingEnumeration<? extends SearchResult> searchResult = ctx.search(searchBase, matchAttr, attributeNames);

  if (ctx != null) {
    ctx.close();
  }

  Map<String, String> result = new HashMap<>();

  if (searchResult.hasMore()) {
    NamingEnumeration<? extends Attribute> attributes = searchResult.next().getAttributes().getAll();

    while (attributes.hasMore()) {
      Attribute attr = attributes.next();
      String attrId = attr.getID();
      String attrValue = (String) attr.get();

      result.put(attrId, attrValue);
    }
  }
  return result;
}
 
開發者ID:SirAeroWN,項目名稱:premier-wherehows,代碼行數:37,代碼來源:AuthenticationManager.java

示例12: getHeaderField

import javax.naming.directory.Attribute; //導入方法依賴的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

示例13: getSingleAttributeString

import javax.naming.directory.Attribute; //導入方法依賴的package包/類
@Override
   public String getSingleAttributeString(Attribute attr) {
try {
    if (attr != null) {
	Object attrValue = attr.get();
	if (attrValue != null) {
	    return attrValue.toString();
	}
    }
} catch (NamingException e) {
    log.error("===> Naming exception occurred: " + e.getMessage());
}
return null;
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:15,代碼來源:LdapService.java

示例14: convert

import javax.naming.directory.Attribute; //導入方法依賴的package包/類
private String convert(final String attributeName, final Attribute ldapAttribute) {
    try {
        return (String) ldapAttribute.get(0);
    } catch (NullPointerException | NamingException e) {
        LOG.warn("User entry does not include attribute: {}", attributeName);

        throw new IllegalArgumentException("No valid string attribute: " + attributeName);
    }
}
 
開發者ID:klenkes74,項目名稱:openshift-ldapsync,代碼行數:10,代碼來源:LdapUserConverter.java

示例15: getAttributeValue

import javax.naming.directory.Attribute; //導入方法依賴的package包/類
/**
 * Return a String representing the value of the specified attribute.
 *
 * @param attrs  Attributes containing the required value
 * @param attrId Attribute name
 * @throws NamingException if a directory server error occurs
 */
private String getAttributeValue(final Attributes attrs, final String attrId)
        throws NamingException {

  if (StringUtils.isBlank(attrId)) {
    return null;
  }

  if (attrId == null || attrs == null) {
    return null;
  }

  final Attribute attr = attrs.get(attrId);
  if (attr == null) {
    return null;
  }
  final Object value = attr.get();
  if (value == null) {
    return null;
  }
  String valueString = null;
  if (value instanceof byte[]) {
    valueString = new String((byte[]) value);
  } else {
    valueString = value.toString();
  }

  return valueString;
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:36,代碼來源:JNDIAuthenticator.java


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