本文整理汇总了Java中org.apache.directory.api.ldap.model.entry.Attribute.getAttributeType方法的典型用法代码示例。如果您正苦于以下问题:Java Attribute.getAttributeType方法的具体用法?Java Attribute.getAttributeType怎么用?Java Attribute.getAttributeType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.directory.api.ldap.model.entry.Attribute
的用法示例。
在下文中一共展示了Attribute.getAttributeType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: anonymize
import org.apache.directory.api.ldap.model.entry.Attribute; //导入方法依赖的package包/类
/**
* Anonymize an attribute using pure random values (either chars of bytes, depending on the Attribute type)
*/
@Override
public Attribute anonymize( Map<Value, Value> valueMap, Set<Value> valueSet, Attribute attribute )
{
Attribute result = new DefaultAttribute( attribute.getAttributeType() );
for ( Value value : attribute )
{
byte[] bytesValue = value.getBytes();
byte[] newValue = computeNewValue( bytesValue );
try
{
result.add( newValue );
Value anonValue = new Value( attribute.getAttributeType(), newValue );
valueMap.put( ( Value ) value, anonValue );
valueSet.add( anonValue );
}
catch ( LdapInvalidAttributeValueException e )
{
throw new RuntimeException( "Error while anonymizing the value" + value );
}
}
return result;
}
示例2: anonymizeChangeAdd
import org.apache.directory.api.ldap.model.entry.Attribute; //导入方法依赖的package包/类
/**
* Anonymize a Add change
*/
private LdifEntry anonymizeChangeAdd( LdifEntry ldifEntry ) throws LdapException
{
Dn entryDn = ldifEntry.getDn();
LdifEntry newLdifEntry = new LdifEntry( schemaManager );
newLdifEntry.setChangeType( ChangeType.Add );
// Process the DN first
Dn anonymizedDn = anonymizeDn( entryDn );
newLdifEntry.setDn( anonymizedDn );
// Now, process the entry's attributes
for ( Attribute attribute : ldifEntry )
{
AttributeType attributeType = attribute.getAttributeType();
Attribute anonymizedAttribute = new DefaultAttribute( attributeType );
// Deal with the special case of a DN syntax
if ( attributeType.getSyntax().getSyntaxChecker() instanceof DnSyntaxChecker )
{
for ( Value dnValue : attribute )
{
Dn dn = new Dn( schemaManager, dnValue.getValue() );
Dn newdDn = anonymizeDn( dn );
anonymizedAttribute.add( newdDn.toString() );
}
newLdifEntry.addAttribute( attribute );
}
else
{
Anonymizer anonymizer = attributeAnonymizers.get( attribute.getAttributeType().getOid() );
if ( anonymizer == null )
{
newLdifEntry.addAttribute( attribute );
}
else
{
anonymizedAttribute = anonymizer.anonymize( valueMap, valueSet, attribute );
if ( anonymizedAttribute != null )
{
newLdifEntry.addAttribute( anonymizedAttribute );
}
}
}
}
return newLdifEntry;
}