You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2015/03/25 18:16:25 UTC
svn commit: r1669163 [1/3] - in
/directory/studio/trunk/plugins/openldap.syncrepl: ./ src/ src/main/
src/main/java/ src/main/java/org/ src/main/java/org/apache/
src/main/java/org/apache/directory/
src/main/java/org/apache/directory/studio/ src/main/jav...
Author: elecharny
Date: Wed Mar 25 17:16:24 2015
New Revision: 1669163
URL: http://svn.apache.org/r1669163
Log:
Injected the openldap.syncrepl plugin
Added:
directory/studio/trunk/plugins/openldap.syncrepl/build.properties
directory/studio/trunk/plugins/openldap.syncrepl/plugin.properties
directory/studio/trunk/plugins/openldap.syncrepl/pom-first.xml
directory/studio/trunk/plugins/openldap.syncrepl/pom.xml
directory/studio/trunk/plugins/openldap.syncrepl/src/
directory/studio/trunk/plugins/openldap.syncrepl/src/main/
directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/
directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/
directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/
directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/
directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/
directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/
directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/
directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/BindMethod.java
directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/Interval.java
directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/KeepAlive.java
directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/Provider.java
directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/Retry.java
directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/RetryPair.java
directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/SaslMechanism.java
directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/SchemaChecking.java
directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/Scope.java
directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/StartTls.java
directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/SyncData.java
directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/SyncRepl.java
directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/SyncReplParser.java
directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/SyncReplParserException.java
directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/TlsCrlCheck.java
directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/TlsReqCert.java
directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/Type.java
directory/studio/trunk/plugins/openldap.syncrepl/src/main/resources/
directory/studio/trunk/plugins/openldap.syncrepl/src/test/
directory/studio/trunk/plugins/openldap.syncrepl/src/test/java/
directory/studio/trunk/plugins/openldap.syncrepl/src/test/java/com/
directory/studio/trunk/plugins/openldap.syncrepl/src/test/java/com/iktek/
directory/studio/trunk/plugins/openldap.syncrepl/src/test/java/com/iktek/studio/
directory/studio/trunk/plugins/openldap.syncrepl/src/test/java/com/iktek/studio/openldap/
directory/studio/trunk/plugins/openldap.syncrepl/src/test/java/com/iktek/studio/openldap/syncrepl/
directory/studio/trunk/plugins/openldap.syncrepl/src/test/java/com/iktek/studio/openldap/syncrepl/IntervalTest.java
directory/studio/trunk/plugins/openldap.syncrepl/src/test/java/com/iktek/studio/openldap/syncrepl/KeepAliveTest.java
directory/studio/trunk/plugins/openldap.syncrepl/src/test/java/com/iktek/studio/openldap/syncrepl/ProviderTest.java
directory/studio/trunk/plugins/openldap.syncrepl/src/test/java/com/iktek/studio/openldap/syncrepl/RetryPairTest.java
directory/studio/trunk/plugins/openldap.syncrepl/src/test/java/com/iktek/studio/openldap/syncrepl/RetryTest.java
directory/studio/trunk/plugins/openldap.syncrepl/src/test/java/com/iktek/studio/openldap/syncrepl/SyncReplParserTest.java
directory/studio/trunk/plugins/openldap.syncrepl/src/test/resources/
Modified:
directory/studio/trunk/plugins/openldap.syncrepl/ (props changed)
Propchange: directory/studio/trunk/plugins/openldap.syncrepl/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Mar 25 17:16:24 2015
@@ -0,0 +1,16 @@
+target
+maven-eclipse.xml
+lib
+bin
+.externalToolBuilders
+felix-cache
+.project
+.classpath
+.settings
+eclipse-classes
+*.log
+*.iml
+*.ipr
+dependency-reduced-pom.xml
+META-INF
+
Added: directory/studio/trunk/plugins/openldap.syncrepl/build.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.syncrepl/build.properties?rev=1669163&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.syncrepl/build.properties (added)
+++ directory/studio/trunk/plugins/openldap.syncrepl/build.properties Wed Mar 25 17:16:24 2015
@@ -0,0 +1,4 @@
+source.. = src/main/java/
+bin.includes = META-INF/,\
+ .,\
+ plugin.properties
Added: directory/studio/trunk/plugins/openldap.syncrepl/plugin.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.syncrepl/plugin.properties?rev=1669163&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.syncrepl/plugin.properties (added)
+++ directory/studio/trunk/plugins/openldap.syncrepl/plugin.properties Wed Mar 25 17:16:24 2015
@@ -0,0 +1,18 @@
+# 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.
+
+Plugin_id=org.apache.directory.studio.openldap.syncrepl
Added: directory/studio/trunk/plugins/openldap.syncrepl/pom-first.xml
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.syncrepl/pom-first.xml?rev=1669163&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.syncrepl/pom-first.xml (added)
+++ directory/studio/trunk/plugins/openldap.syncrepl/pom-first.xml Wed Mar 25 17:16:24 2015
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.directory.studio</groupId>
+ <artifactId>parent-plugins</artifactId>
+ <version>2.0.0.qualifier</version>
+ <relativePath>../pom-first.xml</relativePath>
+ </parent>
+
+ <artifactId>org.apache.directory.studio.openldap.syncrepl</artifactId>
+ <name>Apache Directory Studio SyncRepl</name>
+ <description/>
+ <packaging>bundle</packaging>
+
+ <build>
+ <plugins>
+ <!-- MANIFEST.MF Generation -->
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <manifestLocation>META-INF</manifestLocation>
+ <instructions>
+ <Bundle-SymbolicName>${project.artifactId};singleton:=true</Bundle-SymbolicName>
+ <Bundle-Localization>plugin</Bundle-Localization>
+ <Eclipse-LazyStart>true</Eclipse-LazyStart>
+ <Require-Bundle>
+ org.apache.directory.api.util;bundle-version="${org.apache.directory.api.bundleversion}"
+ </Require-Bundle>
+ <Export-Package>org.apache.directory.studio.openldap.syncrepl</Export-Package>
+ </instructions>
+ </configuration>
+ <executions>
+ <execution>
+ <id>generate-manifest</id>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>manifest</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Added: directory/studio/trunk/plugins/openldap.syncrepl/pom.xml
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.syncrepl/pom.xml?rev=1669163&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.syncrepl/pom.xml (added)
+++ directory/studio/trunk/plugins/openldap.syncrepl/pom.xml Wed Mar 25 17:16:24 2015
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.directory.studio</groupId>
+ <artifactId>parent-plugins</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ <relativePath>../</relativePath>
+ </parent>
+
+ <artifactId>org.apache.directory.studio.openldap.syncrepl</artifactId>
+ <name>Apache Directory Studio OpenLDAP Syncrepl</name>
+ <packaging>eclipse-plugin</packaging>
+ <description />
+</project>
Added: directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/BindMethod.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/BindMethod.java?rev=1669163&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/BindMethod.java (added)
+++ directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/BindMethod.java Wed Mar 25 17:16:24 2015
@@ -0,0 +1,85 @@
+/*
+ * 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.studio.openldap.syncrepl;
+
+
+import java.text.ParseException;
+
+
+/**
+ * This enum implements all the possible values for the bind method value.
+ */
+public enum BindMethod
+{
+ /** The 'simple' bind method value */
+ SIMPLE("simple"),
+
+ /** The 'sash' bind method value */
+ SASL("sasl");
+
+ /** The value */
+ private String value;
+
+
+ /**
+ * Parses a bind method string.
+ *
+ * @param s the string
+ * @return a bind method
+ * @throws ParseException if an error occurs during parsing
+ */
+ public static BindMethod parse( String s ) throws ParseException
+ {
+ // SIMPLE
+ if ( SIMPLE.value.equalsIgnoreCase( s ) )
+ {
+ return SIMPLE;
+ }
+ // SASL
+ else if ( SASL.value.equalsIgnoreCase( s ) )
+ {
+ return SASL;
+ }
+ else
+ {
+ throw new ParseException( "Unable to parse string '" + s + "' as a valid bind method.", 0 );
+ }
+ }
+
+
+ /**
+ * Creates a new instance of BindMethod.
+ *
+ * @param value the value
+ */
+ private BindMethod( String value )
+ {
+ this.value = value;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public String toString()
+ {
+ return value;
+ }
+}
Added: directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/Interval.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/Interval.java?rev=1669163&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/Interval.java (added)
+++ directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/Interval.java Wed Mar 25 17:16:24 2015
@@ -0,0 +1,275 @@
+/*
+ * 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.studio.openldap.syncrepl;
+
+
+import java.text.ParseException;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+
+/**
+ * This class implements an interval.
+ * <p>
+ * Format: "dd:hh:mm:ss"
+ */
+public class Interval
+{
+ /** The pattern used for parsing */
+ private static final Pattern pattern = Pattern.compile( "^([0-9]{2}):([0-9]{2}):([0-9]{2}):([0-9]{2})$" );
+
+ /** The days */
+ private int days;
+
+ /** The hours */
+ private int hours;
+
+ /** The minutes */
+ private int minutes;
+
+ /** The seconds */
+ private int seconds;
+
+
+ /**
+ * Creates a new instance of Interval.
+ *
+ */
+ public Interval()
+ {
+ }
+
+
+ /**
+ * Creates a new instance of Interval.
+ *
+ * @param days the days
+ * @param hours the hours
+ * @param minutes the minutes
+ * @param seconds the seconds
+ */
+ public Interval( int days, int hours, int minutes, int seconds )
+ {
+ this.days = days;
+ this.hours = hours;
+ this.minutes = minutes;
+ this.seconds = seconds;
+ }
+
+
+ /**
+ * Gets a copy of a Interval object.
+ *
+ * @param syncRepl the initial Interval object
+ * @return a copy of the given Interval object
+ */
+ public static Interval copy( Interval interval )
+ {
+ if ( interval != null )
+ {
+ Interval intervalCopy = new Interval();
+
+ intervalCopy.setDays( interval.getDays() );
+ intervalCopy.setHours( interval.getHours() );
+ intervalCopy.setMinutes( interval.getMinutes() );
+ intervalCopy.setSeconds( interval.getSeconds() );
+
+ return intervalCopy;
+ }
+
+ return null;
+ }
+
+
+ /**
+ * Gets a copy of the Interval object.
+ *
+ * @return a copy of the Interval object
+ */
+ public Interval copy()
+ {
+ return Interval.copy( this );
+ }
+
+
+ /**
+ * Parses an interval string.
+ *
+ * @param s the string
+ * @return an interval
+ * @throws ParseException if an error occurs during parsing
+ */
+ public static Interval parse( String s ) throws ParseException
+ {
+ // Creating the interval
+ Interval interval = new Interval();
+
+ // Matching the string
+ Matcher matcher = pattern.matcher( s );
+
+ // Checking the result
+ if ( matcher.find() )
+ {
+ // Days
+ String days = matcher.group( 1 );
+
+ try
+ {
+ interval.setDays( Integer.parseInt( days ) );
+ }
+ catch ( NumberFormatException e )
+ {
+ throw new ParseException( "Unable to convert days value '" + days + "' as an integer.", 0 );
+ }
+
+ // Hours
+ String hours = matcher.group( 2 );
+
+ try
+ {
+ interval.setHours( Integer.parseInt( hours ) );
+ }
+ catch ( NumberFormatException e )
+ {
+ throw new ParseException( "Unable to convert hours value '" + hours + "' as an integer.", 0 );
+ }
+
+ // Minutes
+ String minutes = matcher.group( 3 );
+
+ try
+ {
+ interval.setMinutes( Integer.parseInt( minutes ) );
+ }
+ catch ( NumberFormatException e )
+ {
+ throw new ParseException( "Unable to convert minutes value '" + minutes + "' as an integer.", 0 );
+ }
+
+ // Seconds
+ String seconds = matcher.group( 4 );
+
+ try
+ {
+ interval.setSeconds( Integer.parseInt( seconds ) );
+ }
+ catch ( NumberFormatException e )
+ {
+ throw new ParseException( "Unable to convert seconds value '" + seconds + "' as an integer.", 0 );
+ }
+ }
+ else
+ {
+ throw new ParseException( "Unable to parse string '" + s + "' as a valid interval.", 0 );
+ }
+
+ return interval;
+ }
+
+
+ public int getDays()
+ {
+ return days;
+ }
+
+
+ public int getHours()
+ {
+ return hours;
+ }
+
+
+ public int getMinutes()
+ {
+ return minutes;
+ }
+
+
+ public int getSeconds()
+ {
+ return seconds;
+ }
+
+
+ public void setDays( int days )
+ {
+ this.days = days;
+ }
+
+
+ public void setHours( int hours )
+ {
+ this.hours = hours;
+ }
+
+
+ public void setMinutes( int minutes )
+ {
+ this.minutes = minutes;
+ }
+
+
+ public void setSeconds( int seconds )
+ {
+ this.seconds = seconds;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder();
+
+ sb.append( intValToString( days ) );
+ sb.append( ":" );
+ sb.append( intValToString( hours ) );
+ sb.append( ":" );
+ sb.append( intValToString( minutes ) );
+ sb.append( ":" );
+ sb.append( intValToString( seconds ) );
+
+ return sb.toString();
+
+ }
+
+
+ /**
+ * Gets the string value for the given integer.
+ * <p>
+ * Makes sure the int is printed with two letters.
+ *
+ * @param val the integer
+ * @return the string value for the given integer
+ */
+ private String intValToString( int val )
+ {
+ if ( val < 10 )
+ {
+ return "0" + val;
+
+ }
+ else
+ {
+ return "" + val;
+ }
+ }
+}
Added: directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/KeepAlive.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/KeepAlive.java?rev=1669163&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/KeepAlive.java (added)
+++ directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/KeepAlive.java Wed Mar 25 17:16:24 2015
@@ -0,0 +1,219 @@
+/*
+ * 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.studio.openldap.syncrepl;
+
+
+import java.text.ParseException;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+
+/**
+ * This class implements a keep alive.
+ * <p>
+ * Format: "<idle>:<probes>:<interval>"
+ */
+public class KeepAlive
+{
+ /** The pattern used for parsing */
+ private static final Pattern pattern = Pattern.compile( "^([0-9]+):([0-9]+):([0-9]+)$" );
+
+ /** The idle */
+ private int idle;
+
+ /** The probes */
+ private int probes;
+
+ /** The interval */
+ private int interval;
+
+
+ /**
+ * Creates a new instance of KeepAlive.
+ */
+ public KeepAlive()
+ {
+ }
+
+
+ /**
+ * Creates a new instance of KeepAlive.
+ *
+ * @param idle the idle
+ * @param probes the probes
+ * @param interval the interval
+ */
+ public KeepAlive( int idle, int probes, int interval )
+ {
+ this.idle = idle;
+ this.probes = probes;
+ this.interval = interval;
+ }
+
+
+ /**
+ * Gets a copy of a KeepAlive object.
+ *
+ * @param syncRepl the initial KeepAlive object
+ * @return a copy of the given KeepAlive object
+ */
+ public static KeepAlive copy( KeepAlive keepAlive )
+ {
+ if ( keepAlive != null )
+ {
+ KeepAlive keepAliveCopy = new KeepAlive();
+
+ keepAliveCopy.setIdle( keepAlive.getIdle() );
+ keepAliveCopy.setProbes( keepAlive.getProbes() );
+ keepAliveCopy.setInterval( keepAlive.getInterval() );
+
+ return keepAliveCopy;
+ }
+
+ return null;
+ }
+
+
+ /**
+ * Gets a copy of the KeepAlive object.
+ *
+ * @return a copy of the KeepAlive object
+ */
+ public KeepAlive copy()
+ {
+ return KeepAlive.copy( this );
+ }
+
+
+ /**
+ * Parses a keep alive string.
+ *
+ * @param s the string
+ * @return a keep alive
+ * @throws ParseException if an error occurs during parsing
+ */
+ public static KeepAlive parse( String s ) throws ParseException
+ {
+ // Creating the keep alive
+ KeepAlive keepAlive = new KeepAlive();
+
+ // Matching the string
+ Matcher matcher = pattern.matcher( s );
+
+ // Checking the result
+ if ( matcher.find() )
+ {
+ // Idle
+ String idle = matcher.group( 1 );
+
+ try
+ {
+ keepAlive.setIdle( Integer.parseInt( idle ) );
+ }
+ catch ( NumberFormatException e )
+ {
+ throw new ParseException( "Unable to convert idle value '" + idle + "' as an integer.", 0 );
+ }
+
+ // Probes
+ String probes = matcher.group( 2 );
+
+ try
+ {
+ keepAlive.setProbes( Integer.parseInt( probes ) );
+ }
+ catch ( NumberFormatException e )
+ {
+ throw new ParseException( "Unable to convert probes value '" + probes + "' as an integer.", 0 );
+ }
+
+ // Interval
+ String interval = matcher.group( 3 );
+
+ try
+ {
+ keepAlive.setInterval( Integer.parseInt( interval ) );
+ }
+ catch ( NumberFormatException e )
+ {
+ throw new ParseException( "Unable to convert interval value '" + interval + "' as an integer.", 0 );
+ }
+ }
+ else
+ {
+ throw new ParseException( "Unable to parse string '" + s + "' as a valid keep alive.", 0 );
+ }
+
+ return keepAlive;
+ }
+
+
+ public int getIdle()
+ {
+ return idle;
+ }
+
+
+ public int getProbes()
+ {
+ return probes;
+ }
+
+
+ public int getInterval()
+ {
+ return interval;
+ }
+
+
+ public void setIdle( int idle )
+ {
+ this.idle = idle;
+ }
+
+
+ public void setProbes( int probes )
+ {
+ this.probes = probes;
+ }
+
+
+ public void setInterval( int interval )
+ {
+ this.interval = interval;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder();
+
+ sb.append( idle );
+ sb.append( ":" );
+ sb.append( probes );
+ sb.append( ":" );
+ sb.append( interval );
+
+ return sb.toString();
+ }
+}
Added: directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/Provider.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/Provider.java?rev=1669163&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/Provider.java (added)
+++ directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/Provider.java Wed Mar 25 17:16:24 2015
@@ -0,0 +1,226 @@
+/*
+ * 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.studio.openldap.syncrepl;
+
+
+import java.text.ParseException;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.directory.api.util.Strings;
+
+
+/**
+ * This class implements a provider.
+ * <p>
+ * Format: "ldap[s]://<hostname>[:port]"
+ */
+public class Provider
+{
+ /** Constant used as port value when no port is provided */
+ public static final int NO_PORT = -1;
+
+ /** The pattern used for parsing */
+ private static final Pattern pattern = Pattern
+ .compile( "^[l|L][d|D][a|A][p|P]([s|S]?)://([^:]+)([:]([0-9]{1,5}))?$" );
+
+ /** The LDAPS flag */
+ private boolean isLdaps;
+
+ /** The host */
+ private String host;
+
+ /** The port */
+ private int port = NO_PORT;
+
+
+ /**
+ * Creates a new instance of Provider.
+ */
+ public Provider()
+ {
+ // TODO Auto-generated constructor stub
+ }
+
+
+ /**
+ * Creates a new instance of Provider.
+ *
+ * @param isLdaps the LDAPS flag
+ * @param host the host
+ * @param port the port
+ */
+ public Provider( boolean isLdaps, String host, int port )
+ {
+ this.isLdaps = isLdaps;
+ this.host = host;
+ this.port = port;
+ }
+
+
+ /**
+ * Gets a copy of a Provider object.
+ *
+ * @param provier the initial Provider object
+ * @return a copy of the given Provider object
+ */
+ public static Provider copy( Provider provider )
+ {
+ if ( provider != null )
+ {
+ Provider providerCopy = new Provider();
+
+ providerCopy.setHost( provider.getHost() );
+ providerCopy.setPort( provider.getPort() );
+ providerCopy.setLdaps( provider.isLdaps() );
+
+ return providerCopy;
+ }
+
+ return null;
+ }
+
+
+ /**
+ * Gets a copy of the Provider object.
+ *
+ * @return a copy of the Provider object
+ */
+ public Provider copy()
+ {
+ return Provider.copy( this );
+ }
+
+
+ /**
+ * Parses a provider string.
+ *
+ * @param s the string
+ * @return a provider
+ * @throws ParseException if an error occurs during parsing
+ */
+ public static Provider parse( String s ) throws ParseException
+ {
+ // Creating the provider
+ Provider provider = new Provider();
+
+ // Matching the string
+ Matcher matcher = pattern.matcher( s );
+
+ // Checking the result
+ if ( matcher.find() )
+ {
+ // LDAPS
+ provider.setLdaps( "s".equalsIgnoreCase( matcher.group( 1 ) ) );
+
+ // Host
+ String host = matcher.group( 2 );
+
+ if ( !Strings.isEmpty( host ) )
+ {
+ provider.setHost( host );
+ }
+
+ // Port
+ String port = matcher.group( 4 );
+
+ if ( !Strings.isEmpty( port ) )
+ {
+ try
+ {
+ provider.setPort( Integer.parseInt( port ) );
+ }
+ catch ( NumberFormatException e )
+ {
+ throw new ParseException( "Unable to convert port value '" + port + "' as an integer.", 0 );
+ }
+ }
+ }
+ else
+ {
+ throw new ParseException( "Unable to parse string '" + s + "' as a valid provider.", 0 );
+ }
+
+ return provider;
+ }
+
+
+ public boolean isLdaps()
+ {
+ return isLdaps;
+ }
+
+
+ public String getHost()
+ {
+ return host;
+ }
+
+
+ public int getPort()
+ {
+ return port;
+ }
+
+
+ public void setLdaps( boolean isLdaps )
+ {
+ this.isLdaps = isLdaps;
+ }
+
+
+ public void setHost( String host )
+ {
+ this.host = host;
+ }
+
+
+ public void setPort( int port )
+ {
+ this.port = port;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder();
+
+ sb.append( "ldap" );
+
+ if ( isLdaps )
+ {
+ sb.append( "s" );
+ }
+
+ sb.append( "://" );
+ sb.append( host );
+
+ if ( port != NO_PORT )
+ {
+ sb.append( ":" );
+ sb.append( port );
+ }
+
+ return sb.toString();
+ }
+}
Added: directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/Retry.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/Retry.java?rev=1669163&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/Retry.java (added)
+++ directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/Retry.java Wed Mar 25 17:16:24 2015
@@ -0,0 +1,172 @@
+/*
+ * 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.studio.openldap.syncrepl;
+
+
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+
+/**
+ * This class implements a retry.
+ * <p>
+ * Format: "[<retry interval> <# of retries>]+"
+ */
+public class Retry
+{
+ /** The pattern used for parsing */
+ private static final Pattern pattern = Pattern.compile( "^(([0-9]+) ([0-9]+|\\+))( ([0-9]+) ([0-9]+|\\+))*$" );
+
+ /** The pairs */
+ private List<RetryPair> pairs = new ArrayList<RetryPair>();
+
+ /**
+ * Gets a copy of a Retry object.
+ *
+ * @param syncRepl the initial Retry object
+ * @return a copy of the given Retry object
+ */
+ public static Retry copy( Retry retry )
+ {
+ if ( retry != null )
+ {
+ Retry retryCopy = new Retry();
+
+ for ( RetryPair retryPair : retry.getPairs() )
+ {
+ retryCopy.addPair( RetryPair.copy( retryPair ) );
+ }
+
+ return retryCopy;
+ }
+
+ return null;
+ }
+
+
+ /**
+ * Gets a copy of the Retry object.
+ *
+ * @return a copy of the Retry object
+ */
+ public Retry copy()
+ {
+ return Retry.copy( this );
+ }
+
+
+ /**
+ * Parses a retry string.
+ *
+ * @param s the string
+ * @return a retry
+ * @throws ParseException if an error occurs during parsing
+ */
+ public static Retry parse( String s ) throws ParseException
+ {
+ // Creating the retry
+ Retry retry = new Retry();
+
+ // Matching the string
+ Matcher matcher = pattern.matcher( s );
+
+ // Checking the result
+ if ( matcher.find() )
+ {
+ // Splitting the string into pieces
+ String[] pieces = s.split( " " );
+
+ // Checking we got a even number of pieces
+ if ( ( pieces.length % 2 ) == 0 )
+ {
+ for ( int i = 0; i < pieces.length; i = i + 2 )
+ {
+ retry.addPair( RetryPair.parse( pieces[i] + " " + pieces[i + 1] ) );
+ }
+ }
+ else
+ {
+ throw new ParseException( "Unable to parse string '" + s + "' as a valid retry.", 0 );
+ }
+ }
+ else
+ {
+ throw new ParseException( "Unable to parse string '" + s + "' as a valid retry.", 0 );
+ }
+
+ return retry;
+ }
+
+
+ public void addPair( RetryPair pair )
+ {
+ pairs.add( pair );
+ }
+
+
+ public RetryPair[] getPairs()
+ {
+ return pairs.toArray( new RetryPair[0] );
+ }
+
+
+ public void removePair( RetryPair pair )
+ {
+ pairs.remove( pair );
+ }
+
+
+ public void setPairs( RetryPair[] pairs )
+ {
+ this.pairs = new ArrayList<RetryPair>();
+ this.pairs.addAll( Arrays.asList( pairs ) );
+ }
+
+
+ public int size()
+ {
+ return pairs.size();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder();
+
+ for ( int i = 0; i < pairs.size(); i++ )
+ {
+ sb.append( pairs.get( i ).toString() );
+
+ if ( i != ( pairs.size() - 1 ) )
+ {
+ sb.append( " " );
+ }
+ }
+
+ return sb.toString();
+ }
+}
Added: directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/RetryPair.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/RetryPair.java?rev=1669163&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/RetryPair.java (added)
+++ directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/RetryPair.java Wed Mar 25 17:16:24 2015
@@ -0,0 +1,184 @@
+/*
+ * 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.studio.openldap.syncrepl;
+
+
+import java.text.ParseException;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+
+/**
+ * This class implements a retry pair.
+ * <p>
+ * Format: "<retry interval> <# of retries>"
+ */
+public class RetryPair
+{
+ /** The '+' retries value */
+ public static final int PLUS = -1;
+
+ /** The pattern used for parsing */
+ private static final Pattern pattern = Pattern.compile( "^([0-9]+) ([0-9]+|\\+)$" );
+
+ /** The interval */
+ private int interval;
+
+ /** The retries */
+ private int retries;
+
+
+ /**
+ * Gets a copy of a RetryPair object.
+ *
+ * @param syncRepl the initial RetryPair object
+ * @return a copy of the given RetryPair object
+ */
+ public static RetryPair copy( RetryPair retryPair )
+ {
+ if ( retryPair != null )
+ {
+ RetryPair retryPairCopy = new RetryPair();
+
+ retryPairCopy.setInterval( retryPair.getInterval() );
+ retryPairCopy.setRetries( retryPair.getRetries() );
+
+ return retryPairCopy;
+ }
+
+ return null;
+ }
+
+
+ /**
+ * Gets a copy of the RetryPair object.
+ *
+ * @return a copy of the RetryPair object
+ */
+ public RetryPair copy()
+ {
+ return RetryPair.copy( this );
+ }
+
+
+ /**
+ * Parses a retry pair string.
+ *
+ * @param s the string
+ * @return a retry pair
+ * @throws ParseException if an error occurs during parsing
+ */
+ public static RetryPair parse( String s ) throws ParseException
+ {
+ // Creating the retry pair
+ RetryPair retryPair = new RetryPair();
+
+ // Matching the string
+ Matcher matcher = pattern.matcher( s );
+
+ // Checking the result
+ if ( matcher.find() )
+ {
+ // Interval
+ String interval = matcher.group( 1 );
+
+ try
+ {
+ retryPair.setInterval( Integer.parseInt( interval ) );
+ }
+ catch ( NumberFormatException e )
+ {
+ throw new ParseException( "Unable to convert interval value '" + interval + "' as an integer.", 0 );
+ }
+
+ // Retries
+ String retries = matcher.group( 2 );
+
+ if ( "+".equalsIgnoreCase( retries ) )
+ {
+ retryPair.setRetries( PLUS );
+ }
+ else
+ {
+ try
+ {
+ retryPair.setRetries( Integer.parseInt( retries ) );
+ }
+ catch ( NumberFormatException e )
+ {
+ throw new ParseException( "Unable to convert retries value '" + retries + "' as an integer.", 0 );
+ }
+ }
+ }
+ else
+ {
+ throw new ParseException( "Unable to parse string '" + s + "' as a valid retry pair.", 0 );
+ }
+
+ return retryPair;
+ }
+
+
+ public int getInterval()
+ {
+ return interval;
+ }
+
+
+ public int getRetries()
+ {
+ return retries;
+ }
+
+
+ public void setInterval( int interval )
+ {
+ this.interval = interval;
+ }
+
+
+ public void setRetries( int retries )
+ {
+ this.retries = retries;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder();
+
+ sb.append( interval );
+ sb.append( " " );
+
+ if ( retries == PLUS )
+ {
+ sb.append( "+" );
+ }
+ else
+ {
+ sb.append( retries );
+ }
+
+ return sb.toString();
+ }
+}
Added: directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/SaslMechanism.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/SaslMechanism.java?rev=1669163&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/SaslMechanism.java (added)
+++ directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/SaslMechanism.java Wed Mar 25 17:16:24 2015
@@ -0,0 +1,111 @@
+/*
+ * 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.studio.openldap.syncrepl;
+
+
+import java.text.ParseException;
+
+
+/**
+ * This enum implements all the possible values for the SASL mechanism value.
+ */
+public enum SaslMechanism
+{
+ /** The 'digest-md5' SASL mechanism */
+ DIGEST_MD5("DIGEST-MD5", "digest-md5"),
+
+ /** The 'gssapi' SASL mechanism */
+ GSSAPI("GSSAPI", "gssapi"), ;
+
+ /** The title */
+ private String title;
+
+ /** The value */
+ private String value;
+
+
+ /**
+ * Parses a sasl mechanism string.
+ *
+ * @param s the string
+ * @return a sasl mechanism
+ * @throws ParseException if an error occurs during parsing
+ */
+ public static SaslMechanism parse( String s ) throws ParseException
+ {
+ // DIGEST_MD5
+ if ( DIGEST_MD5.value.equalsIgnoreCase( s ) )
+ {
+ return DIGEST_MD5;
+ }
+ // GSSAPI
+ else if ( GSSAPI.value.equalsIgnoreCase( s ) )
+ {
+ return GSSAPI;
+ }
+ else
+ {
+ throw new ParseException( "Unable to parse string '" + s + "' as a valid sasl mechanism method.", 0 );
+ }
+ }
+
+
+ /**
+ * Creates a new instance of SaslMechanism.
+ *
+ * @param value the value
+ */
+ private SaslMechanism( String title, String value )
+ {
+ this.title = title;
+ this.value = value;
+ }
+
+
+ /**
+ * Gets the title.
+ *
+ * @return the title
+ */
+ public String getTitle()
+ {
+ return title;
+ }
+
+
+ /**
+ * Gets the value.
+ *
+ * @return the value
+ */
+ public String getValue()
+ {
+ return value;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public String toString()
+ {
+ return title;
+ }
+}
Added: directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/SchemaChecking.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/SchemaChecking.java?rev=1669163&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/SchemaChecking.java (added)
+++ directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/SchemaChecking.java Wed Mar 25 17:16:24 2015
@@ -0,0 +1,85 @@
+/*
+ * 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.studio.openldap.syncrepl;
+
+
+import java.text.ParseException;
+
+
+/**
+ * This enum implements all the possible values for the schema checking value.
+ */
+public enum SchemaChecking
+{
+ /** The 'on' schema checking value */
+ ON("on"),
+
+ /** The 'off' schema checking value */
+ OFF("off");
+
+ /** The value */
+ private String value;
+
+
+ /**
+ * Parses a schema checking string.
+ *
+ * @param s the string
+ * @return a schema checking
+ * @throws ParseException if an error occurs during parsing
+ */
+ public static SchemaChecking parse( String s ) throws ParseException
+ {
+ // ON
+ if ( ON.value.equalsIgnoreCase( s ) )
+ {
+ return ON;
+ }
+ // OFF
+ else if ( OFF.value.equalsIgnoreCase( s ) )
+ {
+ return OFF;
+ }
+ else
+ {
+ throw new ParseException( "Unable to parse string '" + s + "' as a valid schema checking.", 0 );
+ }
+ }
+
+
+ /**
+ * Creates a new instance of SchemaChecking.
+ *
+ * @param value the value
+ */
+ private SchemaChecking( String value )
+ {
+ this.value = value;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public String toString()
+ {
+ return value;
+ }
+}
Added: directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/Scope.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/Scope.java?rev=1669163&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/Scope.java (added)
+++ directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/Scope.java Wed Mar 25 17:16:24 2015
@@ -0,0 +1,101 @@
+/*
+ * 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.studio.openldap.syncrepl;
+
+
+import java.text.ParseException;
+
+
+/**
+ * This enum implements all the possible values for the scope value.
+ */
+public enum Scope
+{
+ /** The 'sub' scope value */
+ SUB("sub"),
+
+ /** The 'one' scope value */
+ ONE("one"),
+
+ /** The 'base' scope value */
+ BASE("base"),
+
+ /** The 'subord' scope value */
+ SUBORD("subord");
+
+ /** The value */
+ private String value;
+
+
+ /**
+ * Parses a scope string.
+ *
+ * @param s the string
+ * @return a scope
+ * @throws ParseException if an error occurs during parsing
+ */
+ public static Scope parse( String s ) throws ParseException
+ {
+ // SUB
+ if ( SUB.value.equalsIgnoreCase( s ) )
+ {
+ return SUB;
+ }
+ // ONE
+ else if ( ONE.value.equalsIgnoreCase( s ) )
+ {
+ return ONE;
+ }
+ // BASE
+ else if ( BASE.value.equalsIgnoreCase( s ) )
+ {
+ return BASE;
+ }
+ // SUBORD
+ else if ( SUBORD.value.equalsIgnoreCase( s ) )
+ {
+ return SUBORD;
+ }
+ else
+ {
+ throw new ParseException( "Unable to parse string '" + s + "' as a valid scope.", 0 );
+ }
+ }
+
+
+ /**
+ * Creates a new instance of Scope.
+ *
+ * @param value the value
+ */
+ private Scope( String value )
+ {
+ this.value = value;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public String toString()
+ {
+ return value;
+ }
+}
Added: directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/StartTls.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/StartTls.java?rev=1669163&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/StartTls.java (added)
+++ directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/StartTls.java Wed Mar 25 17:16:24 2015
@@ -0,0 +1,85 @@
+/*
+ * 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.studio.openldap.syncrepl;
+
+
+import java.text.ParseException;
+
+
+/**
+ * This enum implements all the possible values for the Start TLS value.
+ */
+public enum StartTls
+{
+ /** The 'yes' Start TLS value */
+ YES("yes"),
+
+ /** The 'critical' Start TLS value */
+ CRITICAL("critical");
+
+ /** The value */
+ private String value;
+
+
+ /**
+ * Parses a start tls string.
+ *
+ * @param s the string
+ * @return a bind method
+ * @throws ParseException if an error occurs during parsing
+ */
+ public static StartTls parse( String s ) throws ParseException
+ {
+ // YES
+ if ( YES.value.equalsIgnoreCase( s ) )
+ {
+ return YES;
+ }
+ // CRITICAL
+ else if ( CRITICAL.value.equalsIgnoreCase( s ) )
+ {
+ return CRITICAL;
+ }
+ else
+ {
+ throw new ParseException( "Unable to parse string '" + s + "' as a valid start tls.", 0 );
+ }
+ }
+
+
+ /**
+ * Creates a new instance of StartTls.
+ *
+ * @param value the value
+ */
+ private StartTls( String value )
+ {
+ this.value = value;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public String toString()
+ {
+ return value;
+ }
+}
Added: directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/SyncData.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/SyncData.java?rev=1669163&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/SyncData.java (added)
+++ directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/SyncData.java Wed Mar 25 17:16:24 2015
@@ -0,0 +1,93 @@
+/*
+ * 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.studio.openldap.syncrepl;
+
+
+import java.text.ParseException;
+
+
+/**
+ * This enum implements all the possible values for the Sync Data value.
+ */
+public enum SyncData
+{
+ /** The 'default' Sync Data value */
+ DEFAULT("default"),
+
+ /** The 'accesslog' Sync Data value */
+ ACCESSLOG("accesslog"),
+
+ /** The 'changelog' Sync Data value */
+ CHANGELOG("changelog");
+
+ /** The value */
+ private String value;
+
+
+ /**
+ * Parses a sync data string.
+ *
+ * @param s the string
+ * @return a sync data
+ * @throws ParseException if an error occurs during parsing
+ */
+ public static SyncData parse( String s ) throws ParseException
+ {
+ // DEFAULT
+ if ( DEFAULT.value.equalsIgnoreCase( s ) )
+ {
+ return DEFAULT;
+ }
+ // ACCESSLOG
+ else if ( ACCESSLOG.value.equalsIgnoreCase( s ) )
+ {
+ return ACCESSLOG;
+ }
+ // CHANGELOG
+ else if ( CHANGELOG.value.equalsIgnoreCase( s ) )
+ {
+ return CHANGELOG;
+ }
+ else
+ {
+ throw new ParseException( "Unable to parse string '" + s + "' as a valid sync data.", 0 );
+ }
+ }
+
+
+ /**
+ * Creates a new instance of SyncData.
+ *
+ * @param value the value
+ */
+ private SyncData( String value )
+ {
+ this.value = value;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public String toString()
+ {
+ return value;
+ }
+}
Added: directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/SyncRepl.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/SyncRepl.java?rev=1669163&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/SyncRepl.java (added)
+++ directory/studio/trunk/plugins/openldap.syncrepl/src/main/java/org/apache/directory/studio/openldap/syncrepl/SyncRepl.java Wed Mar 25 17:16:24 2015
@@ -0,0 +1,1018 @@
+/*
+ * 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.studio.openldap.syncrepl;
+
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+
+/**
+ * This class implements a SyncRepl object.
+ */
+public class SyncRepl
+{
+ /** The replica ID */
+ private String rid;
+
+ /** The provider */
+ private Provider provider;
+
+ /** The search base */
+ private String searchBase;
+
+ /** The type */
+ private Type type;
+
+ /** The interval */
+ private Interval interval;
+
+ /** The retry */
+ private Retry retry;
+
+ /** The filter */
+ private String filter;
+
+ /** The scope */
+ private Scope scope;
+
+ /** The attributes */
+ private List<String> attributes = new ArrayList<String>();
+
+ /** The attrsonly flag */
+ private boolean isAttrsOnly;
+
+ /** The size limit */
+ private int sizeLimit = -1;
+
+ /** The time limit */
+ private int timeLimit = -1;
+
+ /** The schema checking */
+ private SchemaChecking schemaChecking;
+
+ /** The network timeout */
+ private int networkTimeout = -1;
+
+ /** The timeout */
+ private int timeout = -1;
+
+ /** The bind method */
+ private BindMethod bindMethod;
+
+ /** The bind dn */
+ private String bindDn;
+
+ /** The sasl mech */
+ private String saslMech;
+
+ /** The authentication id */
+ private String authcid;
+
+ /** The authorization id */
+ private String authzid;
+
+ /** The credentials */
+ private String credentials;
+
+ /** The realm */
+ private String realm;
+
+ /** The sec props */
+ private String secProps;
+
+ /** The keep alive */
+ private KeepAlive keepAlive;
+
+ /** The Start TLS */
+ private StartTls startTls;
+
+ /** The TLS cert */
+ private String tlsCert;
+
+ /** The TLS key */
+ private String tlsKey;
+
+ /** The TLS cacert */
+ private String tlsCacert;
+
+ /** The TLS cacert dir */
+ private String tlsCacertDir;
+
+ /** The TLS reqcert */
+ private TlsReqCert tlsReqcert;
+
+ /** The TLS cipher suite */
+ private String tlsCipherSuite;
+
+ /** The TLS crl check */
+ private TlsCrlCheck tlsCrlcheck;
+
+ /** The log base */
+ private String logBase;
+
+ /** The log filter */
+ private String logFilter;
+
+ /** The sync data */
+ private SyncData syncData;
+
+
+ public SyncRepl()
+ {
+ // TODO Auto-generated constructor stub
+ }
+
+
+ /**
+ * Creates a default SyncRepl value.
+ *
+ * @return a default SyncRepl value
+ */
+ public static SyncRepl createDefault()
+ {
+ SyncRepl syncRepl = new SyncRepl();
+
+ return syncRepl;
+ }
+
+
+ /**
+ * Gets a copy of a SyncRepl object.
+ *
+ * @param syncRepl the initial SyncRepl object
+ * @return a copy of the given SyncRepl object
+ */
+ public static SyncRepl copy( SyncRepl syncRepl )
+ {
+ if ( syncRepl != null )
+ {
+ SyncRepl syncReplCopy = new SyncRepl();
+
+ syncReplCopy.setRid( syncRepl.getRid() );
+ syncReplCopy.setProvider( Provider.copy( syncRepl.getProvider() ) );
+ syncReplCopy.setSearchBase( syncRepl.getSearchBase() );
+ syncReplCopy.setType( syncRepl.getType() );
+ syncReplCopy.setInterval( Interval.copy( syncRepl.getInterval() ) );
+ syncReplCopy.setRetry( Retry.copy( syncRepl.getRetry() ) );
+ syncReplCopy.setFilter( syncRepl.getFilter() );
+ syncReplCopy.setScope( syncRepl.getScope() );
+ syncReplCopy.addAttribute( syncRepl.getAttributes() );
+ syncReplCopy.setAttrsOnly( syncRepl.isAttrsOnly() );
+ syncReplCopy.setSizeLimit( syncRepl.getSizeLimit() );
+ syncReplCopy.setTimeLimit( syncRepl.getTimeLimit() );
+ syncReplCopy.setSchemaChecking( syncRepl.getSchemaChecking() );
+ syncReplCopy.setNetworkTimeout( syncRepl.getNetworkTimeout() );
+ syncReplCopy.setTimeout( syncRepl.getTimeout() );
+ syncReplCopy.setBindMethod( syncRepl.getBindMethod() );
+ syncReplCopy.setBindDn( syncRepl.getBindDn() );
+ syncReplCopy.setSaslMech( syncRepl.getSaslMech() );
+ syncReplCopy.setAuthcid( syncRepl.getAuthcid() );
+ syncReplCopy.setAuthzid( syncRepl.getAuthzid() );
+ syncReplCopy.setCredentials( syncRepl.getCredentials() );
+ syncReplCopy.setRealm( syncRepl.getRealm() );
+ syncReplCopy.setSecProps( syncRepl.getSecProps() );
+ syncReplCopy.setKeepAlive( KeepAlive.copy( syncRepl.getKeepAlive() ) );
+ syncReplCopy.setStartTls( syncRepl.getStartTls() );
+ syncReplCopy.setTlsCert( syncRepl.getTlsCert() );
+ syncReplCopy.setTlsKey( syncRepl.getTlsKey() );
+ syncReplCopy.setTlsCacert( syncRepl.getTlsCacert() );
+ syncReplCopy.setTlsCacertDir( syncRepl.getTlsCacertDir() );
+ syncReplCopy.setTlsReqcert( syncRepl.getTlsReqcert() );
+ syncReplCopy.setTlsCipherSuite( syncRepl.getTlsCipherSuite() );
+ syncReplCopy.setTlsCrlcheck( syncRepl.getTlsCrlcheck() );
+ syncReplCopy.setLogBase( syncRepl.getLogBase() );
+ syncReplCopy.setLogFilter( syncRepl.getLogFilter() );
+ syncReplCopy.setSyncData( syncRepl.getSyncData() );
+
+ return syncReplCopy;
+ }
+
+ return null;
+ }
+
+
+ /**
+ * Gets a copy of the SyncRepl object.
+ *
+ * @return a copy of the SyncRepl object
+ */
+ public SyncRepl copy()
+ {
+ return SyncRepl.copy( this );
+ }
+
+
+ public String getRid()
+ {
+ return rid;
+ }
+
+
+ public String getSearchBase()
+ {
+ return searchBase;
+ }
+
+
+ public Type getType()
+ {
+ return type;
+ }
+
+
+ public Interval getInterval()
+ {
+ return interval;
+ }
+
+
+ public Retry getRetry()
+ {
+ return retry;
+ }
+
+
+ public String getFilter()
+ {
+ return filter;
+ }
+
+
+ public Scope getScope()
+ {
+ return scope;
+ }
+
+
+ public String[] getAttributes()
+ {
+ return attributes.toArray( new String[0] );
+ }
+
+
+ public boolean isAttrsOnly()
+ {
+ return isAttrsOnly;
+ }
+
+
+ public int getSizeLimit()
+ {
+ return sizeLimit;
+ }
+
+
+ public int getTimeLimit()
+ {
+ return timeLimit;
+ }
+
+
+ public SchemaChecking getSchemaChecking()
+ {
+ return schemaChecking;
+ }
+
+
+ public int getNetworkTimeout()
+ {
+ return networkTimeout;
+ }
+
+
+ public int getTimeout()
+ {
+ return timeout;
+ }
+
+
+ public BindMethod getBindMethod()
+ {
+ return bindMethod;
+ }
+
+
+ public String getBindDn()
+ {
+ return bindDn;
+ }
+
+
+ public String getSaslMech()
+ {
+ return saslMech;
+ }
+
+
+ public String getAuthcid()
+ {
+ return authcid;
+ }
+
+
+ public String getAuthzid()
+ {
+ return authzid;
+ }
+
+
+ public String getCredentials()
+ {
+ return credentials;
+ }
+
+
+ public String getRealm()
+ {
+ return realm;
+ }
+
+
+ public String getSecProps()
+ {
+ return secProps;
+ }
+
+
+ public KeepAlive getKeepAlive()
+ {
+ return keepAlive;
+ }
+
+
+ public StartTls getStartTls()
+ {
+ return startTls;
+ }
+
+
+ public String getTlsCert()
+ {
+ return tlsCert;
+ }
+
+
+ public String getTlsKey()
+ {
+ return tlsKey;
+ }
+
+
+ public String getTlsCacert()
+ {
+ return tlsCacert;
+ }
+
+
+ public String getTlsCacertDir()
+ {
+ return tlsCacertDir;
+ }
+
+
+ public TlsReqCert getTlsReqcert()
+ {
+ return tlsReqcert;
+ }
+
+
+ public String getTlsCipherSuite()
+ {
+ return tlsCipherSuite;
+ }
+
+
+ public TlsCrlCheck getTlsCrlcheck()
+ {
+ return tlsCrlcheck;
+ }
+
+
+ public String getLogBase()
+ {
+ return logBase;
+ }
+
+
+ public String getLogFilter()
+ {
+ return logFilter;
+ }
+
+
+ public SyncData getSyncData()
+ {
+ return syncData;
+ }
+
+
+ public void setRid( String rid )
+ {
+ this.rid = rid;
+ }
+
+
+ public Provider getProvider()
+ {
+ return provider;
+ }
+
+
+ public void setProvider( Provider provider )
+ {
+ this.provider = provider;
+ }
+
+
+ public void setSearchBase( String searchBase )
+ {
+ this.searchBase = searchBase;
+ }
+
+
+ public void setType( Type type )
+ {
+ this.type = type;
+ }
+
+
+ public void setInterval( Interval interval )
+ {
+ this.interval = interval;
+ }
+
+
+ public void setRetry( Retry retry )
+ {
+ this.retry = retry;
+ }
+
+
+ public void setFilter( String filter )
+ {
+ this.filter = filter;
+ }
+
+
+ public void setScope( Scope scope )
+ {
+ this.scope = scope;
+ }
+
+
+ public void addAttribute( String... attributes )
+ {
+ if ( attributes != null )
+ {
+ for ( String attribute : attributes )
+ {
+ this.attributes.add( attribute );
+ }
+ }
+ }
+
+
+ public void removeAttribute( String... attributes )
+ {
+ if ( attributes != null )
+ {
+ for ( String attribute : attributes )
+ {
+ this.attributes.remove( attribute );
+ }
+ }
+ }
+
+
+ public void setAttributes( String[] attributes )
+ {
+ this.attributes.clear();
+ this.attributes.addAll( Arrays.asList( attributes ) );
+ }
+
+
+ public void setAttrsOnly( boolean isAttrsOnly )
+ {
+ this.isAttrsOnly = isAttrsOnly;
+ }
+
+
+ public void setSizeLimit( int sizeLimit )
+ {
+ this.sizeLimit = sizeLimit;
+ }
+
+
+ public void setTimeLimit( int timeLimit )
+ {
+ this.timeLimit = timeLimit;
+ }
+
+
+ public void setSchemaChecking( SchemaChecking schemaChecking )
+ {
+ this.schemaChecking = schemaChecking;
+ }
+
+
+ public void setNetworkTimeout( int networkTimeout )
+ {
+ this.networkTimeout = networkTimeout;
+ }
+
+
+ public void setTimeout( int timeout )
+ {
+ this.timeout = timeout;
+ }
+
+
+ public void setBindMethod( BindMethod bindMethod )
+ {
+ this.bindMethod = bindMethod;
+ }
+
+
+ public void setBindDn( String bindDn )
+ {
+ this.bindDn = bindDn;
+ }
+
+
+ public void setSaslMech( String saslMech )
+ {
+ this.saslMech = saslMech;
+ }
+
+
+ public void setAuthcid( String authcid )
+ {
+ this.authcid = authcid;
+ }
+
+
+ public void setAuthzid( String authzid )
+ {
+ this.authzid = authzid;
+ }
+
+
+ public void setCredentials( String credentials )
+ {
+ this.credentials = credentials;
+ }
+
+
+ public void setRealm( String realm )
+ {
+ this.realm = realm;
+ }
+
+
+ public void setSecProps( String secProps )
+ {
+ this.secProps = secProps;
+ }
+
+
+ public void setKeepAlive( KeepAlive keepAlive )
+ {
+ this.keepAlive = keepAlive;
+ }
+
+
+ public void setStartTls( StartTls startTls )
+ {
+ this.startTls = startTls;
+ }
+
+
+ public void setTlsCert( String tlsCert )
+ {
+ this.tlsCert = tlsCert;
+ }
+
+
+ public void setTlsKey( String tlsKey )
+ {
+ this.tlsKey = tlsKey;
+ }
+
+
+ public void setTlsCacert( String tlsCacert )
+ {
+ this.tlsCacert = tlsCacert;
+ }
+
+
+ public void setTlsCacertDir( String tlsCacertDir )
+ {
+ this.tlsCacertDir = tlsCacertDir;
+ }
+
+
+ public void setTlsReqcert( TlsReqCert tlsReqcert )
+ {
+ this.tlsReqcert = tlsReqcert;
+ }
+
+
+ public void setTlsCipherSuite( String tlsCipherSuite )
+ {
+ this.tlsCipherSuite = tlsCipherSuite;
+ }
+
+
+ public void setTlsCrlcheck( TlsCrlCheck tlsCrlcheck )
+ {
+ this.tlsCrlcheck = tlsCrlcheck;
+ }
+
+
+ public void setLogBase( String logBase )
+ {
+ this.logBase = logBase;
+ }
+
+
+ public void setLogFilter( String logFilter )
+ {
+ this.logFilter = logFilter;
+ }
+
+
+ public void setSyncData( SyncData syncData )
+ {
+ this.syncData = syncData;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder();
+
+ // Replica ID
+ if ( rid != null )
+ {
+ sb.append( "rid=" );
+ sb.append( rid );
+ }
+
+ // Provider
+ if ( provider != null )
+ {
+ appendSpaceIfNeeded( sb );
+ sb.append( "provider=" );
+ sb.append( provider.toString() );
+ }
+
+ // Search Base
+ if ( searchBase != null )
+ {
+ appendSpaceIfNeeded( sb );
+ sb.append( "searchbase=" );
+ sb.append( '"' );
+ sb.append( escapeDoubleQuotes( searchBase ) );
+ sb.append( '"' );
+ }
+
+ // Type
+ if ( type != null )
+ {
+ appendSpaceIfNeeded( sb );
+ sb.append( "type=" );
+ sb.append( type );
+ }
+
+ // Interval
+ if ( interval != null )
+ {
+ appendSpaceIfNeeded( sb );
+ sb.append( "interval=" );
+ sb.append( interval );
+ }
+
+ // Retry
+ if ( retry != null )
+ {
+ appendSpaceIfNeeded( sb );
+ sb.append( "retry=" );
+ sb.append( '"' );
+ sb.append( escapeDoubleQuotes( retry.toString() ) );
+ sb.append( '"' );
+ }
+
+ // Filter
+ if ( filter != null )
+ {
+ appendSpaceIfNeeded( sb );
+ sb.append( "filter=" );
+ sb.append( '"' );
+ sb.append( escapeDoubleQuotes( filter ) );
+ sb.append( '"' );
+ }
+
+ // Scope
+ if ( scope != null )
+ {
+ appendSpaceIfNeeded( sb );
+ sb.append( "scope=" );
+ sb.append( scope );
+ }
+
+ // Attributes
+ if ( ( attributes != null ) && ( attributes.size() > 0 ) )
+ {
+ appendSpaceIfNeeded( sb );
+ sb.append( "attrs=" );
+ sb.append( '"' );
+
+ // Looping on all attributes
+ for ( int i = 0; i < attributes.size(); i++ )
+ {
+ // Adding the attribute
+ sb.append( attributes.get( i ) );
+
+ // Adding the separator (except for the last one)
+ if ( i != attributes.size() - 1 )
+ {
+ sb.append( ',' );
+ }
+ }
+
+ sb.append( '"' );
+ }
+
+ // Attrsonly Flag
+ if ( isAttrsOnly )
+ {
+ appendSpaceIfNeeded( sb );
+ sb.append( "attrsonly" );
+ }
+
+ // Size Limit
+ if ( sizeLimit != -1 )
+ {
+ appendSpaceIfNeeded( sb );
+ sb.append( "sizelimit=" );
+ sb.append( sizeLimit );
+ }
+
+ // Time Limit
+ if ( timeLimit != -1 )
+ {
+ appendSpaceIfNeeded( sb );
+ sb.append( "timelimit=" );
+ sb.append( timeLimit );
+ }
+
+ // Schema Checking
+ if ( schemaChecking != null )
+ {
+ appendSpaceIfNeeded( sb );
+ sb.append( "schemachecking=" );
+ sb.append( schemaChecking );
+ }
+
+ // Network Timeout
+ if ( networkTimeout != -1 )
+ {
+ appendSpaceIfNeeded( sb );
+ sb.append( "network-timeout=" );
+ sb.append( networkTimeout );
+ }
+
+ // Timeout
+ if ( timeout != -1 )
+ {
+ appendSpaceIfNeeded( sb );
+ sb.append( "timeout=" );
+ sb.append( timeout );
+ }
+
+ // Bind Method
+ if ( bindMethod != null )
+ {
+ appendSpaceIfNeeded( sb );
+ sb.append( "bindmethod=" );
+ sb.append( bindMethod );
+ }
+
+ // Bind DN
+ if ( bindDn != null )
+ {
+ appendSpaceIfNeeded( sb );
+ sb.append( "binddn=" );
+ sb.append( '"' );
+ sb.append( bindDn );
+ sb.append( '"' );
+ }
+
+ // SASL Mech
+ if ( saslMech != null )
+ {
+ appendSpaceIfNeeded( sb );
+ sb.append( "saslmech=" );
+ sb.append( saslMech );
+ }
+
+ // Authentication ID
+ if ( authcid != null )
+ {
+ appendSpaceIfNeeded( sb );
+ sb.append( "authcid=" );
+ sb.append( '"' );
+ sb.append( authcid );
+ sb.append( '"' );
+ }
+
+ // Authorization ID
+ if ( authzid != null )
+ {
+ appendSpaceIfNeeded( sb );
+ sb.append( "authzid=" );
+ sb.append( '"' );
+ sb.append( authzid );
+ sb.append( '"' );
+ }
+
+ // Credentials
+ if ( credentials != null )
+ {
+ appendSpaceIfNeeded( sb );
+ sb.append( "credentials=" );
+ sb.append( credentials );
+ }
+
+ // Realm
+ if ( realm != null )
+ {
+ appendSpaceIfNeeded( sb );
+ sb.append( "realm=" );
+ sb.append( realm );
+ }
+
+ // Sec Props
+ if ( secProps != null )
+ {
+ appendSpaceIfNeeded( sb );
+ sb.append( "secProps=" );
+ sb.append( secProps );
+ }
+
+ // Keep Alive
+ if ( keepAlive != null )
+ {
+ appendSpaceIfNeeded( sb );
+ sb.append( "keepalive=" );
+ sb.append( keepAlive );
+ }
+
+ // Start TLS
+ if ( startTls != null )
+ {
+ appendSpaceIfNeeded( sb );
+ sb.append( "starttls=" );
+ sb.append( startTls );
+ }
+
+ // TLS Cert
+ if ( tlsCert != null )
+ {
+ appendSpaceIfNeeded( sb );
+ sb.append( "tls_cert=" );
+ sb.append( tlsCert );
+ }
+
+ // TLS Key
+ if ( tlsKey != null )
+ {
+ appendSpaceIfNeeded( sb );
+ sb.append( "tls_key=" );
+ sb.append( tlsKey );
+ }
+
+ // TLS Cacert
+ if ( tlsCacert != null )
+ {
+ appendSpaceIfNeeded( sb );
+ sb.append( "tls_cacert=" );
+ sb.append( tlsCacert );
+ }
+
+ // TLS Cacert Dir
+ if ( tlsCacertDir != null )
+ {
+ appendSpaceIfNeeded( sb );
+ sb.append( "tls_cacertdir=" );
+ sb.append( tlsCacertDir );
+ }
+
+ // TLS Reqcert
+ if ( tlsReqcert != null )
+ {
+ appendSpaceIfNeeded( sb );
+ sb.append( "tls_reqcert=" );
+ sb.append( tlsReqcert );
+ }
+
+ // TLS Cipher Suite
+ if ( tlsCipherSuite != null )
+ {
+ appendSpaceIfNeeded( sb );
+ sb.append( "tls_ciphersuite=" );
+ sb.append( tlsCipherSuite );
+ }
+
+ // TLS Crl Check
+ if ( tlsCrlcheck != null )
+ {
+ appendSpaceIfNeeded( sb );
+ sb.append( "tls_crlcheck=" );
+ sb.append( tlsCrlcheck );
+ }
+
+ // Log Base
+ if ( logBase != null )
+ {
+ appendSpaceIfNeeded( sb );
+ sb.append( "logbase=" );
+ sb.append( '"' );
+ sb.append( escapeDoubleQuotes( logBase ) );
+ sb.append( '"' );
+ }
+
+ // Log Filter
+ if ( logFilter != null )
+ {
+ appendSpaceIfNeeded( sb );
+ sb.append( "logfilter=" );
+ sb.append( '"' );
+ sb.append( escapeDoubleQuotes( logFilter ) );
+ sb.append( '"' );
+ }
+
+ // Sync Data
+ if ( syncData != null )
+ {
+ appendSpaceIfNeeded( sb );
+ sb.append( "syncdata=" );
+ sb.append( syncData );
+ }
+
+ return sb.toString();
+ }
+
+
+ /**
+ * Appends a space if the string is not empty.
+ *
+ * @param sb the string
+ */
+ private void appendSpaceIfNeeded( StringBuilder sb )
+ {
+ if ( ( sb != null ) && ( sb.length() > 0 ) )
+ {
+ sb.append( " " );
+ }
+ }
+
+
+ /**
+ * Escapes all double quotes (") found in the given text.
+ *
+ * @param text the text
+ * @return a string where all double quotes are escaped
+ */
+ private String escapeDoubleQuotes( String text )
+ {
+ if ( text != null )
+ {
+ return text.replace( "\"", "\\\"" );
+ }
+
+ return null;
+ }
+}