directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r488345 [10/12] - in /directory/sandbox/pamarcelot/ldapstudio: ldapstudio-browser-core/ ldapstudio-browser-core/META-INF/ ldapstudio-browser-core/about_files/ ldapstudio-browser-core/lib/ ldapstudio-browser-core/src/ ldapstudio-browser-core...
Date Mon, 18 Dec 2006 17:15:08 GMT
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/IConnection.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/IConnection.java?view=auto&rev=488345
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/IConnection.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/IConnection.java Mon Dec 18 09:15:00 2006
@@ -0,0 +1,315 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.browser.core.model;
+
+
+import java.io.Serializable;
+import java.io.Writer;
+
+import org.apache.directory.ldapstudio.browser.core.BookmarkManager;
+import org.apache.directory.ldapstudio.browser.core.SearchManager;
+import org.apache.directory.ldapstudio.browser.core.events.ModelModifier;
+import org.apache.directory.ldapstudio.browser.core.internal.model.ConnectionException;
+import org.apache.directory.ldapstudio.browser.core.internal.model.ModificationLogger;
+import org.apache.directory.ldapstudio.browser.core.jobs.ExtendedProgressMonitor;
+import org.apache.directory.ldapstudio.browser.core.model.ldif.LdifEnumeration;
+import org.apache.directory.ldapstudio.browser.core.model.schema.Schema;
+import org.apache.directory.ldapstudio.browser.core.propertypageproviders.ConnectionPropertyPageProvider;
+import org.eclipse.core.runtime.IAdaptable;
+
+
+public interface IConnection extends Serializable, IAdaptable, ConnectionPropertyPageProvider, ModelModifier
+{
+
+    public static final String[] ROOT_DSE_ATTRIBUTES =
+        { IRootDSE.ROOTDSE_ATTRIBUTE_MONITORCONTEXT, IRootDSE.ROOTDSE_ATTRIBUTE_NAMINGCONTEXTS,
+            IRootDSE.ROOTDSE_ATTRIBUTE_SUPPORTEDLDAPVERSION, IRootDSE.ROOTDSE_ATTRIBUTE_SUBSCHEMASUBENTRY,
+            IRootDSE.ROOTDSE_ATTRIBUTE_ALTSERVER, IRootDSE.ROOTDSE_ATTRIBUTE_SUPPORTEDEXTENSION,
+            IRootDSE.ROOTDSE_ATTRIBUTE_SUPPORTEDCONTROL, IRootDSE.ROOTDSE_ATTRIBUTE_SUPPORTEDFEATURES,
+            IRootDSE.ROOTDSE_ATTRIBUTE_SUPPORTEDSASLMECHANISM, ISearch.ALL_OPERATIONAL_ATTRIBUTES,
+            ISearch.ALL_USER_ATTRIBUTES };
+
+    public static final int AUTH_ANONYMOUS = 0;
+
+    public static final int AUTH_SIMPLE = 1;
+
+    public static final int ENCYRPTION_NONE = 0;
+
+    public static final int ENCYRPTION_LDAPS = 1;
+
+    public static final int ENCYRPTION_STARTTLS = 2;
+
+    public static final int DEREFERENCE_ALIASES_NEVER = 0;
+
+    public static final int DEREFERENCE_ALIASES_ALWAYS = 1;
+
+    public static final int DEREFERENCE_ALIASES_FINDING = 2;
+
+    public static final int DEREFERENCE_ALIASES_SEARCH = 3;
+
+    public static final int HANDLE_REFERRALS_IGNORE = 0;
+
+    public static final int HANDLE_REFERRALS_FOLLOW = 1;
+
+    public static final String CONTROL_MANAGEDSAIT = "2.16.840.1.113730.3.4.2"; //$NON-NLS-1$
+
+
+    public abstract URL getUrl();
+
+
+    public abstract String getName();
+
+
+    public abstract void setName( String name );
+
+
+    public abstract boolean isFetchBaseDNs();
+
+
+    public abstract void setFetchBaseDNs( boolean fetchBaseDNs );
+
+
+    public abstract DN getBaseDN();
+
+
+    public abstract void setBaseDN( DN baseDN );
+
+
+    public abstract int getCountLimit();
+
+
+    public abstract void setCountLimit( int countLimit );
+
+
+    public abstract String getHost();
+
+
+    public abstract void setHost( String host );
+
+
+    public abstract int getPort();
+
+
+    public abstract void setPort( int port );
+
+
+    public abstract int getEncryptionMethod();
+
+
+    public abstract void setEncryptionMethod( int encryptionMethod );
+
+
+    public abstract int getAliasesDereferencingMethod();
+
+
+    public abstract void setAliasesDereferencingMethod( int aliasesDereferencingMethod );
+
+
+    public abstract int getReferralsHandlingMethod();
+
+
+    public abstract void setReferralsHandlingMethod( int referralsHandlingMethod );
+
+
+    public abstract int getTimeLimit();
+
+
+    public abstract void setTimeLimit( int timeLimit );
+
+
+    public String getBindPrincipal();
+
+
+    public void setBindPrincipal( String bindPrincipal );
+
+
+    public String getBindPassword();
+
+
+    public void setBindPassword( String bindPassword );
+
+
+    public int getAuthMethod();
+
+
+    public void setAuthMethod( int authMethod );
+
+
+    public abstract IEntry[] getBaseDNEntries();
+
+
+    public abstract IEntry[] getMetadataEntries();
+
+
+    public abstract IRootDSE getRootDSE();
+
+
+    public abstract Schema getSchema();
+
+
+    public abstract void setSchema( Schema schema );
+
+
+    public abstract ConnectionParameter getConnectionParameter();
+
+
+    public abstract void setConnectionParameter( ConnectionParameter connectionParameter );
+
+
+    public abstract SearchManager getSearchManager();
+
+
+    public abstract BookmarkManager getBookmarkManager();
+
+
+    public abstract ModificationLogger getModificationLogger();
+
+
+    public abstract void reloadSchema( ExtendedProgressMonitor monitor );
+
+
+    /**
+     * Connects to the LDAP server without any authentification:
+     * 
+     * @param pm
+     *                The progress monitor
+     */
+    public abstract void connect( ExtendedProgressMonitor monitor );
+
+
+    /**
+     * Binds to the LDAP server using the required authentification. Depends
+     * on connect().
+     * 
+     * @param pm
+     *                The progress monitor
+     */
+    public abstract void bind( ExtendedProgressMonitor monitor );
+
+
+    /**
+     * Fetches the Root DSE and tries to get the base DNs from Root DSE.
+     * Depends on bind().
+     * 
+     * @param pm
+     *                The progress monitor
+     */
+    public abstract void fetchRootDSE( ExtendedProgressMonitor monitor );
+
+
+    /**
+     * Opens the connection to the LDAP server and loads the schema if
+     * required. Depends on fetchRootDSE().
+     * 
+     * @param pm
+     *                The progress monitor
+     */
+    public abstract void open( ExtendedProgressMonitor monitor );
+
+
+    public abstract boolean isOpened();
+
+
+    public abstract boolean canOpen();
+
+
+    public abstract boolean canClose();
+
+
+    public abstract void close();
+
+
+    public abstract boolean existsEntry( DN dn, ExtendedProgressMonitor monitor );
+
+
+    public abstract IEntry getEntry( DN dn, ExtendedProgressMonitor monitor );
+
+
+    public abstract IEntry getEntryFromCache( DN dn );
+
+
+    public abstract void search( ISearch searchRequest, ExtendedProgressMonitor monitor );
+
+
+    public abstract void delete( IEntry entryToDelete, ExtendedProgressMonitor monitor );
+
+
+    public abstract void delete( IValue valuesToDelete[], ExtendedProgressMonitor monitor );
+
+
+    public abstract void delete( IAttribute attriubtesToDelete[], ExtendedProgressMonitor monitor );
+
+
+    public abstract void create( IEntry entryToCreate, ExtendedProgressMonitor monitor );
+
+
+    public abstract void create( IValue valuesToCreate[], ExtendedProgressMonitor monitor );
+
+
+    public abstract void modify( IValue oldValue, IValue newVaue, ExtendedProgressMonitor monitor );
+
+
+    public abstract void rename( IEntry entryToRename, DN newDn, boolean deleteOldRdn, ExtendedProgressMonitor monitor );
+
+
+    public abstract void move( IEntry entryToMove, DN newSuperior, ExtendedProgressMonitor monitor );
+
+
+    public abstract Object clone();
+
+
+    public abstract void importLdif( LdifEnumeration enumeration, Writer logWriter, boolean continueOnError,
+        ExtendedProgressMonitor monitor );
+
+
+    public abstract LdifEnumeration exportLdif( SearchParameter searchParameter, ExtendedProgressMonitor pm )
+        throws ConnectionException;
+
+
+    /**
+     * Suspends the commitment of modifications.
+     * 
+     */
+    public abstract void suspend();
+
+
+    /**
+     * Resume the commitment of modifications.
+     * 
+     */
+    public abstract void resume( ExtendedProgressMonitor monitor );
+
+
+    /**
+     * Resets the state and deletes all uncommitted modifications
+     * 
+     */
+    public abstract void reset();
+
+
+    public abstract boolean isSuspended();
+
+
+    public abstract int hashCode();
+
+
+    public abstract boolean equals( Object obj );
+}
\ No newline at end of file

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/IConnectionProvider.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/IConnectionProvider.java?view=auto&rev=488345
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/IConnectionProvider.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/IConnectionProvider.java Mon Dec 18 09:15:00 2006
@@ -0,0 +1,50 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.browser.core.model;
+
+
+import org.apache.directory.ldapstudio.browser.core.internal.model.ConnectionException;
+import org.apache.directory.ldapstudio.browser.core.jobs.ExtendedProgressMonitor;
+import org.apache.directory.ldapstudio.browser.core.model.ldif.LdifEnumeration;
+import org.apache.directory.ldapstudio.browser.core.model.ldif.container.LdifRecord;
+
+
+public interface IConnectionProvider
+{
+
+    public void connect( ConnectionParameter parameter, ExtendedProgressMonitor monitor ) throws ConnectionException;
+
+
+    public void bind( ConnectionParameter parameter, ICredentials credentials, ExtendedProgressMonitor monitor )
+        throws ConnectionException;
+
+
+    public void close() throws ConnectionException;
+
+
+    public LdifEnumeration search( SearchParameter parameter, ExtendedProgressMonitor monitor )
+        throws ConnectionException;
+
+
+    public void applyModification( LdifRecord record, int handleReferralsMethod, ExtendedProgressMonitor monitor )
+        throws ConnectionException;
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ICredentials.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ICredentials.java?view=auto&rev=488345
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ICredentials.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ICredentials.java Mon Dec 18 09:15:00 2006
@@ -0,0 +1,35 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.browser.core.model;
+
+
+public interface ICredentials
+{
+
+    public ConnectionParameter getConnectionParameter();
+
+
+    public String getBindDN();
+
+
+    public String getBindPassword();
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/IEntry.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/IEntry.java?view=auto&rev=488345
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/IEntry.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/IEntry.java Mon Dec 18 09:15:00 2006
@@ -0,0 +1,311 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.browser.core.model;
+
+
+import java.io.Serializable;
+
+import org.apache.directory.ldapstudio.browser.core.events.ModelModifier;
+import org.apache.directory.ldapstudio.browser.core.model.schema.Subschema;
+import org.apache.directory.ldapstudio.browser.core.propertypageproviders.ConnectionPropertyPageProvider;
+import org.apache.directory.ldapstudio.browser.core.propertypageproviders.EntryPropertyPageProvider;
+import org.eclipse.core.runtime.IAdaptable;
+
+
+public interface IEntry extends Serializable, IAdaptable, EntryPropertyPageProvider, ConnectionPropertyPageProvider
+{
+
+    /**
+     * Adds the given child to this entry.
+     * 
+     * @param childToAdd
+     *                the child to add
+     * @param source
+     *                the ModelModifier
+     */
+    public abstract void addChild( IEntry childToAdd, ModelModifier source );
+
+
+    /**
+     * Deletes the given child and all its children from this entry.
+     * 
+     * @param childToDelete
+     *                the child to delete
+     * @param source
+     *                the ModelModifier
+     */
+    public abstract void deleteChild( IEntry childToDelete, ModelModifier source );
+
+
+    /**
+     * Adds the given attribute to this entry. The attribute's entry must be
+     * this entry.
+     * 
+     * @param attributeToAdd
+     *                the attribute to add
+     * @param source
+     *                the ModelModifier
+     * @throws ModelModificationException
+     *                 if the attribute is alreade present in this entry or
+     *                 if the attribute's entry isn't this entry.
+     */
+    public abstract void addAttribute( IAttribute attributeToAdd, ModelModifier source )
+        throws ModelModificationException;
+
+
+    /**
+     * Deletes the given attribute from this entry.
+     * 
+     * @param attributeToDelete
+     *                the attribute to delete
+     * @param source
+     *                the ModelModifier
+     * @throws ModelModificationException
+     *                 if the attribute isn't present in this entry.
+     */
+    public abstract void deleteAttribute( IAttribute attributeToDelete, ModelModifier source )
+        throws ModelModificationException;
+
+
+    /**
+     * Checks if the entry with its attributes is consistent. The following
+     * conditions must be fulfilled:
+     * 
+     * <ul>
+     * <li>The objectClass attrbute must be present</li>
+     * <li>All must attributes must be present</li>
+     * <li>There mustn't be any empty value</li>
+     * </ul>
+     * 
+     * @return true if the entry is consistent
+     */
+    public abstract boolean isConsistent();
+
+
+    /**
+     * Indicates wheater the entry was created from directory. Otherwise it
+     * was created from the user.
+     * 
+     * @return true it the entry is a directory entry
+     */
+    public abstract boolean isDirectoryEntry();
+
+
+    /**
+     * 
+     * 
+     * @param isDirectoryEntry
+     *                true if the entry is created from directory.
+     */
+    public abstract void setDirectoryEntry( boolean isDirectoryEntry );
+
+
+    public abstract boolean isAlias();
+
+
+    public abstract void setAlias( boolean b );
+
+
+    public abstract boolean isReferral();
+
+
+    public abstract void setReferral( boolean b );
+
+
+    public abstract boolean isSubentry();
+
+
+    public abstract void setSubentry( boolean b );
+
+
+    /**
+     * Returns the DN of the entry, never null.
+     * 
+     * @return the DN of the entry, never null.
+     */
+    public abstract DN getDn();
+
+
+    /**
+     * Returns the RDN of the entry, never null.
+     * 
+     * @return the RDN of the entry, never null.
+     */
+    public abstract RDN getRdn();
+
+
+    /**
+     * Indicates wheater the attributes were initialized from directory.
+     * 
+     * @return true if the attributes were initialized from directory.
+     */
+    public abstract boolean isAttributesInitialized();
+
+
+    /**
+     * Sets if the attributes of this entry are initialized.
+     * 
+     * @param b
+     */
+    public abstract void setAttributesInitialized( boolean b, ModelModifier source );
+
+
+    /**
+     * Returns the attributes of the entry.
+     * 
+     * @return The attributes of the entry or null if the attributes arn't
+     *         initialized
+     */
+    public abstract IAttribute[] getAttributes();
+
+
+    /**
+     * Returns the attribute of the entry.
+     * 
+     * @param attributeDescription
+     * @return The attributes of the entry or null if the attribute doesn't
+     *         exist or if the attributes arn't initialized.
+     */
+    public abstract IAttribute getAttribute( String attributeDescription );
+
+
+    /**
+     * Returns a AttributeHierachie containing the requested attribute and
+     * all its subtypes.
+     * 
+     * @param attributeDescription
+     * @return The attributes of the entry or null if the attribute doesn't
+     *         exist or if the attributes arn't initialized.
+     */
+    public abstract AttributeHierachie getAttributeWithSubtypes( String attributeDescription );
+
+
+    /**
+     * Returns the subschema of the entry.
+     * 
+     * @return The subschema of the entry or null if the attributes aren't
+     *         initialized.
+     */
+    public abstract Subschema getSubschema();
+
+
+    /**
+     * Indicates wheater the children were initialized from directory.
+     * 
+     * @return true if the children were initialized from directory.
+     */
+    public abstract boolean isChildrenInitialized();
+
+
+    /**
+     * Sets if the children of this entry are initialized from directory.
+     * 
+     * @param b
+     */
+    public abstract void setChildrenInitialized( boolean b, ModelModifier source );
+
+
+    /**
+     * Returns true if the entry has children.
+     * 
+     * @return true if the entry has children.
+     */
+    public abstract boolean hasChildren();
+
+
+    /**
+     * Sets if the entry has children.
+     * 
+     * @param b
+     */
+    public abstract void setHasChildrenHint( boolean b, ModelModifier source );
+
+
+    /**
+     * Returns the children of the entry.
+     * 
+     * @return The children of the entry or null if the children arn't
+     *         initialized
+     */
+    public abstract IEntry[] getChildren();
+
+
+    /**
+     * Returns the number of children of the entry.
+     * 
+     * @return The number of children of the entry or -1 if the children
+     *         arn't initialized
+     */
+    public abstract int getChildrenCount();
+
+
+    /**
+     * Indicates wheather this entry has more children than
+     * getChildrenCount() returns. This occurs when the count or time limit
+     * of the LDAP connection exeeded while fetching children.
+     * 
+     * @return true if this entry has (maybe) more children than the given.
+     */
+    public abstract boolean hasMoreChildren();
+
+
+    /**
+     * Sets if the entry has more children in the directory.
+     * 
+     * @param b
+     */
+    public abstract void setHasMoreChildren( boolean b, ModelModifier source );
+
+
+    /**
+     * Indicates wheather this entry has a parent entry. Each entry except
+     * the root DSE and the base entry should have a parent entry.
+     * 
+     * @return true if the entry has a parent entry.
+     */
+    public abstract boolean hasParententry();
+
+
+    /**
+     * Return the parent entry.
+     * 
+     * @return the parent entry or null if this entry hasn't a parent.
+     */
+    public abstract IEntry getParententry();
+
+
+    public abstract String getChildrenFilter();
+
+
+    public abstract void setChildrenFilter( String filter );
+
+
+    /**
+     * Return the connection of this entry, never null.
+     * 
+     * @return the connection of this entry, never null.
+     */
+    public abstract IConnection getConnection();
+
+
+    public abstract URL getUrl();
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/IReferralHandler.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/IReferralHandler.java?view=auto&rev=488345
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/IReferralHandler.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/IReferralHandler.java Mon Dec 18 09:15:00 2006
@@ -0,0 +1,29 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.browser.core.model;
+
+
+public interface IReferralHandler
+{
+
+    public IConnection getReferralConnection( URL referralURL );
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/IRootDSE.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/IRootDSE.java?view=auto&rev=488345
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/IRootDSE.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/IRootDSE.java Mon Dec 18 09:15:00 2006
@@ -0,0 +1,58 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.browser.core.model;
+
+
+public interface IRootDSE extends IEntry
+{
+
+    public static final String ROOTDSE_ATTRIBUTE_NAMINGCONTEXTS = "namingContexts"; //$NON-NLS-1$
+
+    public static final String ROOTDSE_ATTRIBUTE_SUBSCHEMASUBENTRY = "subschemaSubentry"; //$NON-NLS-1$
+
+    public static final String ROOTDSE_ATTRIBUTE_MONITORCONTEXT = "monitorContext"; //$NON-NLS-1$
+
+    public static final String ROOTDSE_ATTRIBUTE_CONFIGCONTEXT = "configContext"; //$NON-NLS-1$
+
+    public static final String ROOTDSE_ATTRIBUTE_DSANAME = "dsaName"; //$NON-NLS-1$
+
+    public static final String ROOTDSE_ATTRIBUTE_SUPPORTEDEXTENSION = "supportedExtension"; //$NON-NLS-1$
+
+    public static final String ROOTDSE_ATTRIBUTE_SUPPORTEDCONTROL = "supportedControl"; //$NON-NLS-1$
+
+    public static final String ROOTDSE_ATTRIBUTE_SUPPORTEDFEATURES = "supportedFeatures"; //$NON-NLS-1$
+
+    public static final String ROOTDSE_ATTRIBUTE_SUPPORTEDLDAPVERSION = "supportedLDAPVersion"; //$NON-NLS-1$
+
+    public static final String ROOTDSE_ATTRIBUTE_ALTSERVER = "altServer"; //$NON-NLS-1$
+
+    public static final String ROOTDSE_ATTRIBUTE_SUPPORTEDSASLMECHANISM = "supportedSASLMechanisms"; //$NON-NLS-1$
+
+
+    public String[] getSupportedExtensions();
+
+
+    public String[] getSupportedControls();
+
+
+    public String[] getSupportedFeatures();
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ISearch.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ISearch.java?view=auto&rev=488345
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ISearch.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ISearch.java Mon Dec 18 09:15:00 2006
@@ -0,0 +1,143 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.browser.core.model;
+
+
+import java.io.Serializable;
+
+import org.apache.directory.ldapstudio.browser.core.propertypageproviders.ConnectionPropertyPageProvider;
+import org.apache.directory.ldapstudio.browser.core.propertypageproviders.SearchPropertyPageProvider;
+import org.eclipse.core.runtime.IAdaptable;
+
+
+public interface ISearch extends Serializable, IAdaptable, SearchPropertyPageProvider, ConnectionPropertyPageProvider
+{
+
+    public static final String ALL_USER_ATTRIBUTES = "*"; //$NON-NLS-1$
+
+    public static final String ALL_OPERATIONAL_ATTRIBUTES = "+"; //$NON-NLS-1$
+
+    public static final String[] NO_ATTRIBUTES = new String[0];
+
+    public static final String FILTER_TRUE = "(objectClass=*)"; //$NON-NLS-1$
+
+    public static final String FILTER_FALSE = "(!(objectClass=*))"; //$NON-NLS-1$
+
+    public static final int SCOPE_OBJECT = 0;
+
+    public static final int SCOPE_ONELEVEL = 1;
+
+    public static final int SCOPE_SUBTREE = 2;
+
+
+    public abstract URL getUrl();
+
+
+    public abstract boolean isInitChildrenFlag();
+
+
+    public abstract boolean isInitAliasAndReferralFlag();
+
+
+    public abstract Control[] getControls();
+
+
+    public abstract int getCountLimit();
+
+
+    public abstract void setCountLimit( int countLimit );
+
+
+    public abstract String getFilter();
+
+
+    public abstract void setFilter( String filter );
+
+
+    public abstract String[] getReturningAttributes();
+
+
+    public abstract void setReturningAttributes( String[] returningAttributes );
+
+
+    public abstract int getScope();
+
+
+    public abstract void setScope( int scope );
+
+
+    public abstract int getAliasesDereferencingMethod();
+
+
+    public abstract void setAliasesDereferencingMethod( int aliasesDereferencingMethod );
+
+
+    public abstract int getReferralsHandlingMethod();
+
+
+    public abstract void setReferralsHandlingMethod( int referralsHandlingMethod );
+
+
+    public abstract DN getSearchBase();
+
+
+    public abstract void setSearchBase( DN searchBase );
+
+
+    public abstract int getTimeLimit();
+
+
+    public abstract void setTimeLimit( int timeLimit );
+
+
+    public abstract String getName();
+
+
+    public abstract void setName( String searchName );
+
+
+    public abstract ISearchResult[] getSearchResults();
+
+
+    public abstract void setSearchResults( ISearchResult[] searchResults );
+
+
+    public abstract boolean isCountLimitExceeded();
+
+
+    public abstract void setCountLimitExceeded( boolean countLimitExceeded );
+
+
+    public abstract IConnection getConnection();
+
+
+    public abstract void setConnection( IConnection connection );
+
+
+    public abstract Object clone();
+
+
+    public abstract SearchParameter getSearchParameter();
+
+
+    public abstract void setSearchParameter( SearchParameter searchParameter );
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ISearchResult.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ISearchResult.java?view=auto&rev=488345
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ISearchResult.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ISearchResult.java Mon Dec 18 09:15:00 2006
@@ -0,0 +1,89 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.browser.core.model;
+
+
+import java.io.Serializable;
+
+import org.apache.directory.ldapstudio.browser.core.propertypageproviders.ConnectionPropertyPageProvider;
+import org.apache.directory.ldapstudio.browser.core.propertypageproviders.EntryPropertyPageProvider;
+import org.eclipse.core.runtime.IAdaptable;
+
+
+public interface ISearchResult extends Serializable, IAdaptable, EntryPropertyPageProvider,
+    ConnectionPropertyPageProvider
+{
+
+    /**
+     * Returns the DN of the search result entry.
+     * 
+     * @return the DN of the search result entry.
+     */
+    public DN getDn();
+
+
+    /**
+     * Returns the attributes of the search result entry.
+     * 
+     * @return the attributes of the search result entry.
+     */
+    public IAttribute[] getAttributes();
+
+
+    /**
+     * Returns the attribute of the search result entry.
+     * 
+     * @param attributeDescription
+     *                the attribute description of the attribute to return
+     * @return the attribute with the given description or null.
+     */
+    public IAttribute getAttribute( String attributeDescription );
+
+
+    /**
+     * Returns the AttributeHierachie of the search result entry.
+     * 
+     * @param attributeDescription
+     *                the description of the attribute to return
+     * @return the AttributeHierachie with the given description or null.
+     */
+    public AttributeHierachie getAttributeWithSubtypes( String attributeDescription );
+
+
+    /**
+     * Returns the entry of the search result.
+     * 
+     * @return the entry
+     */
+    public IEntry getEntry();
+
+
+    /**
+     * Return the search, the parent of this search result.
+     * 
+     * @return the search
+     */
+    public ISearch getSearch();
+
+
+    public void setSearch( ISearch search );
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/IValue.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/IValue.java?view=auto&rev=488345
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/IValue.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/IValue.java Mon Dec 18 09:15:00 2006
@@ -0,0 +1,206 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.browser.core.model;
+
+
+import java.io.Serializable;
+
+import org.apache.directory.ldapstudio.browser.core.BrowserCoreMessages;
+import org.apache.directory.ldapstudio.browser.core.propertypageproviders.AttributePropertyPageProvider;
+import org.apache.directory.ldapstudio.browser.core.propertypageproviders.ConnectionPropertyPageProvider;
+import org.apache.directory.ldapstudio.browser.core.propertypageproviders.EntryPropertyPageProvider;
+import org.apache.directory.ldapstudio.browser.core.propertypageproviders.ValuePropertyPageProvider;
+import org.eclipse.core.runtime.IAdaptable;
+
+
+/**
+ * A wrapper for raw LDAP values.
+ */
+public interface IValue extends Serializable, IAdaptable, ValuePropertyPageProvider, AttributePropertyPageProvider,
+    EntryPropertyPageProvider, ConnectionPropertyPageProvider
+{
+
+    interface EmptyValue
+    {
+        public String toString();
+
+
+        public String getStringValue();
+
+
+        public byte[] getBinaryValue();
+
+
+        public boolean isString();
+
+
+        public boolean isBinary();
+    }
+
+    /**
+     * This object represents the empty string value.
+     */
+    public static final EmptyValue EMPTY_STRING_VALUE = new EmptyValue()
+    {
+        public String toString()
+        {
+            return BrowserCoreMessages.model__empty_string_value;
+        }
+
+
+        public boolean isString()
+        {
+            return true;
+        }
+
+
+        public boolean isBinary()
+        {
+            return false;
+        }
+
+
+        public byte[] getBinaryValue()
+        {
+            return new byte[0];
+        }
+
+
+        public String getStringValue()
+        {
+            return ""; //$NON-NLS-1$
+        }
+    };
+
+    /**
+     * This object represents the empty binary value.
+     */
+    public static final EmptyValue EMPTY_BINARY_VALUE = new EmptyValue()
+    {
+        public String toString()
+        {
+            return BrowserCoreMessages.model__empty_binary_value;
+        }
+
+
+        public boolean isString()
+        {
+            return false;
+        }
+
+
+        public boolean isBinary()
+        {
+            return true;
+        }
+
+
+        public byte[] getBinaryValue()
+        {
+            return new byte[0];
+        }
+
+
+        public String getStringValue()
+        {
+            return ""; //$NON-NLS-1$
+        }
+    };
+
+
+    /**
+     * The attribute of this value.
+     * 
+     * @return The attribute of this value, never null.
+     */
+    public abstract IAttribute getAttribute();
+
+
+    /**
+     * Returns the raw value or an EmptyValue
+     * 
+     * @return The raw value or an EmptyValue, never null.
+     */
+    public abstract Object getRawValue();
+
+
+    /**
+     * Returns the String value of this value.
+     * 
+     * @return the String value
+     */
+    public abstract String getStringValue();
+
+
+    /**
+     * Returns the binary value of this value.
+     * 
+     * @return the binary value
+     */
+    public abstract byte[] getBinaryValue();
+
+
+    /**
+     * Return true if the value is empty.
+     * 
+     * @return true if the value is the empty.
+     */
+    public abstract boolean isEmpty();
+
+
+    /**
+     * Convinience method to getAttribute().isString().
+     * 
+     * @return true if the values attribute is string.
+     */
+    public abstract boolean isString();
+
+
+    /**
+     * Convinience method to getAttribute().isBinary()
+     * 
+     * @return true if the values attribute is binary.
+     */
+    public abstract boolean isBinary();
+
+
+    /**
+     * Returns true if this value is part of its entries RDN.
+     * 
+     * @return true if this value is part of its entries RDN.
+     */
+    public abstract boolean isRdnPart();
+
+
+    /**
+     * Return true if the argument is also of type IValue and they are
+     * equal.
+     * 
+     * IValues are equal if there entries, there attributes and there raw
+     * values are equal.
+     * 
+     * @param o
+     *                The value to compare, must be of type IValue
+     * @return true if the argument is equal to this.
+     */
+    public abstract boolean equals( Object o );
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ModelModificationException.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ModelModificationException.java?view=auto&rev=488345
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ModelModificationException.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/ModelModificationException.java Mon Dec 18 09:15:00 2006
@@ -0,0 +1,46 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.browser.core.model;
+
+
+public class ModelModificationException extends Exception
+{
+
+    private static final long serialVersionUID = 1L;
+
+
+    public ModelModificationException( String msg )
+    {
+        super( msg );
+    }
+
+
+    public ModelModificationException( String msg, Throwable exception )
+    {
+        super( msg, exception );
+    }
+
+
+    public ModelModificationException( Throwable exception )
+    {
+        super( exception );
+    }
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/NameException.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/NameException.java?view=auto&rev=488345
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/NameException.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/NameException.java Mon Dec 18 09:15:00 2006
@@ -0,0 +1,35 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.browser.core.model;
+
+
+public class NameException extends Exception
+{
+
+    private static final long serialVersionUID = 1L;
+
+
+    public NameException( String message )
+    {
+        super( message );
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/Password.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/Password.java?view=auto&rev=488345
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/Password.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/Password.java Mon Dec 18 09:15:00 2006
@@ -0,0 +1,357 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.browser.core.model;
+
+
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.security.SecureRandom;
+
+import org.apache.directory.ldapstudio.browser.core.BrowserCoreMessages;
+import org.apache.directory.ldapstudio.browser.core.utils.LdifUtils;
+import org.apache.directory.ldapstudio.browser.core.utils.UnixCrypt;
+
+
+public class Password
+{
+
+    public static final String HASH_METHOD_SHA = "SHA"; //$NON-NLS-1$
+
+    public static final String HASH_METHOD_SSHA = "SSHA"; //$NON-NLS-1$
+
+    public static final String HASH_METHOD_MD5 = "MD5"; //$NON-NLS-1$
+
+    public static final String HASH_METHOD_SMD5 = "SMD5"; //$NON-NLS-1$
+
+    public static final String HASH_METHOD_CRYPT = "CRYPT"; //$NON-NLS-1$
+
+    public static final String HASH_METHOD_NO = BrowserCoreMessages.model__no_hash;
+
+    public static final String HASH_METHOD_UNSUPPORTED = BrowserCoreMessages.model__unsupported_hash;
+
+    String hashMethod;
+
+    byte[] hashedPassword;
+
+    byte[] salt;
+
+    String trash;
+
+
+    public Password( byte[] password )
+    {
+        this( LdifUtils.utf8decode( password ) );
+    }
+
+
+    public Password( String password )
+    {
+
+        if ( password == null )
+        {
+            throw new IllegalArgumentException( BrowserCoreMessages.model__empty_password );
+        }
+        else if ( password.indexOf( '{' ) == 0 && password.indexOf( '}' ) > 0 )
+        {
+            hashMethod = password.substring( password.indexOf( '{' ) + 1, password.indexOf( '}' ) );
+            String rest = password.substring( hashMethod.length() + 2 );
+
+            if ( HASH_METHOD_SHA.equals( hashMethod ) || HASH_METHOD_MD5.equals( hashMethod ) )
+            {
+                hashedPassword = LdifUtils.base64decodeToByteArray( rest );
+                salt = null;
+            }
+            else if ( HASH_METHOD_SSHA.equals( hashMethod ) )
+            {
+                byte[] hashedPasswordWithSalt = LdifUtils.base64decodeToByteArray( rest );
+                hashedPassword = new byte[20];
+                salt = new byte[hashedPasswordWithSalt.length - hashedPassword.length];
+                split( hashedPasswordWithSalt, hashedPassword, salt );
+            }
+            else if ( HASH_METHOD_SMD5.equals( hashMethod ) )
+            {
+                byte[] hashedPasswordWithSalt = LdifUtils.base64decodeToByteArray( rest );
+                hashedPassword = new byte[16];
+                salt = new byte[hashedPasswordWithSalt.length - hashedPassword.length];
+                split( hashedPasswordWithSalt, hashedPassword, salt );
+            }
+            else if ( HASH_METHOD_CRYPT.equals( hashMethod ) )
+            {
+                byte[] saltWithPassword = LdifUtils.utf8encode( rest );
+                salt = new byte[2];
+                hashedPassword = new byte[saltWithPassword.length - salt.length];
+                split( saltWithPassword, salt, hashedPassword );
+            }
+            else
+            {
+                // throw new IllegalArgumentException("Unsupported hash method
+                // '"+hashMethod+"'");
+                // handle as plain text?
+                hashMethod = HASH_METHOD_UNSUPPORTED;
+                trash = password;
+                // salt = null;
+            }
+        }
+        else
+        {
+            // plain text
+            hashMethod = null;
+            hashedPassword = LdifUtils.utf8encode( password );
+            salt = null;
+        }
+    }
+
+
+    public Password( String hashMethod, String passwordAsPlaintext )
+    {
+
+        if ( !( hashMethod == null || HASH_METHOD_NO.equals( hashMethod ) || HASH_METHOD_SHA.equals( hashMethod )
+            || HASH_METHOD_SSHA.equals( hashMethod ) || HASH_METHOD_MD5.equals( hashMethod )
+            || HASH_METHOD_SMD5.equals( hashMethod ) || HASH_METHOD_CRYPT.equals( hashMethod ) ) )
+        {
+            throw new IllegalArgumentException( BrowserCoreMessages.model__unsupported_hash );
+        }
+        if ( passwordAsPlaintext == null )
+        {
+            throw new IllegalArgumentException( BrowserCoreMessages.model__empty_password );
+        }
+
+        // set hash method
+        if ( HASH_METHOD_NO.equals( hashMethod ) )
+        {
+            hashMethod = null;
+        }
+        this.hashMethod = hashMethod;
+
+        // set salt
+        if ( HASH_METHOD_SSHA.equals( hashMethod ) || HASH_METHOD_SMD5.equals( hashMethod ) )
+        {
+            this.salt = new byte[8];
+            new SecureRandom().nextBytes( this.salt );
+        }
+        else if ( HASH_METHOD_CRYPT.equals( hashMethod ) )
+        {
+            this.salt = new byte[2];
+            SecureRandom sr = new SecureRandom();
+            int i1 = sr.nextInt( 64 );
+            int i2 = sr.nextInt( 64 );
+            this.salt[0] = ( byte ) ( i1 < 12 ? ( i1 + '.' ) : i1 < 38 ? ( i1 + 'A' - 12 ) : ( i1 + 'a' - 38 ) );
+            this.salt[1] = ( byte ) ( i2 < 12 ? ( i2 + '.' ) : i2 < 38 ? ( i2 + 'A' - 12 ) : ( i2 + 'a' - 38 ) );
+        }
+        else
+        {
+            this.salt = null;
+        }
+
+        // digest
+        if ( HASH_METHOD_SHA.equals( hashMethod ) || HASH_METHOD_SSHA.equals( hashMethod ) )
+        {
+            this.hashedPassword = digest( HASH_METHOD_SHA, passwordAsPlaintext, this.salt );
+        }
+        else if ( HASH_METHOD_MD5.equals( hashMethod ) || HASH_METHOD_SMD5.equals( hashMethod ) )
+        {
+            this.hashedPassword = digest( HASH_METHOD_MD5, passwordAsPlaintext, this.salt );
+        }
+        else if ( HASH_METHOD_CRYPT.equals( hashMethod ) )
+        {
+            this.hashedPassword = crypt( passwordAsPlaintext, this.salt );
+        }
+        else if ( hashMethod == null )
+        {
+            this.hashedPassword = LdifUtils.utf8encode( passwordAsPlaintext );
+        }
+    }
+
+
+    public boolean verify( String testPasswordAsPlaintext )
+    {
+
+        if ( testPasswordAsPlaintext == null )
+        {
+            return false;
+        }
+
+        boolean verified = false;
+        if ( hashMethod == null )
+        {
+            verified = testPasswordAsPlaintext.equals( LdifUtils.utf8decode( hashedPassword ) );
+        }
+        else if ( HASH_METHOD_SHA.equals( hashMethod ) || HASH_METHOD_SSHA.equals( hashMethod ) )
+        {
+            byte[] hash = digest( HASH_METHOD_SHA, testPasswordAsPlaintext, this.salt );
+            verified = equals( hash, this.hashedPassword );
+        }
+        else if ( HASH_METHOD_MD5.equals( hashMethod ) || HASH_METHOD_SMD5.equals( hashMethod ) )
+        {
+            byte[] hash = digest( HASH_METHOD_MD5, testPasswordAsPlaintext, this.salt );
+            verified = equals( hash, this.hashedPassword );
+        }
+        else if ( HASH_METHOD_CRYPT.equals( hashMethod ) )
+        {
+            byte[] crypted = crypt( testPasswordAsPlaintext, this.salt );
+            verified = equals( crypted, this.hashedPassword );
+        }
+
+        return verified;
+    }
+
+
+    public String getHashMethod()
+    {
+        return this.hashMethod;
+    }
+
+
+    public byte[] getHashedPassword()
+    {
+        return hashedPassword;
+    }
+
+
+    public String getHashedPasswordAsHexString()
+    {
+        return LdifUtils.hexEncode( hashedPassword );
+    }
+
+
+    public byte[] getSalt()
+    {
+        return salt;
+    }
+
+
+    public String getSaltAsHexString()
+    {
+        return LdifUtils.hexEncode( salt );
+    }
+
+
+    public byte[] toBytes()
+    {
+        return LdifUtils.utf8encode( toString() );
+    }
+
+
+    public String toString()
+    {
+        StringBuffer sb = new StringBuffer();
+
+        if ( HASH_METHOD_UNSUPPORTED.equals( hashMethod ) )
+        {
+            sb.append( trash );
+        }
+        else if ( HASH_METHOD_CRYPT.equals( hashMethod ) )
+        {
+            sb.append( '{' ).append( hashMethod ).append( '}' );
+            sb.append( LdifUtils.utf8decode( salt ) );
+            sb.append( LdifUtils.utf8decode( hashedPassword ) );
+        }
+        else if ( hashMethod != null )
+        {
+            sb.append( '{' ).append( hashMethod ).append( '}' );
+            if ( salt != null )
+            {
+                byte[] hashedPasswordWithSaltBytes = new byte[hashedPassword.length + salt.length];
+                merge( hashedPasswordWithSaltBytes, hashedPassword, salt );
+                sb.append( LdifUtils.base64encode( hashedPasswordWithSaltBytes ) );
+            }
+            else
+            {
+                sb.append( LdifUtils.base64encode( hashedPassword ) );
+            }
+        }
+        else
+        {
+            sb.append( LdifUtils.utf8decode( hashedPassword ) );
+        }
+
+        return sb.toString();
+    }
+
+
+    private static void split( byte[] all, byte[] left, byte[] right )
+    {
+        System.arraycopy( all, 0, left, 0, left.length );
+        System.arraycopy( all, left.length, right, 0, right.length );
+    }
+
+
+    private static void merge( byte[] all, byte[] left, byte[] right )
+    {
+        System.arraycopy( left, 0, all, 0, left.length );
+        System.arraycopy( right, 0, all, left.length, right.length );
+    }
+
+
+    private static boolean equals( byte[] data1, byte[] data2 )
+    {
+        if ( data1 == data2 )
+            return true;
+        if ( data1 == null || data2 == null )
+            return false;
+        if ( data1.length != data2.length )
+            return false;
+        for ( int i = 0; i < data1.length; i++ )
+        {
+            if ( data1[i] != data2[i] )
+                return false;
+        }
+        return true;
+    }
+
+
+    private static byte[] digest( String hashMethod, String password, byte[] salt )
+    {
+
+        byte[] passwordBytes = LdifUtils.utf8encode( password );
+        MessageDigest digest;
+        try
+        {
+            digest = MessageDigest.getInstance( hashMethod );
+        }
+        catch ( NoSuchAlgorithmException e1 )
+        {
+            return null;
+        }
+
+        if ( salt != null )
+        {
+            digest.update( passwordBytes );
+            digest.update( salt );
+            byte[] hashedPasswordBytes = digest.digest();
+            return hashedPasswordBytes;
+        }
+        else
+        {
+            byte[] hashedPasswordBytes = digest.digest( passwordBytes );
+            return hashedPasswordBytes;
+        }
+    }
+
+
+    private static byte[] crypt( String password, byte[] salt )
+    {
+        String saltWithCrypted = UnixCrypt.crypt( password, LdifUtils.utf8decode( salt ) );
+        String crypted = saltWithCrypted.substring( 2 );
+        return LdifUtils.utf8encode( crypted );
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/RDN.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/RDN.java?view=auto&rev=488345
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/RDN.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/RDN.java Mon Dec 18 09:15:00 2006
@@ -0,0 +1,320 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.browser.core.model;
+
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.directory.ldapstudio.browser.core.BrowserCoreMessages;
+import org.apache.directory.ldapstudio.browser.core.model.schema.Schema;
+
+
+public class RDN implements Serializable
+{
+
+    private static final long serialVersionUID = -4165959915339033047L;
+
+    private RDNPart[] parts;
+
+
+    public RDN()
+    {
+        this.parts = new RDNPart[0];
+    }
+
+
+    public RDN( String rdn ) throws NameException
+    {
+
+        if ( rdn == null )
+        {
+            throw new IllegalArgumentException( BrowserCoreMessages.model__empty_rdn );
+        }
+
+        // this.parseMultiRdn(rdn.trim());
+        this.parseMultiRdn( rdn );
+    }
+
+
+    public RDN( RDN rdn )
+    {
+
+        if ( rdn == null )
+        {
+            throw new IllegalArgumentException( BrowserCoreMessages.model__empty_rdn );
+        }
+
+        this.parts = new RDNPart[rdn.getParts().length];
+        for ( int i = 0; i < this.parts.length; i++ )
+        {
+            this.parts[i] = new RDNPart( rdn.getParts()[i] );
+        }
+    }
+
+
+    /**
+     * Create a single-valued RDN with the given name and value
+     * 
+     * @param name
+     * @param value
+     */
+    public RDN( String name, String value, boolean isValueEncoded ) throws NameException
+    {
+
+        if ( name == null )
+        {
+            throw new IllegalArgumentException( BrowserCoreMessages.model__empty_attribute );
+        }
+        if ( value == null )
+        {
+            throw new IllegalArgumentException( BrowserCoreMessages.model__empty_value );
+        }
+
+        this.parts = new RDNPart[1];
+        this.parts[0] = new RDNPart( name, value, isValueEncoded );
+    }
+
+
+    public RDN( String[] names, String[] values, boolean areValuesEncoded ) throws NameException
+    {
+
+        if ( names == null || names.length < 1 )
+        {
+            throw new IllegalArgumentException( BrowserCoreMessages.model__empty_attribute );
+        }
+        if ( values == null || values.length < 1 )
+        {
+            throw new IllegalArgumentException( BrowserCoreMessages.model__empty_value );
+        }
+        if ( names.length != values.length )
+        {
+            throw new IllegalArgumentException( "Size of names and values is not equal" ); //$NON-NLS-1$
+        }
+
+        this.parts = new RDNPart[names.length];
+        for ( int i = 0; i < this.parts.length; i++ )
+        {
+            this.parts[i] = new RDNPart( names[i], values[i], areValuesEncoded );
+        }
+    }
+
+
+    public boolean isMultivalued()
+    {
+        return this.parts.length > 1;
+    }
+
+
+    public String getName()
+    {
+        return this.parts.length > 0 ? this.parts[0].getName() : ""; //$NON-NLS-1$
+    }
+
+
+    public String getValue()
+    {
+        return this.parts.length > 0 ? this.parts[0].getValue() : ""; //$NON-NLS-1$
+    }
+
+
+    public RDNPart[] getParts()
+    {
+        return this.parts;
+    }
+
+
+    public void setParts( RDNPart[] parts )
+    {
+        this.parts = parts;
+    }
+
+
+    public String[] getNames()
+    {
+        if ( !isMultivalued() )
+        {
+            return new String[]
+                { getName() };
+        }
+        else
+        {
+            Set nameSet = new LinkedHashSet();
+            for ( int i = 0; i < this.parts.length; i++ )
+            {
+                RDNPart entry = this.parts[i];
+                nameSet.add( entry.getName() );
+            }
+            return ( String[] ) nameSet.toArray( new String[nameSet.size()] );
+        }
+    }
+
+
+    public String[] getValues()
+    {
+        if ( !isMultivalued() )
+        {
+            return new String[]
+                { getValue() };
+        }
+        else
+        {
+            Set valueSet = new LinkedHashSet();
+            for ( int i = 0; i < this.parts.length; i++ )
+            {
+                RDNPart entry = this.parts[i];
+                valueSet.add( entry.getValue() );
+            }
+            return ( String[] ) valueSet.toArray( new String[valueSet.size()] );
+        }
+    }
+
+
+    public int hashCode()
+    {
+        return this.toString().hashCode();
+    }
+
+
+    public boolean equals( Object o )
+    {
+        if ( o instanceof RDN )
+        {
+            return this.toString().equals( ( ( RDN ) o ).toString() );
+        }
+        return false;
+    }
+
+
+    public String toString()
+    {
+        StringBuffer sb = new StringBuffer();
+
+        if ( isMultivalued() )
+        {
+            for ( int i = 0; i < this.parts.length; i++ )
+            {
+                RDNPart part = this.parts[i];
+                sb.append( part.toString() );
+                // sb.append(part.getName());
+                // sb.append("="); //$NON-NLS-1$
+                // sb.append(part.getValue());
+
+                if ( i + 1 < this.parts.length )
+                {
+                    sb.append( "+" ); //$NON-NLS-1$
+                }
+            }
+        }
+        else if ( this.parts.length > 0 )
+        {
+            RDNPart part = this.parts[0];
+            sb.append( part.toString() );
+            // sb.append(part.getName());
+            // sb.append("="); //$NON-NLS-1$
+            // sb.append(part.getValue());
+        }
+
+        return sb.toString();
+    }
+
+
+    public String toOidString( Schema schema )
+    {
+        StringBuffer sb = new StringBuffer();
+
+        if ( isMultivalued() )
+        {
+            for ( int i = 0; i < this.parts.length; i++ )
+            {
+                RDNPart part = this.parts[i];
+                sb.append( part.toOidString( schema ) );
+
+                if ( i + 1 < this.parts.length )
+                {
+                    sb.append( "+" ); //$NON-NLS-1$
+                }
+            }
+        }
+        else if ( this.parts.length > 0 )
+        {
+            RDNPart part = this.parts[0];
+            sb.append( part.toOidString( schema ) );
+        }
+
+        return sb.toString();
+    }
+
+
+    private void parseMultiRdn( String multirdn ) throws NameException
+    {
+
+        List partList = new ArrayList( 1 );
+
+        boolean backslash = false;
+        int start = 0;
+        for ( int i = 0; i < multirdn.length(); i++ )
+        {
+            if ( multirdn.charAt( i ) == '\\' && !backslash )
+            {
+                backslash = true;
+            }
+            else
+            {
+                String rdn = null;
+                if ( multirdn.charAt( i ) == '+' && !backslash )
+                {
+                    rdn = multirdn.substring( start, i );
+                }
+                else if ( i == multirdn.length() - 1 )
+                {
+                    rdn = multirdn.substring( start );
+                }
+                if ( rdn != null )
+                {
+                    int index = rdn.indexOf( '=' );
+                    if ( index < 1 )
+                    {
+                        throw new NameException( BrowserCoreMessages.model__invalid_rdn );
+                    }
+                    String name = rdn.substring( 0, index );
+                    String value = rdn.substring( index + 1, rdn.length() );
+                    // partList.add(new RDNPart(name.trim(), value.trim()));
+                    partList.add( new RDNPart( name, value, true ) );
+                    start = i + 1;
+                }
+                backslash = false;
+            }
+        }
+
+        if ( partList.isEmpty() )
+        {
+
+        }
+
+        this.parts = ( RDNPart[] ) partList.toArray( new RDNPart[partList.size()] );
+
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/RDNPart.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/RDNPart.java?view=auto&rev=488345
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/RDNPart.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/RDNPart.java Mon Dec 18 09:15:00 2006
@@ -0,0 +1,208 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.browser.core.model;
+
+
+import java.io.Serializable;
+
+import org.apache.directory.ldapstudio.browser.core.BrowserCoreMessages;
+import org.apache.directory.ldapstudio.browser.core.model.schema.Schema;
+
+
+public class RDNPart implements Serializable
+{
+
+    private static final long serialVersionUID = 3250931604639940667L;
+
+    private String name;
+
+    private String value;
+
+
+    public RDNPart()
+    {
+        this.name = ""; //$NON-NLS-1$
+        this.value = ""; //$NON-NLS-1$
+    }
+
+
+    public RDNPart( String name, String value, boolean isValueEncoded ) throws NameException
+    {
+        if ( name == null || !name.matches( "([A-Za-z][A-Za-z0-9-]*)|([0-9]+(\\.[0-9]+)+)" ) ) { //$NON-NLS-1$
+            throw new NameException( BrowserCoreMessages.model__empty_attribute );
+        }
+        if ( value == null || value.length() < 1 )
+        {
+            throw new NameException( BrowserCoreMessages.model__empty_value );
+        }
+        // this.name = name.trim();
+        // this.value = value.trim();
+        this.setName( name );
+        if ( isValueEncoded )
+        {
+            this.setValue( value );
+        }
+        else
+        {
+            this.setUnencodedValue( value );
+        }
+    }
+
+
+    public RDNPart( RDNPart rdnPart )
+    {
+        this.name = rdnPart.name;
+        this.value = rdnPart.value;
+    }
+
+
+    public String getName()
+    {
+        return name;
+    }
+
+
+    public void setName( String name )
+    {
+        this.name = name;
+    }
+
+
+    // If the UTF-8 string does not have any of the following characters
+    // which need escaping, then that string can be used as the string
+    // representation of the value.
+    //
+    // o a space or "#" character occurring at the beginning of the
+    // string
+    //
+    // o a space character occurring at the end of the string
+    //
+    // o one of the characters ",", "+", """, "\", "<", ">" or ";"
+    //
+    // Implementations MAY escape other characters.
+    //
+    // If a character to be escaped is one of the list shown above, then it
+    // is prefixed by a backslash ('\' ASCII 92).
+    //
+    // Otherwise the character to be escaped is replaced by a backslash and
+    // two hex digits, which form a single byte in the code of the
+    // character.
+    public String getUnencodedValue()
+    {
+        StringBuffer unencodedValue = new StringBuffer( this.value );
+
+        for ( int i = 0; i < unencodedValue.length(); i++ )
+        {
+            if ( unencodedValue.charAt( i ) == '\\' )
+            {
+
+                if ( i == 0 && unencodedValue.length() > i + 1 && unencodedValue.charAt( i + 1 ) == ' ' )
+                {
+                    unencodedValue.deleteCharAt( i );
+                }
+                else if ( i == unencodedValue.length() - 2 && unencodedValue.length() > i + 1
+                    && unencodedValue.charAt( i + 1 ) == ' ' )
+                {
+                    unencodedValue.deleteCharAt( i );
+                }
+                else if ( i == 0 && unencodedValue.length() > i + 1 && unencodedValue.charAt( i + 1 ) == '#' )
+                {
+                    unencodedValue.deleteCharAt( i );
+                }
+                else if ( unencodedValue.length() > i + 1
+                    && ( unencodedValue.charAt( i + 1 ) == '+' || unencodedValue.charAt( i + 1 ) == ','
+                        || unencodedValue.charAt( i + 1 ) == ';' || unencodedValue.charAt( i + 1 ) == '<'
+                        || unencodedValue.charAt( i + 1 ) == '>' || unencodedValue.charAt( i + 1 ) == '"' || unencodedValue
+                        .charAt( i + 1 ) == '\\' ) )
+                {
+                    unencodedValue.deleteCharAt( i );
+                }
+
+            }
+        }
+
+        return unencodedValue.toString();
+    }
+
+
+    public void setUnencodedValue( String unencodedValue )
+    {
+
+        unencodedValue = unencodedValue.replaceAll( "\\\\", "\\\\\\\\" ); //$NON-NLS-1$ //$NON-NLS-2$
+        unencodedValue = unencodedValue.replaceAll( "\\+", "\\\\+" ); //$NON-NLS-1$ //$NON-NLS-2$
+        unencodedValue = unencodedValue.replaceAll( ",", "\\\\," ); //$NON-NLS-1$ //$NON-NLS-2$
+        unencodedValue = unencodedValue.replaceAll( "\"", "\\\\\"" ); //$NON-NLS-1$ //$NON-NLS-2$
+        unencodedValue = unencodedValue.replaceAll( "<", "\\\\<" ); //$NON-NLS-1$ //$NON-NLS-2$
+        unencodedValue = unencodedValue.replaceAll( ">", "\\\\>" ); //$NON-NLS-1$ //$NON-NLS-2$
+        unencodedValue = unencodedValue.replaceAll( ";", "\\\\;" ); //$NON-NLS-1$ //$NON-NLS-2$
+
+        if ( unencodedValue.startsWith( " " ) ) //$NON-NLS-1$
+            unencodedValue = "\\" + unencodedValue; //$NON-NLS-1$
+        if ( unencodedValue.startsWith( "#" ) ) //$NON-NLS-1$
+            unencodedValue = "\\" + unencodedValue; //$NON-NLS-1$
+        if ( unencodedValue.endsWith( " " ) ) //$NON-NLS-1$
+            unencodedValue = unencodedValue.substring( 0, unencodedValue.length() - 1 ) + "\\ "; //$NON-NLS-1$
+
+        this.value = unencodedValue;
+    }
+
+
+    public String getValue()
+    {
+        return value;
+    }
+
+
+    public void setValue( String value )
+    {
+        this.value = value;
+    }
+
+
+    public int hashCode()
+    {
+        return this.toString().hashCode();
+    }
+
+
+    public boolean equals( Object o )
+    {
+        if ( o instanceof RDNPart )
+        {
+            return this.toString().equals( ( ( RDNPart ) o ).toString() );
+        }
+        return false;
+    }
+
+
+    public String toString()
+    {
+        return getName() + "=" + getValue(); //$NON-NLS-1$
+    }
+
+
+    public String toOidString( Schema schema )
+    {
+        String oid = schema != null ? schema.getAttributeTypeDescription( getName() ).getNumericOID() : getName();
+        return oid + "=" + getValue(); //$NON-NLS-1$
+    }
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/SearchParameter.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/SearchParameter.java?view=auto&rev=488345
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/SearchParameter.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/model/SearchParameter.java Mon Dec 18 09:15:00 2006
@@ -0,0 +1,274 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.browser.core.model;
+
+
+import java.io.Serializable;
+
+import org.apache.directory.ldapstudio.browser.core.utils.LdifUtils;
+
+
+public class SearchParameter implements Serializable
+{
+
+    private static final long serialVersionUID = 2447490121520960805L;
+
+    private String name;
+
+    private DN searchBase;
+
+    private String filter = ISearch.FILTER_TRUE;
+
+    private String[] returningAttributes = null;
+
+    private int scope = ISearch.SCOPE_OBJECT;
+
+    private int timeLimit = 0;
+
+    private int countLimit = 0;
+
+    private int aliasesDereferencingMethod = IConnection.DEREFERENCE_ALIASES_NEVER;
+
+    private int referralsHandlingMethod = IConnection.HANDLE_REFERRALS_IGNORE;
+
+    private Control[] controls = null;
+
+    private boolean initChildrenFlag = false;
+
+    private boolean initAliasAndReferralFlag = false;
+
+
+    public SearchParameter()
+    {
+    }
+
+
+    public int getCountLimit()
+    {
+        return countLimit;
+    }
+
+
+    public void setCountLimit( int countLimit )
+    {
+        this.countLimit = countLimit;
+    }
+
+
+    public String getFilter()
+    {
+        return filter;
+    }
+
+
+    public void setFilter( String filter )
+    {
+        this.filter = filter;
+    }
+
+
+    public String getName()
+    {
+        return name;
+    }
+
+
+    public void setName( String name )
+    {
+        this.name = name;
+    }
+
+
+    public String[] getReturningAttributes()
+    {
+        return returningAttributes;
+    }
+
+
+    public void setReturningAttributes( String[] returningAttributes )
+    {
+        if ( returningAttributes == null )
+        {
+            IllegalArgumentException e = new IllegalArgumentException( "Argument returningAttributes is null" ); //$NON-NLS-1$
+            e.printStackTrace();
+            throw e;
+        }
+        this.returningAttributes = returningAttributes;
+    }
+
+
+    public int getScope()
+    {
+        return scope;
+    }
+
+
+    public void setScope( int scope )
+    {
+        this.scope = scope;
+    }
+
+
+    public int getAliasesDereferencingMethod()
+    {
+        return aliasesDereferencingMethod;
+    }
+
+
+    public void setAliasesDereferencingMethod( int aliasesDereferencingMethod )
+    {
+        this.aliasesDereferencingMethod = aliasesDereferencingMethod;
+    }
+
+
+    public int getReferralsHandlingMethod()
+    {
+        return referralsHandlingMethod;
+    }
+
+
+    public void setReferralsHandlingMethod( int referralsHandlingMethod )
+    {
+        this.referralsHandlingMethod = referralsHandlingMethod;
+    }
+
+
+    public DN getSearchBase()
+    {
+        return searchBase;
+    }
+
+
+    public void setSearchBase( DN searchBase )
+    {
+        this.searchBase = searchBase;
+    }
+
+
+    public int getTimeLimit()
+    {
+        return timeLimit;
+    }
+
+
+    public void setTimeLimit( int timeLimit )
+    {
+        this.timeLimit = timeLimit;
+    }
+
+
+    public Object clone()
+    {
+        SearchParameter clone = new SearchParameter();
+        clone.setName( getName() );
+        clone.setSearchBase( getSearchBase() );
+        clone.setFilter( getFilter() );
+        clone.setReturningAttributes( getReturningAttributes() );
+        clone.setScope( getScope() );
+        clone.setTimeLimit( getTimeLimit() );
+        clone.setCountLimit( getCountLimit() );
+        clone.setAliasesDereferencingMethod( getAliasesDereferencingMethod() );
+        clone.setReferralsHandlingMethod( getReferralsHandlingMethod() );
+        clone.setInitChildrenFlag( isInitChildrenFlag() );
+        clone.setInitAliasAndReferralFlag( isInitAliasAndReferralFlag() );
+        clone.setControls( getControls() );
+        return clone;
+    }
+
+
+    public String getURL()
+    {
+        // ldap://host:port/dn?attributes?scope?filter?extensions
+        StringBuffer sb = new StringBuffer();
+
+        sb.append( LdifUtils.urlEncode( searchBase.toString() ) );
+
+        sb.append( '?' );
+
+        for ( int i = 0; returningAttributes != null && i < returningAttributes.length; i++ )
+        {
+            sb.append( LdifUtils.urlEncode( returningAttributes[i] ) );
+            if ( i + 1 < returningAttributes.length )
+                sb.append( ',' );
+        }
+
+        sb.append( '?' );
+
+        if ( scope == ISearch.SCOPE_OBJECT )
+        {
+            sb.append( "base" ); //$NON-NLS-1$
+        }
+        else if ( scope == ISearch.SCOPE_ONELEVEL )
+        {
+            sb.append( "one" ); //$NON-NLS-1$
+        }
+        else if ( scope == ISearch.SCOPE_SUBTREE )
+        {
+            sb.append( "sub" ); //$NON-NLS-1$
+        }
+
+        sb.append( '?' );
+
+        if ( filter != null )
+        {
+            sb.append( LdifUtils.urlEncode( filter ) );
+        }
+
+        return sb.toString();
+    }
+
+
+    public boolean isInitAliasAndReferralFlag()
+    {
+        return initAliasAndReferralFlag;
+    }
+
+
+    public void setInitAliasAndReferralFlag( boolean initAliasAndReferralFlag )
+    {
+        this.initAliasAndReferralFlag = initAliasAndReferralFlag;
+    }
+
+
+    public boolean isInitChildrenFlag()
+    {
+        return initChildrenFlag;
+    }
+
+
+    public void setInitChildrenFlag( boolean initChildrenFlag )
+    {
+        this.initChildrenFlag = initChildrenFlag;
+    }
+
+
+    public Control[] getControls()
+    {
+        return controls;
+    }
+
+
+    public void setControls( Control[] controls )
+    {
+        this.controls = controls;
+    }
+
+}



Mime
View raw message