/** * {@inheritDoc} */ public void unregisterSchemaElements( String schemaName ) throws LdapException { if ( schemaName == null ) { return; } // Loop on all the SchemaObjects stored and remove those associated // with the give schemaName for ( SyntaxChecker syntaxChecker : this ) { if ( schemaName.equalsIgnoreCase( syntaxChecker.getSchemaName() ) ) { String oid = syntaxChecker.getOid(); SchemaObject removed = unregister( oid ); if ( DEBUG ) { LOG.debug( "Removed {} with oid {} from the registry", removed, oid ); } } } }
/** * Attempts to resolve the SyntaxChecker * * @param normalizer the SyntaxChecker * @param errors the list of errors to add exceptions to */ private void resolve( SyntaxChecker syntaxChecker, List<Throwable> errors ) { // This is currently doing nothing. try { syntaxChecker.addToRegistries( errors, this ); } catch ( LdapException e ) { errors.add( e ); } }
/** * Class load a syntaxChecker instance */ private SyntaxChecker classLoadSyntaxChecker( SchemaManager schemaManager, String oid, String className, EntryAttribute byteCode, Registries targetRegistries ) throws Exception { // Try to class load the syntaxChecker Class<?> clazz = null; SyntaxChecker syntaxChecker = null; String byteCodeStr = StringTools.EMPTY; if ( byteCode == null ) { clazz = Class.forName( className ); } else { classLoader.setAttribute( byteCode ); clazz = classLoader.loadClass( className ); byteCodeStr = new String( Base64.encode( byteCode.getBytes() ) ); } // Create the syntaxChecker instance syntaxChecker = ( SyntaxChecker ) clazz.newInstance(); // Update the common fields syntaxChecker.setBytecode( byteCodeStr ); syntaxChecker.setFqcn( className ); // Inject the new OID, as the loaded syntaxChecker might have its own syntaxChecker.setOid( oid ); return syntaxChecker; }
/** * @see Object#equals() */ public boolean equals( Object o ) { if ( !super.equals( o ) ) { return false; } if ( !( o instanceof LdapSyntax ) ) { return false; } LdapSyntax that = ( LdapSyntax ) o; // IsHR if ( isHumanReadable != that.isHumanReadable ) { return false; } // Check the SyntaxChecker (not a equals) return syntaxChecker.getOid().equals( that.syntaxChecker.getOid() ); }
/** * @see BootstrapProducer#produce(Registries, ProducerCallback) */ public void produce( Registries registries, ProducerCallback cb ) throws NamingException { SyntaxChecker checker = null; checker = new NumericOidSyntaxChecker(); cb.schemaObjectProduced( this, checker.getSyntaxOid(), checker ); checker = new ObjectClassTypeSyntaxChecker(); cb.schemaObjectProduced( this, checker.getSyntaxOid(), checker ); checker = new NumberSyntaxChecker(); cb.schemaObjectProduced( this, checker.getSyntaxOid(), checker ); checker = new ObjectNameSyntaxChecker(); cb.schemaObjectProduced( this, checker.getSyntaxOid(), checker ); } }
/** * Asserts whether or not the attribute's value conforms to the attribute * syntax. * * @param value the value of some attribute with the syntax * @throws LdapException if the value does not conform to the attribute syntax. */ public void assertSyntax( Object value ) throws LdapException { if ( !isValidSyntax( value ) ) { throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX ); } }
public ServerEntry getAttributes( SyntaxChecker syntaxChecker, Schema schema, SchemaManager schemaManager ) { ServerEntry entry = new DefaultServerEntry( schemaManager ); entry.put( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, MetaSchemaConstants.META_SYNTAX_CHECKER_OC ); entry.put( MetaSchemaConstants.M_OID_AT, syntaxChecker.getOid() ); entry.put( MetaSchemaConstants.M_FQCN_AT, syntaxChecker.getClass().getName() ); entry.put( SchemaConstants.CREATORS_NAME_AT, schema.getOwner() ); entry.put( SchemaConstants.CREATE_TIMESTAMP_AT, DateUtils.getGeneralizedTime() ); return entry; }
/** * @see org.apache.directory.server.core.schema.bootstrap.BootstrapProducer#produce(BootstrapRegistries, org.apache.directory.server.core.schema.bootstrap.ProducerCallback) */ public void produce( BootstrapRegistries registries, ProducerCallback cb ) throws NamingException { SyntaxChecker syntaxChecker; /* * We are going to need a syntax checker for each and every one of * these syntaxes. However right now we're probably not going to be * turning on syntax checking or are not as interested in it. So we * can put in place simple do nothing syntax checkers - which is really * the binary syntax checker. */ // 1.3.6.1.1.1.0.0 - RFC2307 NIS Netgroup Triple syntaxChecker = new AcceptAllSyntaxChecker( "1.3.6.1.1.1.0.0" ); cb.schemaObjectProduced( this, syntaxChecker.getSyntaxOid(), syntaxChecker ); // 1.3.6.1.1.1.0.1 - RFC2307 Boot Parameter Syntax syntaxChecker = new AcceptAllSyntaxChecker( "1.3.6.1.1.1.0.1" ); cb.schemaObjectProduced( this, syntaxChecker.getSyntaxOid(), syntaxChecker ); } }
/** * Uses the syntaxChecker associated with the attributeType to check if the * value is valid. Repeated calls to this method do not attempt to re-check * the syntax of the wrapped value every time if the wrapped value does not * change. Syntax checks only result on the first check, and when the wrapped * value changes. * * @see ServerValue#isValid() */ public final boolean isValid( SyntaxChecker syntaxChecker ) throws LdapException { if ( syntaxChecker == null ) { String message = I18n.err( I18n.ERR_04139, toString() ); LOG.error( message ); throw new LdapException( message ); } valid = syntaxChecker.isValidSyntax( getReference() ); return valid; }
cb.schemaObjectProduced( this, syntaxChecker.getSyntaxOid(), syntaxChecker ); cb.schemaObjectProduced( this, syntaxChecker.getSyntaxOid(), syntaxChecker ); cb.schemaObjectProduced( this, syntaxChecker.getSyntaxOid(), syntaxChecker ); cb.schemaObjectProduced( this, syntaxChecker.getSyntaxOid(), syntaxChecker ); cb.schemaObjectProduced( this, syntaxChecker.getSyntaxOid(), syntaxChecker ); cb.schemaObjectProduced( this, syntaxChecker.getSyntaxOid(), syntaxChecker ); cb.schemaObjectProduced( this, syntaxChecker.getSyntaxOid(), syntaxChecker ); cb.schemaObjectProduced( this, syntaxChecker.getSyntaxOid(), syntaxChecker ); cb.schemaObjectProduced( this, syntaxChecker.getSyntaxOid(), syntaxChecker ); cb.schemaObjectProduced( this, syntaxChecker.getSyntaxOid(), syntaxChecker ); cb.schemaObjectProduced( this, syntaxChecker.getSyntaxOid(), syntaxChecker ); cb.schemaObjectProduced( this, syntaxChecker.getSyntaxOid(), syntaxChecker ); cb.schemaObjectProduced( this, syntaxChecker.getSyntaxOid(), syntaxChecker ); cb.schemaObjectProduced( this, syntaxChecker.getSyntaxOid(), syntaxChecker ); cb.schemaObjectProduced( this, syntaxChecker.getSyntaxOid(), syntaxChecker );
return attributeType.getSyntax().getSyntaxChecker().isValidSyntax( null );
/** * Uses the syntaxChecker associated with the attributeType to check if the * value is valid. Repeated calls to this method do not attempt to re-check * the syntax of the wrapped value every time if the wrapped value does not * change. Syntax checks only result on the first check, and when the wrapped * value changes. * * @see Value#isValid() */ public final boolean isValid() { if ( valid != null ) { return valid; } if ( attributeType != null ) { valid = attributeType.getSyntax().getSyntaxChecker().isValidSyntax( get() ); } else { valid = false; } return valid; }