本文整理汇总了Java中javax.naming.directory.Attributes.get方法的典型用法代码示例。如果您正苦于以下问题:Java Attributes.get方法的具体用法?Java Attributes.get怎么用?Java Attributes.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.naming.directory.Attributes
的用法示例。
在下文中一共展示了Attributes.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: uid2ext
import javax.naming.directory.Attributes; //导入方法依赖的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;
}
示例2: defineTriggerExecutionSpecificPoint
import javax.naming.directory.Attributes; //导入方法依赖的package包/类
/**
* Defines the Administration point and administrative role for the TriggerExecution specific point
* @param apCtx The administrative point context
* @throws NamingException If the operation failed
*/
public static void defineTriggerExecutionSpecificPoint( LdapContext apCtx ) throws NamingException
{
Attributes ap = apCtx.getAttributes( "", new String[] { SchemaConstants.ADMINISTRATIVE_ROLE_AT } );
Attribute administrativeRole = ap.get( SchemaConstants.ADMINISTRATIVE_ROLE_AT );
if ( administrativeRole == null
|| !AttributeUtils.containsValueCaseIgnore( administrativeRole, SchemaConstants.TRIGGER_EXECUTION_SPECIFIC_AREA ) )
{
Attributes changes = new BasicAttributes( SchemaConstants.ADMINISTRATIVE_ROLE_AT,
SchemaConstants.TRIGGER_EXECUTION_SPECIFIC_AREA, true );
apCtx.modifyAttributes( "", DirContext.ADD_ATTRIBUTE, changes );
}
}
示例3: getAttributeValue
import javax.naming.directory.Attributes; //导入方法依赖的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;
}
示例4: getAttributeValue
import javax.naming.directory.Attributes; //导入方法依赖的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;
}
示例5: getValue
import javax.naming.directory.Attributes; //导入方法依赖的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 "";
}
}
示例6: getAttributeValue
import javax.naming.directory.Attributes; //导入方法依赖的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;
}
示例7: toAttributes
import javax.naming.directory.Attributes; //导入方法依赖的package包/类
Attributes toAttributes() {
Attributes attrs = new BasicAttributes(true);
TypeAndValue tv;
Attribute attr;
for (int i = 0; i < tvs.size(); i++) {
tv = tvs.elementAt(i);
if ((attr = attrs.get(tv.getType())) == null) {
attrs.put(tv.getType(), tv.getUnescapedValue());
} else {
attr.add(tv.getUnescapedValue());
}
}
return attrs;
}
示例8: getAttributeValue
import javax.naming.directory.Attributes; //导入方法依赖的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;
}
示例9: getParentGroupForGroup
import javax.naming.directory.Attributes; //导入方法依赖的package包/类
@Override
public GroupBean getParentGroupForGroup(DirContext ctx, String groupID)
{
LDAPResult groupRes = ldap.getGroupResult(ctx, groupID, ldap.getGroupAttributes());
if( groupRes == null )
{
return null;
}
try
{
Name groupName = groupRes.getFullName();
int sz = groupName.size();
if( sz > 1 )
{
groupName.remove(sz - 1);
Attributes attributes = ctx.getAttributes(groupName);
Attribute attribute = attributes.get(LDAP.OBJECTCLASS);
if( attribute != null && attribute.contains(ldap.getGroupObject()) )
{
return ldap.getGroupBeanFromResult(groupRes);
}
}
}
catch( NamingException e )
{
LOGGER.error(e, e);
}
return null;
}
示例10: addAttributeValues
import javax.naming.directory.Attributes; //导入方法依赖的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;
}
示例11: getValueMap
import javax.naming.directory.Attributes; //导入方法依赖的package包/类
/**
* Get a map containing the values for this request. The first time
* this method is called on an object, the LDAP request is sent,
* the results parsed and added to a private map and also to the
* cache of this LDAPCertStore. Subsequent calls return the private
* map immediately.
*
* The map contains an entry for each requested attribute. The
* attribute name is the key, values are byte[][]. If there are no
* values for that attribute, values are byte[0][].
*
* @return the value Map
* @throws NamingException if a naming exception occurs
*/
private Map<String, byte[][]> getValueMap() throws NamingException {
if (valueMap != null) {
return valueMap;
}
if (DEBUG) {
System.out.println("Request: " + name + ":" + requestedAttributes);
requests++;
if (requests % 5 == 0) {
System.out.println("LDAP requests: " + requests);
}
}
valueMap = new HashMap<>(8);
String[] attrIds = requestedAttributes.toArray(STRING0);
Attributes attrs;
if (communicationError) {
ctx.reconnect(null);
communicationError = false;
}
try {
attrs = ctx.getAttributes(name, attrIds);
} catch (CommunicationException ce) {
communicationError = true;
throw ce;
} catch (NameNotFoundException e) {
// name does not exist on this LDAP server
// treat same as not attributes found
attrs = EMPTY_ATTRIBUTES;
}
for (String attrId : requestedAttributes) {
Attribute attr = attrs.get(attrId);
byte[][] values = getAttributeValues(attr);
cacheAttribute(attrId, values);
valueMap.put(attrId, values);
}
return valueMap;
}
示例12: testLdifParserRFC2849Sample3
import javax.naming.directory.Attributes; //导入方法依赖的package包/类
@Test
public void testLdifParserRFC2849Sample3() throws LdapLdifException, Exception
{
String ldif =
"objectclass: top\n"
+ "objectclass: person\n"
+ "objectclass: organizationalPerson\n"
+ "cn: Gern Jensen\n"
+ "cn: Gern O Jensen\n"
+ "sn: Jensen\n"
+ "uid: gernj\n"
+ "telephonenumber: +1 408 555 1212\n"
+ "description:: V2hhdCBhIGNhcmVmdWwgcmVhZGVyIHlvdSBhcmUhICBUaGlzIHZhbHVl\n"
+ " IGlzIGJhc2UtNjQtZW5jb2RlZCBiZWNhdXNlIGl0IGhhcyBhIGNvbnRyb2wgY2hhcmFjdG\n"
+ " VyIGluIGl0IChhIENSKS4NICBCeSB0aGUgd2F5LCB5b3Ugc2hvdWxkIHJlYWxseSBnZXQg\n"
+ " b3V0IG1vcmUu";
LdifAttributesReader reader = new LdifAttributesReader();
Attributes attributes = reader.parseAttributes( ldif );
javax.naming.directory.Attribute attr = attributes.get( "objectclass" );
assertTrue( attr.contains( "top" ) );
assertTrue( attr.contains( "person" ) );
assertTrue( attr.contains( "organizationalPerson" ) );
attr = attributes.get( "cn" );
assertTrue( attr.contains( "Gern Jensen" ) );
assertTrue( attr.contains( "Gern O Jensen" ) );
attr = attributes.get( "sn" );
assertTrue( attr.contains( "Jensen" ) );
attr = attributes.get( "uid" );
assertTrue( attr.contains( "gernj" ) );
attr = attributes.get( "telephonenumber" );
assertTrue( attr.contains( "+1 408 555 1212" ) );
attr = attributes.get( "description" );
assertTrue( attr
.contains( "What a careful reader you are! This value is base-64-encoded because it has a control character in it (a CR).\r By the way, you should really get out more."
.getBytes( StandardCharsets.UTF_8 ) ) );
reader.close();
}
示例13: testLdifAttributesReaderDirServer
import javax.naming.directory.Attributes; //导入方法依赖的package包/类
@Test
public void testLdifAttributesReaderDirServer() throws NamingException, Exception
{
String ldif =
"# -------------------------------------------------------------------\n"
+ "#\n"
+ "# Licensed to the Apache Software Foundation (ASF) under one\n"
+ "# or more contributor license agreements. See the NOTICE file\n"
+ "# distributed with this work for additional information\n"
+ "# regarding copyright ownership. The ASF licenses this file\n"
+ "# to you under the Apache License, Version 2.0 (the\n"
+ "# \"License\"); you may not use this file except in compliance\n"
+ "# with the License. You may obtain a copy of the License at\n"
+ "# \n"
+ "# http://www.apache.org/licenses/LICENSE-2.0\n"
+ "# \n"
+ "# Unless required by applicable law or agreed to in writing,\n"
+ "# software distributed under the License is distributed on an\n"
+ "# \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n"
+ "# KIND, either express or implied. See the License for the\n"
+ "# specific language governing permissions and limitations\n"
+ "# under the License. \n"
+ "# \n"
+ "#\n"
+ "# EXAMPLE.COM is freely and reserved for testing according to this RFC:\n"
+ "#\n"
+ "# http://www.rfc-editor.org/rfc/rfc2606.txt\n"
+ "#\n"
+ "# -------------------------------------------------------------------\n"
+ "\n"
+ "objectclass: top\n"
+ "objectclass: organizationalunit\n"
+ "ou: Users";
LdifAttributesReader reader = new LdifAttributesReader();
Attributes attributes = reader.parseAttributes( ldif );
javax.naming.directory.Attribute attr = attributes.get( "objectclass" );
assertTrue( attr.contains( "top" ) );
assertTrue( attr.contains( "organizationalunit" ) );
attr = attributes.get( "ou" );
assertTrue( attr.contains( "Users" ) );
reader.close();
}
示例14: testLdifParserCommentsEmptyLines
import javax.naming.directory.Attributes; //导入方法依赖的package包/类
@Test
public void testLdifParserCommentsEmptyLines() throws NamingException, Exception
{
String ldif = "#\n"
+ "# Licensed to the Apache Software Foundation (ASF) under one\n"
+ "# or more contributor license agreements. See the NOTICE file\n"
+ "# distributed with this work for additional information\n"
+ "# regarding copyright ownership. The ASF licenses this file\n"
+ "# to you under the Apache License, Version 2.0 (the\n"
+ "# \"License\"); you may not use this file except in compliance\n"
+ "# with the License. You may obtain a copy of the License at\n"
+ "# \n"
+ "# http://www.apache.org/licenses/LICENSE-2.0\n"
+ "# \n"
+ "# Unless required by applicable law or agreed to in writing,\n"
+ "# software distributed under the License is distributed on an\n"
+ "# \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n"
+ "# KIND, either express or implied. See the License for the\n"
+ "# specific language governing permissions and limitations\n"
+ "# under the License. \n"
+ "# \n"
+ "#\n"
+ "#\n"
+ "# EXAMPLE.COM is freely and reserved for testing according to this RFC:\n"
+ "#\n"
+ "# http://www.rfc-editor.org/rfc/rfc2606.txt\n"
+ "#\n"
+ "#\n"
+ "\n"
+ "#\n"
+ "# This ACI allows brouse access to the root suffix and one level below that to anyone.\n"
+ "# At this level there is nothing critical exposed. Everything that matters is one or\n"
+ "# more levels below this.\n"
+ "#\n"
+ "\n"
+ "objectClass: top\n"
+ "objectClass: subentry\n"
+ "objectClass: accessControlSubentry\n"
+ "subtreeSpecification: { maximum 1 }\n"
+ "prescriptiveACI: { identificationTag \"browseRoot\", precedence 100, authenticationLevel none, itemOrUserFirst userFirst: { userClasses { allUsers }, userPermissions { { protectedItems {entry}, grantsAndDenials { grantReturnDN, grantBrowse } } } } }\n";
LdifAttributesReader reader = new LdifAttributesReader();
Attributes attributes = reader.parseAttributes( ldif );
javax.naming.directory.Attribute attr = attributes.get( "objectClass" );
assertTrue( attr.contains( "top" ) );
assertTrue( attr.contains( SchemaConstants.SUBENTRY_OC ) );
assertTrue( attr.contains( "accessControlSubentry" ) );
attr = attributes.get( "subtreeSpecification" );
assertTrue( attr.contains( "{ maximum 1 }" ) );
attr = attributes.get( "prescriptiveACI" );
assertTrue( attr
.contains( "{ identificationTag \"browseRoot\", precedence 100, authenticationLevel none, itemOrUserFirst userFirst: { userClasses { allUsers }, userPermissions { { protectedItems {entry}, grantsAndDenials { grantReturnDN, grantBrowse } } } } }" ) );
reader.close();
}
示例15: mapToNode
import javax.naming.directory.Attributes; //导入方法依赖的package包/类
private NodeDescription mapToNode(Map<String, String> attributeMapping, Map<String, String> attributeDefaults,
SearchResult result) throws NamingException
{
NodeDescription nodeDescription = new NodeDescription(result.getNameInNamespace());
Attributes ldapAttributes = result.getAttributes();
// Parse the timestamp
Attribute modifyTimestamp = ldapAttributes.get(this.modifyTimestampAttributeName);
if (modifyTimestamp != null)
{
try
{
nodeDescription.setLastModified(this.timestampFormat.parse(modifyTimestamp.get().toString()));
}
catch (ParseException e)
{
throw new AlfrescoRuntimeException("Failed to parse timestamp.", e);
}
}
// Apply the mapped attributes
PropertyMap properties = nodeDescription.getProperties();
for (String key : attributeMapping.keySet())
{
QName keyQName = QName.createQName(key, this.namespaceService);
// cater for null
String attributeName = attributeMapping.get(key);
if (attributeName != null)
{
Attribute attribute = ldapAttributes.get(attributeName);
String defaultAttribute = attributeDefaults.get(key);
if (attribute != null)
{
String value = (String) attribute.get(0);
if (value != null)
{
properties.put(keyQName, value);
}
}
else if (defaultAttribute != null)
{
properties.put(keyQName, defaultAttribute);
}
else
{
// Make sure that a 2nd sync, updates deleted ldap attributes(MNT-14026)
properties.put(keyQName, null);
}
}
else
{
String defaultValue = attributeDefaults.get(key);
if (defaultValue != null)
{
properties.put(keyQName, defaultValue);
}
}
}
return nodeDescription;
}