本文整理汇总了Java中org.apache.directory.api.ldap.model.entry.Modification类的典型用法代码示例。如果您正苦于以下问题:Java Modification类的具体用法?Java Modification怎么用?Java Modification使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Modification类属于org.apache.directory.api.ldap.model.entry包,在下文中一共展示了Modification类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testCreateServerModification
import org.apache.directory.api.ldap.model.entry.Modification; //导入依赖的package包/类
@Test
public void testCreateServerModification() throws LdapException
{
Attribute attribute = new DefaultAttribute( "cn", cnAT );
attribute.add( "test1", "test2" );
Modification mod = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, attribute );
Modification clone = mod.clone();
attribute.remove( "test2" );
Attribute clonedAttribute = clone.getAttribute();
assertEquals( 1, mod.getAttribute().size() );
assertTrue( mod.getAttribute().contains( "TEST1" ) );
assertEquals( 2, clonedAttribute.size() );
assertTrue( clone.getAttribute().contains( "test1" ) );
assertTrue( clone.getAttribute().contains( "test2" ) );
}
开发者ID:apache,项目名称:directory-ldap-api,代码行数:21,代码来源:SchemaAwareModificationSerializationTest.java
示例2: testCreateServerModification
import org.apache.directory.api.ldap.model.entry.Modification; //导入依赖的package包/类
@Test
public void testCreateServerModification() throws LdapException
{
Attribute attribute = new DefaultAttribute( "cn" );
attribute.add( "test1", "test2" );
Modification mod = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, attribute );
Modification clone = mod.clone();
attribute.remove( "test2" );
Attribute clonedAttribute = clone.getAttribute();
assertEquals( 1, mod.getAttribute().size() );
assertTrue( mod.getAttribute().contains( "test1" ) );
assertEquals( 2, clonedAttribute.size() );
assertTrue( clone.getAttribute().contains( "test1" ) );
assertTrue( clone.getAttribute().contains( "test2" ) );
}
开发者ID:apache,项目名称:directory-ldap-api,代码行数:21,代码来源:ModificationTest.java
示例3: testApplyAddModificationToEntry
import org.apache.directory.api.ldap.model.entry.Modification; //导入依赖的package包/类
/**
* Test a addModification applied to an entry
*/
@Test
public void testApplyAddModificationToEntry() throws LdapException
{
Entry entry = new DefaultEntry();
entry.add( "dc", "apache" );
assertEquals( 1, entry.size() );
Attribute attr = new DefaultAttribute( "cn", "test" );
Modification modification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, attr );
AttributeUtils.applyModification( entry, modification );
assertNotNull( entry.get( "cn" ) );
assertEquals( 2, entry.size() );
assertEquals( attr, entry.get( "cn" ) );
}
开发者ID:apache,项目名称:directory-ldap-api,代码行数:19,代码来源:AttributeUtilsTest.java
示例4: testApplyRemoveModificationFromEntryAttributeNotPresent
import org.apache.directory.api.ldap.model.entry.Modification; //导入依赖的package包/类
/**
* Test the deletion of an attribute into an entry which does not contain the attribute
*/
@Test
public void testApplyRemoveModificationFromEntryAttributeNotPresent() throws LdapException
{
Entry entry = new DefaultEntry();
Attribute dc = new DefaultAttribute( "dc", "apache" );
entry.put( dc );
Attribute cn = new DefaultAttribute( "cn", "test" );
Modification modification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, cn );
AttributeUtils.applyModification( entry, modification );
assertNull( entry.get( "cn" ) );
assertNotNull( entry.get( "dc" ) );
assertEquals( 1, entry.size() );
assertEquals( dc, entry.get( "dc" ) );
}
开发者ID:apache,项目名称:directory-ldap-api,代码行数:23,代码来源:AttributeUtilsTest.java
示例5: testApplyRemoveModificationFromEntryAttributeNotSameValue
import org.apache.directory.api.ldap.model.entry.Modification; //导入依赖的package包/类
/**
* Test the deletion of an attribute into an entry which contains the attribute
* but without the value to be deleted
*/
@Test
public void testApplyRemoveModificationFromEntryAttributeNotSameValue() throws LdapException
{
Entry entry = new DefaultEntry();
Attribute cn = new DefaultAttribute( "cn", "apache" );
entry.put( cn );
Attribute attr = new DefaultAttribute( "cn", "test" );
Modification modification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, attr );
AttributeUtils.applyModification( entry, modification );
assertNotNull( entry.get( "cn" ) );
assertEquals( 1, entry.size() );
assertEquals( cn, entry.get( "cn" ) );
}
开发者ID:apache,项目名称:directory-ldap-api,代码行数:23,代码来源:AttributeUtilsTest.java
示例6: testApplyRemoveModificationFromEntrySameAttributeSameValue
import org.apache.directory.api.ldap.model.entry.Modification; //导入依赖的package包/类
/**
* Test the deletion of an attribute into an entry which contains the attribute.
*
* The entry should not contain the attribute after the operation
*/
@Test
public void testApplyRemoveModificationFromEntrySameAttributeSameValue() throws LdapException
{
Entry entry = new DefaultEntry();
entry.put( "cn", "test" );
Attribute attr = new DefaultAttribute( "cn", "test" );
Modification modification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, attr );
AttributeUtils.applyModification( entry, modification );
assertNull( entry.get( "cn" ) );
assertEquals( 0, entry.size() );
}
开发者ID:apache,项目名称:directory-ldap-api,代码行数:21,代码来源:AttributeUtilsTest.java
示例7: testApplyModifyModificationRemoveAttribute
import org.apache.directory.api.ldap.model.entry.Modification; //导入依赖的package包/类
/**
* Test the removing by modification of an existing attribute in an .
*
* @throws LdapException
*/
@Test
public void testApplyModifyModificationRemoveAttribute() throws LdapException
{
Entry entry = new DefaultEntry();
entry.put( "cn", "test" );
entry.put( "ou", "apache", "acme corp" );
Attribute newOu = new DefaultAttribute( "ou" );
Modification modification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, newOu );
AttributeUtils.applyModification( entry, modification );
assertEquals( 1, entry.size() );
assertNotNull( entry.get( "cn" ) );
assertNull( entry.get( "ou" ) );
}
开发者ID:apache,项目名称:directory-ldap-api,代码行数:24,代码来源:AttributeUtilsTest.java
示例8: testNotEqualDiffModCount
import org.apache.directory.api.ldap.model.entry.Modification; //导入依赖的package包/类
/**
* Test for inequality when only the number of mods are different.
*/
@Test
public void testNotEqualDiffModCount() throws LdapException
{
ModifyRequestImpl req0 = getRequest();
Attribute attr = new DefaultAttribute( "attr3" );
attr.add( "val0" );
attr.add( "val1" );
attr.add( "val2" );
Modification item = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, attr );
req0.addModification( item );
ModifyRequestImpl req1 = getRequest();
assertFalse( req0.equals( req1 ) );
assertFalse( req1.equals( req0 ) );
}
开发者ID:apache,项目名称:directory-ldap-api,代码行数:20,代码来源:ModifyRequestImplTest.java
示例9: testReaderAttrIdCaseInsensitive
import org.apache.directory.api.ldap.model.entry.Modification; //导入依赖的package包/类
private void testReaderAttrIdCaseInsensitive( String ldif ) throws Exception
{
LdifReader reader = new LdifReader();
List<LdifEntry> entries = reader.parseLdif( ldif );
assertNotNull( entries );
reader.close();
LdifEntry entry = entries.get( 0 );
assertTrue( entry.isChangeModify() );
assertEquals( "dc=example,dc=com", entry.getDn().getName() );
List<Modification> mods = entry.getModifications();
assertTrue( mods.size() == 1 );
Attribute attr = mods.get( 0 ).getAttribute();
assertTrue( attr.getId().equals( "administrativerole" ) );
assertEquals( attr.getString(), "accessControlSpecificArea" );
}
开发者ID:apache,项目名称:directory-ldap-api,代码行数:21,代码来源:LdifReaderTest.java
示例10: modify
import org.apache.directory.api.ldap.model.entry.Modification; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public void modify( Dn dn, List<Modification> mods, LogChange log ) throws LdapException
{
if ( mods == null )
{
return;
}
List<Modification> serverModifications = new ArrayList<Modification>( mods.size() );
for ( Modification mod : mods )
{
serverModifications.add( new DefaultModification( directoryService.getSchemaManager(), mod ) );
}
ModifyOperationContext modifyContext = new ModifyOperationContext( this, dn, serverModifications );
modifyContext.setLogChange( log );
OperationManager operationManager = directoryService.getOperationManager();
operationManager.modify( modifyContext );
}
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:25,代码来源:DefaultCoreSession.java
示例11: createContextCsnModList
import org.apache.directory.api.ldap.model.entry.Modification; //导入依赖的package包/类
private void createContextCsnModList() throws LdapException
{
Modification contextCsnMod = new DefaultModification();
contextCsnMod.setOperation( ModificationOperation.REPLACE_ATTRIBUTE );
DefaultAttribute contextCsnAt = new DefaultAttribute( schemaManager
.lookupAttributeTypeRegistry( SchemaConstants.CONTEXT_CSN_AT ) );
contextCsnMod.setAttribute( contextCsnAt );
mods.add( contextCsnMod );
Modification timeStampMod = new DefaultModification();
timeStampMod.setOperation( ModificationOperation.REPLACE_ATTRIBUTE );
DefaultAttribute timeStampAt = new DefaultAttribute( schemaManager
.lookupAttributeTypeRegistry( SchemaConstants.MODIFY_TIMESTAMP_AT ) );
timeStampMod.setAttribute( timeStampAt );
mods.add( timeStampMod );
}
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:19,代码来源:DefaultPartitionNexus.java
示例12: convertToServerModification
import org.apache.directory.api.ldap.model.entry.Modification; //导入依赖的package包/类
/**
*
* Convert a list of ModificationItemImpl to a list of
*
* @param modificationImpls
* @param atRegistry
* @return
* @throws LdapException
*/
public static List<Modification> convertToServerModification( List<ModificationItem> modificationItems,
SchemaManager schemaManager ) throws LdapException
{
if ( modificationItems != null )
{
List<Modification> modifications = new ArrayList<Modification>( modificationItems.size() );
for ( ModificationItem modificationItem : modificationItems )
{
AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( modificationItem
.getAttribute().getID() );
modifications.add( toServerModification( modificationItem, attributeType ) );
}
return modifications;
}
else
{
return null;
}
}
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:31,代码来源:ServerEntryUtils.java
示例13: writeBinaryAttribute
import org.apache.directory.api.ldap.model.entry.Modification; //导入依赖的package包/类
public void writeBinaryAttribute( final String entryDN, final String attributeName, final byte[][] values, final boolean overwrite )
throws ChaiUnavailableException, ChaiOperationException
{
activityPreCheck();
getInputValidator().writeBinaryAttribute( entryDN, attributeName, values, overwrite );
try
{
final ModifyRequest modifyRequest = new ModifyRequestImpl();
modifyRequest.setName( new Dn( entryDN ) );
{
final Modification modification = new DefaultModification();
modification.setOperation( overwrite ? ModificationOperation.REPLACE_ATTRIBUTE : ModificationOperation.ADD_ATTRIBUTE );
modification.setAttribute( new DefaultAttribute( attributeName, values ) );
modifyRequest.addModification( modification );
}
final ModifyResponse response = connection.modify( modifyRequest );
processResponse( response );
}
catch ( LdapException e )
{
throw ChaiOperationException.forErrorMessage( e.getMessage() );
}
}
开发者ID:ldapchai,项目名称:ldapchai,代码行数:25,代码来源:ApacheLdapProviderImpl.java
示例14: writeStringAttribute
import org.apache.directory.api.ldap.model.entry.Modification; //导入依赖的package包/类
public void writeStringAttribute( final String entryDN, final String attributeName, final Set<String> values, final boolean overwrite )
throws ChaiOperationException, ChaiUnavailableException, IllegalStateException
{
activityPreCheck();
getInputValidator().writeStringAttribute( entryDN, attributeName, values, overwrite );
try
{
final ModifyRequest modifyRequest = new ModifyRequestImpl();
modifyRequest.setName( new Dn( entryDN ) );
{
final Modification modification = new DefaultModification();
modification.setOperation( overwrite ? ModificationOperation.REPLACE_ATTRIBUTE : ModificationOperation.ADD_ATTRIBUTE );
modification.setAttribute( new DefaultAttribute( attributeName, values.toArray( new String[values.size()] ) ) );
modifyRequest.addModification( modification );
}
final ModifyResponse response = connection.modify( modifyRequest );
processResponse( response );
}
catch ( LdapException e )
{
throw ChaiOperationException.forErrorMessage( e.getMessage() );
}
}
开发者ID:ldapchai,项目名称:ldapchai,代码行数:25,代码来源:ApacheLdapProviderImpl.java
示例15: addAttributeModification
import org.apache.directory.api.ldap.model.entry.Modification; //导入依赖的package包/类
@Override
protected void addAttributeModification(Dn dn, List<Modification> modifications,
org.apache.directory.api.ldap.model.schema.ObjectClass ldapStructuralObjectClass,
ObjectClass icfObjectClass, Attribute icfAttr, ModificationOperation modOp) {
if (icfAttr.is(OperationalAttributes.LOCK_OUT_NAME)
&& LdapConfiguration.LOCKOUT_STRATEGY_OPENLDAP.equals(getConfiguration().getLockoutStrategy())) {
List<Object> values = icfAttr.getValue();
if (values.size() != 1) {
throw new InvalidAttributeValueException("Unexpected number of values in attribute "+icfAttr);
}
Boolean value = (Boolean)values.get(0);
if (value) {
throw new UnsupportedOperationException("Locking object is not supported (only unlocking is)");
}
modifications.add(
new DefaultModification(modOp, SchemaConstants.PWD_ACCOUNT_LOCKED_TIME_AT)); // no value
} else {
super.addAttributeModification(dn, modifications, ldapStructuralObjectClass, icfObjectClass, icfAttr, modOp);
}
}
开发者ID:Evolveum,项目名称:connector-ldap,代码行数:23,代码来源:LdapConnector.java
示例16: addAttributeModification
import org.apache.directory.api.ldap.model.entry.Modification; //导入依赖的package包/类
protected void addAttributeModification(Dn dn, List<Modification> modifications,
org.apache.directory.api.ldap.model.schema.ObjectClass ldapStructuralObjectClass,
ObjectClass icfObjectClass, Attribute icfAttr, ModificationOperation modOp) {
AbstractSchemaTranslator<C> schemaTranslator = getSchemaTranslator();
AttributeType attributeType = schemaTranslator.toLdapAttribute(ldapStructuralObjectClass, icfAttr.getName());
if (attributeType == null && !configuration.isAllowUnknownAttributes()
&& !ArrayUtils.contains(configuration.getOperationalAttributes(), icfAttr.getName())) {
throw new InvalidAttributeValueException("Unknown attribute "+icfAttr.getName()+" in object class "+icfObjectClass);
}
List<Value<Object>> ldapValues = schemaTranslator.toLdapValues(attributeType, icfAttr.getValue());
if (ldapValues == null || ldapValues.isEmpty()) {
// Do NOT set AttributeType here
modifications.add(new DefaultModification(modOp, attributeType.getName()));
} else {
// Do NOT set AttributeType here
modifications.add(new DefaultModification(modOp, attributeType.getName(), ldapValues.toArray(new Value[ldapValues.size()])));
}
}
开发者ID:Evolveum,项目名称:connector-ldap,代码行数:19,代码来源:AbstractLdapConnector.java
示例17: processModificationsBeforeUpdate
import org.apache.directory.api.ldap.model.entry.Modification; //导入依赖的package包/类
private Modification[] processModificationsBeforeUpdate(List<Modification> modifications) {
Modification[] out = new Modification[modifications.size()];
int i = 0;
for (final Modification modification: modifications) {
if (modification.getAttribute() != null && modification.getAttribute().get() != null) {
Value<?> val = modification.getAttribute().get();
if (val instanceof GuardedStringValue) {
((GuardedStringValue)val).getGuardedStringValue().access(new GuardedString.Accessor() {
@Override
public void access(char[] clearChars) {
DefaultAttribute attr = new DefaultAttribute( modification.getAttribute().getId(), new String(clearChars));
modification.setAttribute(attr);
}
});
}
}
out[i] = modification;
i++;
}
return out;
}
开发者ID:Evolveum,项目名称:connector-ldap,代码行数:22,代码来源:AbstractLdapConnector.java
示例18: dumpModifications
import org.apache.directory.api.ldap.model.entry.Modification; //导入依赖的package包/类
protected String dumpModifications(List<Modification> modifications) {
if (modifications == null) {
return null;
}
StringBuilder sb = new StringBuilder("[");
for (Modification mod: modifications) {
sb.append(mod.getOperation()).append(":");
if (isSensitiveAttribute(mod.getAttribute())) {
sb.append(mod.getAttribute().getUpId()).append("=");
sb.append("..hidden.value..");
} else {
sb.append(mod.getAttribute());
}
sb.append(",");
}
sb.append("]");
return sb.toString();
}
开发者ID:Evolveum,项目名称:connector-ldap,代码行数:19,代码来源:AbstractLdapConnector.java
示例19: loadProperties
import org.apache.directory.api.ldap.model.entry.Modification; //导入依赖的package包/类
/**
* Given a collection of {@link java.util.Properties}, convert to raw data name-value format and load into ldap
* modification set in preparation for ldap modify.
*
* @param props contains {@link java.util.Properties} targeted for updating in ldap.
* @param mods ldap modification set containing name-value pairs in raw ldap format.
* @param attrName contains the name of the ldap attribute to be updated.
* @param replace boolean variable, if set to true use {@link ModificationOperation#REPLACE_ATTRIBUTE} else {@link
* ModificationOperation#ADD_ATTRIBUTE}.
* @param separator contains the char value used to separate name and value in ldap raw format.
*/
protected void loadProperties( Properties props, List<Modification> mods, String attrName, boolean replace,
char separator )
{
if ( props != null && props.size() > 0 )
{
if ( replace )
{
mods.add( new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, attrName ) );
}
for ( Enumeration<?> e = props.propertyNames(); e.hasMoreElements(); )
{
String key = ( String ) e.nextElement();
String val = props.getProperty( key );
// This LDAP attr is stored as a name-value pair separated by a ':'.
mods.add( new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, attrName,
key + separator + val ) );
}
}
}
开发者ID:apache,项目名称:directory-fortress-core,代码行数:32,代码来源:LdapDataProvider.java
示例20: removeProperties
import org.apache.directory.api.ldap.model.entry.Modification; //导入依赖的package包/类
/**
* Given a collection of {@link java.util.Properties}, convert to raw data name-value format and load into ldap
* modification set in preparation for ldap modify.
*
* @param props contains {@link java.util.Properties} targeted for removal from ldap.
* @param mods ldap modification set containing name-value pairs in raw ldap format to be removed.
* @param attrName contains the name of the ldap attribute to be removed.
*/
protected void removeProperties( Properties props, List<Modification> mods, String attrName )
{
if ( props != null && props.size() > 0 )
{
for ( Enumeration<?> e = props.propertyNames(); e.hasMoreElements(); )
{
String key = ( String ) e.nextElement();
String val = props.getProperty( key );
// This LDAP attr is stored as a name-value pair separated by a ':'.
mods.add( new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, attrName,
key + GlobalIds.PROP_SEP + val ) );
}
}
}
开发者ID:apache,项目名称:directory-fortress-core,代码行数:24,代码来源:LdapDataProvider.java
注:本文中的org.apache.directory.api.ldap.model.entry.Modification类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论