/** * Matches the equals character. * * @param name the name * @param pos the pos * * @throws LdapInvalidDnException the invalid name exception */ private static void matchEquals( char[] name, Position pos ) throws LdapInvalidDnException { char c = nextChar( name, pos, true ); if ( c != '=' ) { throw new LdapInvalidDnException( ResultCodeEnum.INVALID_DN_SYNTAX, I18n.err( I18n.ERR_13609_EQUAL_EXPECTED, c, pos.start ) ); } }
/** * Matches the equals character. * * @param name the name * @param pos the pos * * @throws LdapInvalidDnException the invalid name exception */ private static void matchEquals( char[] name, Position pos ) throws LdapInvalidDnException { char c = nextChar( name, pos, true ); if ( c != '=' ) { throw new LdapInvalidDnException( ResultCodeEnum.INVALID_DN_SYNTAX, I18n.err( I18n.ERR_13609_EQUAL_EXPECTED, c, pos.start ) ); } }
/** * Matches the equals character. * * @param name the name * @param pos the pos * * @throws LdapInvalidDnException the invalid name exception */ private static void matchEquals( char[] name, Position pos ) throws LdapInvalidDnException { char c = nextChar( name, pos, true ); if ( c != '=' ) { throw new LdapInvalidDnException( ResultCodeEnum.INVALID_DN_SYNTAX, I18n.err( I18n.ERR_13609_EQUAL_EXPECTED, c, pos.start ) ); } }
/** * Parses an Dn. * * @param schemaManager The SchemaManager * @param name the string representation of the distinguished name * @param rdns the (empty) list where parsed RDNs are put to * @return The normalized Dn * * @throws LdapInvalidDnException the invalid name exception */ /* No protection*/String parseDn( SchemaManager schemaManager, String name, List<Rdn> rdns ) throws LdapInvalidDnException { AntlrDnParser dnParser = new AntlrDnParser( new AntlrDnLexer( new StringReader( name ) ) ); try { return dnParser.relativeDistinguishedNames( schemaManager, rdns ); } catch ( Exception e ) { throw new LdapInvalidDnException( ResultCodeEnum.INVALID_DN_SYNTAX, e.getMessage(), e ); } }
/** * Parses an Rdn. * * @param schemaManager The SchemaManager * @param name the string representation of the relative distinguished name * @param rdn the (empty) Rdn where parsed ATAVs are put into * * @throws LdapInvalidDnException the invalid name exception */ /* No protection*/void parseRdn( SchemaManager schemaManager, String name, Rdn rdn ) throws LdapInvalidDnException { AntlrDnParser dnParser = new AntlrDnParser( new AntlrDnLexer( new StringReader( name ) ) ); try { dnParser.relativeDistinguishedName( schemaManager, rdn ); } catch ( Exception e ) { throw new LdapInvalidDnException( ResultCodeEnum.INVALID_DN_SYNTAX, e.getMessage(), e ); } } }
/** * Parses an Rdn. * * @param schemaManager The SchemaManager * @param name the string representation of the relative distinguished name * @param rdn the (empty) Rdn where parsed ATAVs are put into * * @throws LdapInvalidDnException the invalid name exception */ /* No protection*/void parseRdn( SchemaManager schemaManager, String name, Rdn rdn ) throws LdapInvalidDnException { AntlrDnParser dnParser = new AntlrDnParser( new AntlrDnLexer( new StringReader( name ) ) ); try { dnParser.relativeDistinguishedName( schemaManager, rdn ); } catch ( Exception e ) { throw new LdapInvalidDnException( ResultCodeEnum.INVALID_DN_SYNTAX, e.getMessage(), e ); } } }
/** * Parses an Dn. * * @param schemaManager The SchemaManager * @param name the string representation of the distinguished name * @param rdns the (empty) list where parsed RDNs are put to * @return The normalized Dn * * @throws LdapInvalidDnException the invalid name exception */ /* No protection*/String parseDn( SchemaManager schemaManager, String name, List<Rdn> rdns ) throws LdapInvalidDnException { AntlrDnParser dnParser = new AntlrDnParser( new AntlrDnLexer( new StringReader( name ) ) ); try { return dnParser.relativeDistinguishedNames( schemaManager, rdns ); } catch ( Exception e ) { throw new LdapInvalidDnException( ResultCodeEnum.INVALID_DN_SYNTAX, e.getMessage(), e ); } }
/** * Gets the next character. * * @param name the name * @param pos the pos * @param increment true to increment the position * * @return the character * @throws LdapInvalidDnException If no more characters are available */ private static char nextChar( char[] name, Position pos, boolean increment ) throws LdapInvalidDnException { if ( !hasMoreChars( pos ) ) { throw new LdapInvalidDnException( ResultCodeEnum.INVALID_DN_SYNTAX, I18n.err( I18n.ERR_13610_NO_MORE_CHAR_AVAILABLE, pos.start ) ); } char c = name[pos.start]; if ( increment ) { pos.start++; } return c; }
/** * Parses an Dn. * * @param schemaManager The SchemaManager * @param name the string representation of the distinguished name * @param rdns the (empty) list where parsed RDNs are put to * @return The normalized Dn * * @throws LdapInvalidDnException the invalid name exception */ /* No protection*/String parseDn( SchemaManager schemaManager, String name, List<Rdn> rdns ) throws LdapInvalidDnException { AntlrDnParser dnParser = new AntlrDnParser( new AntlrDnLexer( new StringReader( name ) ) ); try { return dnParser.relativeDistinguishedNames( schemaManager, rdns ); } catch ( Exception e ) { throw new LdapInvalidDnException( ResultCodeEnum.INVALID_DN_SYNTAX, e.getMessage(), e ); } }
/** * Parses an Rdn. * * @param schemaManager The SchemaManager * @param name the string representation of the relative distinguished name * @param rdn the (empty) Rdn where parsed ATAVs are put into * * @throws LdapInvalidDnException the invalid name exception */ /* No protection*/void parseRdn( SchemaManager schemaManager, String name, Rdn rdn ) throws LdapInvalidDnException { AntlrDnParser dnParser = new AntlrDnParser( new AntlrDnLexer( new StringReader( name ) ) ); try { dnParser.relativeDistinguishedName( schemaManager, rdn ); } catch ( Exception e ) { throw new LdapInvalidDnException( ResultCodeEnum.INVALID_DN_SYNTAX, e.getMessage(), e ); } } }
private void checkNewParent( Dn newParent ) throws LdapException { if ( newParent.size() != 3 ) { throw new LdapInvalidDnException( ResultCodeEnum.NAMING_VIOLATION, I18n.err( I18n.ERR_402 ) ); } Rdn rdn = newParent.getRdn(); if ( !schemaManager.getAttributeTypeRegistry().getOidByName( rdn.getNormType() ).equals( SchemaConstants.OU_AT_OID ) ) { throw new LdapInvalidDnException( ResultCodeEnum.NAMING_VIOLATION, I18n.err( I18n.ERR_403 ) ); } if ( !rdn.getValue().equalsIgnoreCase( SchemaConstants.SYNTAXES ) ) { throw new LdapInvalidDnException( ResultCodeEnum.NAMING_VIOLATION, I18n.err( I18n.ERR_363 ) ); } } }
/** * Parses the given name string and fills the given Rdn object. * * @param schemaManager The SchemaManager * @param name the name to parse * @param rdn the Rdn to fill * * @throws LdapInvalidDnException the invalid name exception */ /* No protection*/static void parseRdn( SchemaManager schemaManager, String name, Rdn rdn ) throws LdapInvalidDnException { if ( Strings.isEmpty( name ) ) { throw new LdapInvalidDnException( ResultCodeEnum.INVALID_DN_SYNTAX, I18n.err( I18n.ERR_13602_RDN_EMPTY ) ); } if ( rdn == null ) { throw new LdapInvalidDnException( ResultCodeEnum.INVALID_DN_SYNTAX, I18n.err( I18n.ERR_13603_NULL_RDN ) ); } Position pos = new Position(); pos.start = 0; pos.length = name.length(); StringBuilder sb = new StringBuilder(); parseRdnInternal( schemaManager, name, pos, rdn ); sb.append( rdn.getNormName() ); }
/** * Parses the given name string and fills the given Rdn object. * * @param schemaManager The SchemaManager * @param name the name to parse * @param rdn the Rdn to fill * * @throws LdapInvalidDnException the invalid name exception */ /* No protection*/static void parseRdn( SchemaManager schemaManager, String name, Rdn rdn ) throws LdapInvalidDnException { if ( Strings.isEmpty( name ) ) { throw new LdapInvalidDnException( ResultCodeEnum.INVALID_DN_SYNTAX, I18n.err( I18n.ERR_13602_RDN_EMPTY ) ); } if ( rdn == null ) { throw new LdapInvalidDnException( ResultCodeEnum.INVALID_DN_SYNTAX, I18n.err( I18n.ERR_13603_NULL_RDN ) ); } Position pos = new Position(); pos.start = 0; pos.length = name.length(); StringBuilder sb = new StringBuilder(); parseRdnInternal( schemaManager, name, pos, rdn ); sb.append( rdn.getNormName() ); }
private void checkNewParent( Dn newParent ) throws LdapException { if ( newParent.size() != 3 ) { throw new LdapInvalidDnException( ResultCodeEnum.NAMING_VIOLATION, I18n.err( I18n.ERR_370 ) ); } Rdn rdn = newParent.getRdn(); if ( !schemaManager.getAttributeTypeRegistry().getOidByName( rdn.getNormType() ).equals( SchemaConstants.OU_AT_OID ) ) { throw new LdapInvalidDnException( ResultCodeEnum.NAMING_VIOLATION, I18n.err( I18n.ERR_371 ) ); } if ( !rdn.getValue().equalsIgnoreCase( SchemaConstants.NORMALIZERS_AT ) ) { throw new LdapInvalidDnException( ResultCodeEnum.NAMING_VIOLATION, I18n.err( I18n.ERR_372 ) ); } } }
private void checkNewParent( Dn newParent ) throws LdapException { if ( newParent.size() != 3 ) { throw new LdapInvalidDnException( ResultCodeEnum.NAMING_VIOLATION, "The parent dn of a objectClass should be at most 3 name components in length." ); } Rdn rdn = newParent.getRdn(); if ( !schemaManager.getAttributeTypeRegistry().getOidByName( rdn.getNormType() ).equals( SchemaConstants.OU_AT_OID ) ) { throw new LdapInvalidDnException( ResultCodeEnum.NAMING_VIOLATION, I18n.err( I18n.ERR_376 ) ); } if ( !rdn.getValue().equalsIgnoreCase( SchemaConstants.OBJECT_CLASSES_AT ) ) { throw new LdapInvalidDnException( ResultCodeEnum.NAMING_VIOLATION, I18n.err( I18n.ERR_377 ) ); } } }
/** * Checks that the parent Dn is a valid Dn * * @param newParent The parent DN to check * @param schemaManager The SchemaManager instance * @param objectType The ObjectType to check * @throws LdapException If the deletion failed */ protected void checkParent( Dn newParent, SchemaManager schemaManager, String objectType ) throws LdapException { if ( newParent.size() != 3 ) { throw new LdapInvalidDnException( ResultCodeEnum.NAMING_VIOLATION, I18n.err( I18n.ERR_337 ) ); } Rdn rdn = newParent.getRdn(); if ( !schemaManager.getAttributeTypeRegistry().getOidByName( rdn.getNormType() ) .equals( SchemaConstants.OU_AT_OID ) ) { throw new LdapInvalidDnException( ResultCodeEnum.NAMING_VIOLATION, I18n.err( I18n.ERR_338, objectType ) ); } if ( !rdn.getValue().equalsIgnoreCase( OBJECT_TYPE_TO_PATH.get( objectType ) ) ) { throw new LdapInvalidDnException( ResultCodeEnum.NAMING_VIOLATION, I18n.err( I18n.ERR_339, objectType, OBJECT_TYPE_TO_PATH.get( objectType ) ) ); } }
private void checkNewParent( Dn newParent ) throws LdapException { if ( newParent.size() != 3 ) { throw new LdapInvalidDnException( ResultCodeEnum.NAMING_VIOLATION, I18n.err( I18n.ERR_357 ) ); } Rdn rdn = newParent.getRdn(); if ( !schemaManager.getAttributeTypeRegistry().getOidByName( rdn.getNormType() ).equals( SchemaConstants.OU_AT_OID ) ) { throw new LdapInvalidDnException( ResultCodeEnum.NAMING_VIOLATION, I18n.err( I18n.ERR_358 ) ); } if ( !rdn.getValue().equalsIgnoreCase( SchemaConstants.COMPARATORS_AT ) ) { throw new LdapInvalidDnException( ResultCodeEnum.NAMING_VIOLATION, I18n.err( I18n.ERR_359 ) ); } } }
private void checkNewParent( Dn newParent ) throws LdapException { if ( newParent.size() != 3 ) { throw new LdapInvalidDnException( ResultCodeEnum.NAMING_VIOLATION, I18n.err( I18n.ERR_361 ) ); } Rdn rdn = newParent.getRdn(); if ( !schemaManager.getAttributeTypeRegistry().getOidByName( rdn.getNormType() ).equals( SchemaConstants.OU_AT_OID ) ) { throw new LdapInvalidDnException( ResultCodeEnum.NAMING_VIOLATION, I18n.err( I18n.ERR_362 ) ); } if ( !rdn.getValue().equalsIgnoreCase( SchemaConstants.MATCHING_RULES_AT ) ) { throw new LdapInvalidDnException( ResultCodeEnum.NAMING_VIOLATION, I18n.err( I18n.ERR_363 ) ); } } }
private void checkNewParent( Dn newParent ) throws LdapException { if ( newParent.size() != 3 ) { throw new LdapInvalidDnException( ResultCodeEnum.NAMING_VIOLATION, I18n.err( I18n.ERR_396 ) ); } Rdn rdn = newParent.getRdn(); if ( !schemaManager.getAttributeTypeRegistry().getOidByName( rdn.getNormType() ).equals( SchemaConstants.OU_AT_OID ) ) { throw new LdapInvalidDnException( ResultCodeEnum.NAMING_VIOLATION, I18n.err( I18n.ERR_397 ) ); } if ( !rdn.getValue().equalsIgnoreCase( SchemaConstants.SYNTAX_CHECKERS_AT ) ) { throw new LdapInvalidDnException( ResultCodeEnum.NAMING_VIOLATION, I18n.err( I18n.ERR_372 ) ); } } }
/** * Exctract the schema name from the Dn. It is supposed to be the * second Rdn in the dn : * <pre> * ou=schema, cn=MySchema, ... * </pre> * Here, the schemaName is MySchema * * @param dn The Dn we want to get the schema name from * @return The schema name * @throws LdapException If we got an error */ protected String getSchemaName( Dn dn ) throws LdapException { int size = dn.size(); if ( size < 2 ) { throw new LdapInvalidDnException( I18n.err( I18n.ERR_276 ) ); } Rdn rdn = dn.getRdn( size - 2 ); return Strings.trim( rdn.getAva().getValue().getNormalized() ); }