private boolean hasPrescriptiveACI( Attributes entry ) throws NamingException { // only do something if the entry contains prescriptiveACI Attribute aci = entry.get( ACI_ATTR ); if ( aci == null ) { if ( AttributeUtils.containsValueCaseIgnore( entry.get( OC_ATTR ), ACSUBENTRY_OC ) ) { // should not be necessary because of schema interceptor but schema checking // can be turned off and in this case we must protect against being able to // add access control information to anything other than an AC subentry throw new LdapSchemaViolationException( "", ResultCodeEnum.OBJECTCLASSVIOLATION ); } else { return false; } } return true; }
/** * Creates a new instance of LdapSchemaViolationException. * * @param resultCode the ResultCodeEnum for this exception * @param message The exception message */ public LdapSchemaViolationException( ResultCodeEnum resultCode, String message ) { super( message ); checkResultCode( resultCode ); this.resultCode = resultCode; }
/** * Check that the attribute does not contain collective attributes if it does not * have the collectiveAttributeSubentry ObjectClass declared * * @param normName The entry DN * @param entry The entry attributes * @throws LdapSchemaViolationException * @throws NamingException */ public void checkAdd( LdapDN normName, Attributes entry ) throws LdapSchemaViolationException, NamingException { Attribute objectClass = entry.get( "objectClass" ); // If the objectclass contains "collectiveAttributeSubentry", then we don't have to // check for the existence on collectivbe attributes : it's already allowed if ( AttributeUtils.containsValueCaseIgnore( objectClass, "collectiveAttributeSubentry" ) ) { return; } else if ( containsAnyCollectiveAttributes( entry ) ) { // We have some collective attributes, which is not allowed throw new LdapSchemaViolationException( "Collective attributes cannot be stored in non-collectiveAttributeSubentries", ResultCodeEnum.OBJECTCLASSVIOLATION ); } }
/** * Creates a new instance of LdapSchemaViolationException. * * @param resultCode the ResultCodeEnum for this exception */ public LdapSchemaViolationException( ResultCodeEnum resultCode ) { super( null ); checkResultCode( resultCode ); this.resultCode = resultCode; }
throw new LdapSchemaViolationException( msg, ResultCodeEnum.OBJECTCLASSMODSPROHIBITED ); throw new LdapSchemaViolationException( msg, ResultCodeEnum.OBJECTCLASSMODSPROHIBITED );
/** * Unlink the SchemaObject references */ public void removeReference( List<Throwable> errors, SchemaObject schemaObject ) { try { schemaObject.removeFromRegistries( errors, this ); } catch ( LdapException ne ) { // Not allowed. String msg = I18n.err( I18n.ERR_04293, schemaObject.getName(), ne.getLocalizedMessage() ); Throwable error = new LdapSchemaViolationException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, msg ); errors.add( error ); LOG.info( msg ); } }
throw new LdapSchemaViolationException( msg, ResultCodeEnum.NOTALLOWEDONRDN ); throw new LdapSchemaViolationException( msg, ResultCodeEnum.NOTALLOWEDONRDN );
private int getSubentryTypes( Attributes subentry ) throws NamingException { int types = 0; Attribute oc = subentry.get( "objectClass" ); if ( oc == null ) { throw new LdapSchemaViolationException( "A subentry must have an objectClass attribute", ResultCodeEnum.OBJECTCLASSVIOLATION ); } if ( AttributeUtils.containsValueCaseIgnore( oc, "accessControlSubentry" ) ) { types |= Subentry.ACCESS_CONTROL_SUBENTRY; } if ( AttributeUtils.containsValueCaseIgnore( oc, "subschema" ) ) { types |= Subentry.SCHEMA_SUBENTRY; } if ( AttributeUtils.containsValueCaseIgnore( oc, "collectiveAttributeSubentry" ) ) { types |= Subentry.COLLECTIVE_SUBENTRY; } return types; }
throw new LdapSchemaViolationException( msg, ResultCodeEnum.OBJECTCLASSMODSPROHIBITED ); throw new LdapSchemaViolationException( msg, ResultCodeEnum.OBJECTCLASSMODSPROHIBITED );
/** * Checks to see the presence of all required attributes within an entry. */ private void assertRequiredAttributesPresent( LdapDN dn, Attributes entry, Set must ) throws NamingException { NamingEnumeration attributes = entry.getAll(); while ( attributes.hasMoreElements() && ( must.size() > 0 ) ) { Attribute attribute = ( Attribute ) attributes.nextElement(); String oid = globalRegistries.getOidRegistry().getOid( attribute.getID() ); must.remove( oid ); } if ( must.size() != 0 ) { throw new LdapSchemaViolationException( "Required attributes " + must + " not found within entry " + dn.getUpName(), ResultCodeEnum.OBJECTCLASSVIOLATION ); } }
throw new LdapSchemaViolationException( msg, ResultCodeEnum.NOTALLOWEDONRDN ); throw new LdapSchemaViolationException( msg, ResultCodeEnum.NOTALLOWEDONRDN );
throw new LdapSchemaViolationException( msg, ResultCodeEnum.NOTALLOWEDONRDN ); throw new LdapSchemaViolationException( msg, ResultCodeEnum.NOTALLOWEDONRDN );
public void checkModify( LdapDN normName, ModificationItemImpl[] mods ) throws NamingException { Attributes originalEntry = nexus.lookup( normName ); Attributes targetEntry = SchemaUtils.getTargetEntry( mods, originalEntry ); Attribute targetObjectClasses = targetEntry.get( "objectClass" ); if ( AttributeUtils.containsValueCaseIgnore( targetObjectClasses, "collectiveAttributeSubentry" ) ) { return; } if ( addsAnyCollectiveAttributes( mods ) ) { /* * TODO: Replace the Exception and the ResultCodeEnum with the correct ones. */ throw new LdapSchemaViolationException( "Cannot operate on collective attributes in non-collectiveAttributeSubentries", ResultCodeEnum.OTHER); } }
throw new LdapSchemaViolationException( msg, ResultCodeEnum.OBJECTCLASSMODSPROHIBITED ); throw new LdapSchemaViolationException( msg, ResultCodeEnum.OBJECTCLASSMODSPROHIBITED );
throw new LdapSchemaViolationException( msg, ResultCodeEnum.NOTALLOWEDONRDN ); throw new LdapSchemaViolationException( msg, ResultCodeEnum.NOTALLOWEDONRDN );
throw new LdapSchemaViolationException( msg, ResultCodeEnum.OBJECTCLASSMODSPROHIBITED ); throw new LdapSchemaViolationException( msg, ResultCodeEnum.OBJECTCLASSMODSPROHIBITED );
Throwable error = new LdapSchemaViolationException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_04295, matchingRule.getOid() ) ); errors.add( error ); Throwable error = new LdapSchemaViolationException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_04296, matchingRule.getOid() ) ); errors.add( error );
Throwable error = new LdapSchemaViolationException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, msg ); errors.add( error ); LOG.info( msg );
Throwable error = new LdapSchemaViolationException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_04297, attributeType.getOid() ) ); errors.add( error ); Throwable error = new LdapSchemaViolationException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_04298, attributeType.getOid() ) ); errors.add( error );
Throwable error = new LdapSchemaViolationException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, msg ); errors.add( error ); LOG.info( msg );