当前位置: 首页>>代码示例>>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;未经允许,请勿转载。