/** * Read the configuration from the DIT, returning a bean containing all of it. * <p> * This method implicitly uses <em>"ou=config"</em> as base Dn * * @return The Config bean, containing the whole configuration * @throws ConfigurationException If we had some issue reading the configuration */ public ConfigBean readConfig() throws LdapException { // The starting point is the DirectoryService element return readConfig( new Dn( new Rdn( SchemaConstants.OU_AT, "config" ) ) ); }
/** * Validate a NameComponent : <br> * <p> * <name-component> ::= <attributeType> <spaces> '=' * <spaces> <attributeValue> <nameComponents> * </p> * * @param dn The string to parse * @return <code>true</code> if the Rdn is valid */ public static boolean isValid( String dn ) { Rdn rdn = new Rdn(); try { parse( null, dn, rdn ); return true; } catch ( LdapInvalidDnException e ) { return false; } }
/** * Construct an empty Schema aware Dn object * * @param schemaManager The SchemaManager to use * @param dn The Dn to use * @throws LdapInvalidDnException If the Dn is invalid */ public Dn( SchemaManager schemaManager, Dn dn ) throws LdapInvalidDnException { this.schemaManager = schemaManager; if ( dn == null ) { return; } for ( Rdn rdn : dn.rdns ) { this.rdns.add( new Rdn( schemaManager, rdn ) ); } toUpName(); }
/** * Construct an empty Schema aware Dn object * * @param schemaManager The SchemaManager to use * @param dn The Dn to use * @throws LdapInvalidDnException If the Dn is invalid */ public Dn( SchemaManager schemaManager, Dn dn ) throws LdapInvalidDnException { this.schemaManager = schemaManager; if ( dn == null ) { return; } for ( Rdn rdn : dn.rdns ) { this.rdns.add( new Rdn( schemaManager, rdn ) ); } toUpName(); }
/** * Construct an empty Schema aware Dn object * * @param schemaManager The SchemaManager to use * @param dn The Dn to use * @throws LdapInvalidDnException If the Dn is invalid */ public Dn( SchemaManager schemaManager, Dn dn ) throws LdapInvalidDnException { this.schemaManager = schemaManager; if ( dn == null ) { return; } for ( Rdn rdn : dn.rdns ) { this.rdns.add( new Rdn( schemaManager, rdn ) ); } toUpName(); }
/** * Validate a NameComponent : <br> * <p> * <name-component> ::= <attributeType> <spaces> '=' * <spaces> <attributeValue> <nameComponents> * </p> * * @param schemaManager The Schemamanager to use * @param dn The string to parse * @return <code>true</code> if the Rdn is valid */ public static boolean isValid( SchemaManager schemaManager, String dn ) { Rdn rdn = new Rdn( schemaManager ); try { parse( schemaManager, dn, rdn ); return true; } catch ( LdapInvalidDnException e ) { return false; } }
/** * Validate a NameComponent : <br> * <p> * <name-component> ::= <attributeType> <spaces> '=' * <spaces> <attributeValue> <nameComponents> * </p> * * @param dn The string to parse * @return <code>true</code> if the Rdn is valid */ public static boolean isValid( String dn ) { Rdn rdn = new Rdn(); try { parse( null, dn, rdn ); return true; } catch ( LdapInvalidDnException e ) { return false; } }
/** * {@inheritDoc} */ @Override public void rename( String entryDn, String newRdn, boolean deleteOldRdn ) throws LdapException { rename( new Dn( schemaManager, entryDn ), new Rdn( newRdn ), deleteOldRdn ); }
/** * {@inheritDoc} */ @Override public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException { // Read the UPName upName = in.readUTF(); // Read the RDNs. Is it's null, the number will be -1. int nbRdns = in.readInt(); rdns = new ArrayList<>( nbRdns ); for ( int i = 0; i < nbRdns; i++ ) { Rdn rdn = new Rdn( schemaManager ); rdn.readExternal( in ); rdns.add( rdn ); } toUpName(); }
/** * {@inheritDoc} */ @Override public void rename( String entryDn, String newRdn ) throws LdapException { if ( entryDn == null ) { String msg = "Cannot process a rename of a null Dn"; LOG.debug( msg ); throw new IllegalArgumentException( msg ); } if ( newRdn == null ) { String msg = "Cannot process a rename with a null Rdn"; LOG.debug( msg ); throw new IllegalArgumentException( msg ); } rename( new Dn( schemaManager, entryDn ), new Rdn( schemaManager, newRdn ) ); }
/** * {@inheritDoc} */ @Override public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException { // Read the UPName upName = in.readUTF(); // Read the RDNs. Is it's null, the number will be -1. int nbRdns = in.readInt(); rdns = new ArrayList<>( nbRdns ); for ( int i = 0; i < nbRdns; i++ ) { Rdn rdn = new Rdn( schemaManager ); rdn.readExternal( in ); rdns.add( rdn ); } toUpName(); }
/** * {@inheritDoc} */ @Override public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException { // Read the UPName upName = in.readUTF(); // Read the RDNs. Is it's null, the number will be -1. int nbRdns = in.readInt(); rdns = new ArrayList<>( nbRdns ); for ( int i = 0; i < nbRdns; i++ ) { Rdn rdn = new Rdn( schemaManager ); rdn.readExternal( in ); rdns.add( rdn ); } toUpName(); }
/** * Add a suffix to the Dn. For instance, if the current Dn is "ou=people", * and the suffix "dc=example,dc=com", then the resulting Dn will be * "ou=people,dc=example,dc=com" * * @param comp the suffix to add * @return The resulting Dn with the additional suffix * @throws LdapInvalidDnException If the resulting Dn is not valid */ public Dn add( String comp ) throws LdapInvalidDnException { if ( comp.length() == 0 ) { return this; } Dn clonedDn = copy(); // We have to parse the nameComponent which is given as an argument Rdn newRdn = new Rdn( schemaManager, comp ); clonedDn.rdns.add( 0, newRdn ); clonedDn.toUpName(); return clonedDn; }
/** * Creates a Schema aware Dn from a list of Rdns. * * @param schemaManager The SchemaManager to use * @param rdns the list of Rdns to be used for the Dn * @throws LdapInvalidDnException If the resulting Dn is invalid */ public Dn( SchemaManager schemaManager, Rdn... rdns ) throws LdapInvalidDnException { this.schemaManager = schemaManager; if ( rdns == null ) { return; } for ( Rdn rdn : rdns ) { if ( rdn.isSchemaAware() ) { this.rdns.add( rdn ); } else { this.rdns.add( new Rdn( schemaManager, rdn ) ); } } toUpName(); }
/** * Creates a Schema aware Dn from a list of Rdns. * * @param schemaManager The SchemaManager to use * @param rdns the list of Rdns to be used for the Dn * @throws LdapInvalidDnException If the resulting Dn is invalid */ public Dn( SchemaManager schemaManager, Rdn... rdns ) throws LdapInvalidDnException { this.schemaManager = schemaManager; if ( rdns == null ) { return; } for ( Rdn rdn : rdns ) { if ( rdn.isSchemaAware() ) { this.rdns.add( rdn ); } else { this.rdns.add( new Rdn( schemaManager, rdn ) ); } } toUpName(); }
/** * Used to convert a dn of String to a Dn object * @param principalName The principal name to be convert. * @return * @throws org.apache.directory.api.ldap.model.exception.LdapInvalidDnException if a remote exception occurs. * @throws LdapInvalidAttributeValueException */ private Dn toDn(String principalName) throws LdapInvalidDnException, LdapInvalidAttributeValueException { String[] names = principalName.split("@"); String uid = names[0]; Dn dn = new Dn(new Rdn("uid", uid), new Dn(getConfig().getString("base_dn"))); return dn; }
/** * Used to convert a dn of String to a Dn object * @param principalName The principal name to be convert. * @return * @throws org.apache.directory.api.ldap.model.exception.LdapInvalidDnException if a remote exception occurs. * @throws LdapInvalidAttributeValueException */ private Dn toDn(String principalName) throws LdapInvalidDnException, LdapInvalidAttributeValueException { String[] names = principalName.split("@"); String uid = names[0]; Dn dn = new Dn(new Rdn("uid", uid), new Dn(getConfig().getString("base_dn"))); return dn; }
/** * Adds a single Rdn to the (leaf) end of this name. * * @param newRdn the Rdn to add * @return the updated cloned Dn * @throws LdapInvalidDnException If the Dn is invalid */ public Dn add( Rdn newRdn ) throws LdapInvalidDnException { if ( ( newRdn == null ) || ( newRdn.size() == 0 ) ) { return this; } Dn clonedDn = copy(); clonedDn.rdns.add( 0, new Rdn( schemaManager, newRdn ) ); clonedDn.toUpName(); return clonedDn; }
/** * Adds a single Rdn to the (leaf) end of this name. * * @param newRdn the Rdn to add * @return the updated cloned Dn * @throws LdapInvalidDnException If the Dn is invalid */ public Dn add( Rdn newRdn ) throws LdapInvalidDnException { if ( ( newRdn == null ) || ( newRdn.size() == 0 ) ) { return this; } Dn clonedDn = copy(); clonedDn.rdns.add( 0, new Rdn( schemaManager, newRdn ) ); clonedDn.toUpName(); return clonedDn; }
/** * Adds a single Rdn to the (leaf) end of this name. * * @param newRdn the Rdn to add * @return the updated cloned Dn * @throws LdapInvalidDnException If the Dn is invalid */ public Dn add( Rdn newRdn ) throws LdapInvalidDnException { if ( ( newRdn == null ) || ( newRdn.size() == 0 ) ) { return this; } Dn clonedDn = copy(); clonedDn.rdns.add( 0, new Rdn( schemaManager, newRdn ) ); clonedDn.toUpName(); return clonedDn; }