aboutsummaryrefslogtreecommitdiffstats
path: root/redback-common
diff options
context:
space:
mode:
authorOlivier Lamy <olamy@apache.org>2012-04-06 09:58:14 +0000
committerOlivier Lamy <olamy@apache.org>2012-04-06 09:58:14 +0000
commit5b06b6673ee8eaed4b46ad8e847e98fe4c90319d (patch)
treee184a7512cd005f5baaf82a94e13fd67646cc2ea /redback-common
parentbe9e1800fdcb3c37c566220c1b2b79650d375000 (diff)
downloadarchiva-5b06b6673ee8eaed4b46ad8e847e98fe4c90319d.tar.gz
archiva-5b06b6673ee8eaed4b46ad8e847e98fe4c90319d.zip
import of redback core sources
http://svn.codehaus.org/redback/redback/trunk/ r1724 git-svn-id: https://svn.apache.org/repos/asf/archiva/redback/redback-core/trunk@1310268 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'redback-common')
-rw-r--r--redback-common/pom.xml32
-rw-r--r--redback-common/redback-common-jdo/pom.xml80
-rw-r--r--redback-common/redback-common-jdo/src/main/java/org/codehaus/plexus/redback/common/jdo/UserConfigurableJdoFactory.java109
-rw-r--r--redback-common/redback-common-jdo/src/main/java/org/codehaus/plexus/redback/common/jdo/test/StoreManagerDebug.java110
-rw-r--r--redback-common/redback-common-jdo/src/main/resources/META-INF/spring-context.xml33
-rw-r--r--redback-common/redback-common-ldap/pom.xml60
-rw-r--r--redback-common/redback-common-ldap/src/main/java/org/codehaus/plexus/redback/common/ldap/LdapUser.java246
-rw-r--r--redback-common/redback-common-ldap/src/main/java/org/codehaus/plexus/redback/common/ldap/LdapUserMapper.java310
-rw-r--r--redback-common/redback-common-ldap/src/main/java/org/codehaus/plexus/redback/common/ldap/LdapUtils.java129
-rw-r--r--redback-common/redback-common-ldap/src/main/java/org/codehaus/plexus/redback/common/ldap/MappingException.java36
-rw-r--r--redback-common/redback-common-ldap/src/main/java/org/codehaus/plexus/redback/common/ldap/UserMapper.java61
-rw-r--r--redback-common/redback-common-ldap/src/main/java/org/codehaus/plexus/redback/common/ldap/UserUpdate.java67
-rw-r--r--redback-common/redback-common-ldap/src/main/java/org/codehaus/plexus/redback/common/ldap/connection/ConfigurableLdapConnectionFactory.java283
-rw-r--r--redback-common/redback-common-ldap/src/main/java/org/codehaus/plexus/redback/common/ldap/connection/LdapConnection.java273
-rw-r--r--redback-common/redback-common-ldap/src/main/java/org/codehaus/plexus/redback/common/ldap/connection/LdapConnectionConfiguration.java348
-rw-r--r--redback-common/redback-common-ldap/src/main/java/org/codehaus/plexus/redback/common/ldap/connection/LdapConnectionFactory.java56
-rw-r--r--redback-common/redback-common-ldap/src/main/java/org/codehaus/plexus/redback/common/ldap/connection/LdapException.java45
-rw-r--r--redback-common/redback-common-ldap/src/main/resources/META-INF/spring-context.xml33
-rw-r--r--redback-common/redback-common-ldap/src/test/java/org/codehaus/plexus/redback/common/ldap/LdapUserMapperTest.java41
-rw-r--r--redback-common/redback-common-ldap/src/test/java/org/codehaus/plexus/redback/common/ldap/connection/ConfigurableLdapConnectionFactoryTest.java44
-rw-r--r--redback-common/redback-common-ldap/src/test/resources/spring-context.xml37
-rw-r--r--redback-common/redback-common-ldap/src/test/resources/test.properties10
-rw-r--r--redback-common/redback-common-test-resources/pom.xml29
-rw-r--r--redback-common/redback-common-test-resources/src/main/resources/META-INF/redback/redback-core.xml228
-rw-r--r--redback-common/redback-common-test-resources/src/main/resources/org/codehaus/plexus/redback/config-defaults.properties130
25 files changed, 2830 insertions, 0 deletions
diff --git a/redback-common/pom.xml b/redback-common/pom.xml
new file mode 100644
index 000000000..d2b1117e9
--- /dev/null
+++ b/redback-common/pom.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2006 The Codehaus.
+ ~
+ ~ Licensed 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.
+ -->
+<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.codehaus.redback</groupId>
+ <artifactId>redback</artifactId>
+ <version>1.5-SNAPSHOT</version>
+ </parent>
+ <artifactId>redback-common</artifactId>
+ <name>Redback :: Commons</name>
+ <packaging>pom</packaging>
+ <modules>
+ <module>redback-common-jdo</module>
+ <module>redback-common-ldap</module>
+ <module>redback-common-test-resources</module>
+ </modules>
+</project> \ No newline at end of file
diff --git a/redback-common/redback-common-jdo/pom.xml b/redback-common/redback-common-jdo/pom.xml
new file mode 100644
index 000000000..acd373596
--- /dev/null
+++ b/redback-common/redback-common-jdo/pom.xml
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2006 The Codehaus.
+ ~
+ ~ Licensed 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.
+ -->
+<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.codehaus.redback</groupId>
+ <artifactId>redback-common</artifactId>
+ <version>1.5-SNAPSHOT</version>
+ </parent>
+ <artifactId>redback-common-jdo</artifactId>
+ <name>Redback :: JDO Common API</name>
+ <packaging>jar</packaging>
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.redback.components</groupId>
+ <artifactId>spring-jdo2</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>jpox</groupId>
+ <artifactId>jpox</artifactId>
+ <scope>compile</scope>
+ <exclusions>
+ <!-- targeting JDK 1.4 we don't need this -->
+ <exclusion>
+ <groupId>javax.sql</groupId>
+ <artifactId>jdbc-stdext</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </exclusion>
+
+ <exclusion>
+ <groupId>javax.resource</groupId>
+ <artifactId>connector</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>javax.transaction</groupId>
+ <artifactId>jta</artifactId>
+ </exclusion>
+
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.redback</groupId>
+ <artifactId>redback-configuration</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context-support</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.annotation</groupId>
+ <artifactId>jsr250-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/redback-common/redback-common-jdo/src/main/java/org/codehaus/plexus/redback/common/jdo/UserConfigurableJdoFactory.java b/redback-common/redback-common-jdo/src/main/java/org/codehaus/plexus/redback/common/jdo/UserConfigurableJdoFactory.java
new file mode 100644
index 000000000..8c64244e3
--- /dev/null
+++ b/redback-common/redback-common-jdo/src/main/java/org/codehaus/plexus/redback/common/jdo/UserConfigurableJdoFactory.java
@@ -0,0 +1,109 @@
+package org.codehaus.plexus.redback.common.jdo;
+
+import org.apache.commons.lang.StringUtils;
+import org.codehaus.plexus.interpolation.InterpolationException;
+import org.codehaus.plexus.interpolation.PropertiesBasedValueSource;
+import org.codehaus.plexus.interpolation.StringSearchInterpolator;
+import org.codehaus.plexus.jdo.DefaultConfigurableJdoFactory;
+import org.codehaus.plexus.redback.configuration.UserConfiguration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.PostConstruct;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+/**
+ * UserConfigurableJdoFactory
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+@Service( "jdoFactory#users" )
+public class UserConfigurableJdoFactory
+ extends DefaultConfigurableJdoFactory
+{
+
+ private Logger log = LoggerFactory.getLogger( getClass() );
+
+ @Inject
+ @Named( value = "userConfiguration" )
+ private UserConfiguration config;
+
+ private String getConfigString( String key, String currentValue, String defaultValue )
+ {
+ String valueFromSysProps = System.getProperty( "redback." + key );
+ if (StringUtils.isNotEmpty( valueFromSysProps ))
+ {
+ return valueFromSysProps;
+ }
+ String value = null;
+ if ( StringUtils.isNotEmpty( currentValue ) )
+ {
+ value = config.getString( key, currentValue );
+ }
+ else
+ {
+ value = config.getString( key, defaultValue );
+ }
+ // do some interpolation as we can have some ${plexus.home} etc...
+ StringSearchInterpolator interpolator = new StringSearchInterpolator();
+ interpolator.addValueSource( new PropertiesBasedValueSource( System.getProperties() ) );
+
+ try
+ {
+ return interpolator.interpolate( value );
+ }
+ catch ( InterpolationException e )
+ {
+ // ignore interpolation issue
+ log.warn( "skip issue during interpolation " + e.getMessage() );
+ return value;
+ }
+ }
+
+ @PostConstruct
+ public void initialize()
+ {
+ String jdbcDriverName =
+ getConfigString( "jdbc.driver.name", super.getDriverName(), "org.apache.derby.jdbc.EmbeddedDriver" );
+ String jdbcUrl =
+ getConfigString( "jdbc.url", super.getUrl(), "jdbc:derby:${plexus.home}/database;create=true" );
+
+ String jdbcUsername = getConfigString( "jdbc.username", super.getUserName(), "sa" );
+ String jdbcPassword = getConfigString( "jdbc.password", super.getPassword(), "" );
+
+ super.setDriverName( jdbcDriverName );
+ super.setUrl( jdbcUrl );
+ super.setUserName( jdbcUsername );
+ super.setPassword( jdbcPassword );
+
+ if ( StringUtils.isEmpty( super.persistenceManagerFactoryClass ) )
+ {
+ super.setPersistenceManagerFactoryClass( "org.jpox.PersistenceManagerFactoryImpl" );
+ }
+
+ if ( ( super.otherProperties == null ) || super.otherProperties.isEmpty() )
+ {
+ super.setProperty( "org.jpox.autoCreateSchema", "true" );
+ super.setProperty( "org.jpox.validateSchema", "false" );
+ super.setProperty( "org.jpox.validateTables", "false" );
+ super.setProperty( "org.jpox.validateConstraints", "false" );
+ super.setProperty( "org.jpox.transactionIsolation", "READ_COMMITTED" );
+ super.setProperty( "org.jpox.rdbms.dateTimezone", "JDK_DEFAULT_TIMEZONE" );
+ }
+
+ super.initialize();
+ }
+
+ public UserConfiguration getConfig()
+ {
+ return config;
+ }
+
+ public void setConfig( UserConfiguration config )
+ {
+ this.config = config;
+ }
+}
diff --git a/redback-common/redback-common-jdo/src/main/java/org/codehaus/plexus/redback/common/jdo/test/StoreManagerDebug.java b/redback-common/redback-common-jdo/src/main/java/org/codehaus/plexus/redback/common/jdo/test/StoreManagerDebug.java
new file mode 100644
index 000000000..a2ef47086
--- /dev/null
+++ b/redback-common/redback-common-jdo/src/main/java/org/codehaus/plexus/redback/common/jdo/test/StoreManagerDebug.java
@@ -0,0 +1,110 @@
+package org.codehaus.plexus.redback.common.jdo.test;
+
+/*
+ * Copyright 2009 The Codehaus
+ *
+ * Licensed 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.
+ */
+
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import javax.jdo.PersistenceManager;
+
+import org.jpox.AbstractPersistenceManagerFactory;
+import org.jpox.ClassLoaderResolver;
+import org.jpox.plugin.ConfigurationElement;
+import org.jpox.plugin.Extension;
+import org.jpox.store.rdbms.RDBMSManager;
+
+/**
+ * A extension to JPOX store manager that allows counting the SQL queries
+ *
+ * @author Carlos Sanchez <a href="mailto:carlos@apache.org">
+ */
+public class StoreManagerDebug
+ extends RDBMSManager
+{
+ private static int counter;
+
+ public StoreManagerDebug( ClassLoaderResolver clr, AbstractPersistenceManagerFactory pmf, String userName,
+ String password )
+ {
+ super( clr, pmf, userName, password );
+ }
+
+ /**
+ * This method will change JPOX store manager extension so it uses our class instead of whatever is configured in
+ * the plugin.xml
+ *
+ * @param pmf
+ */
+ public static void setup( AbstractPersistenceManagerFactory pmf )
+ {
+ /* set our own Store Manager to allow counting SQL statements */
+ Extension[] extensions =
+ pmf.getPMFContext().getPluginManager().getExtensionPoint( "org.jpox.store_manager" ).getExtensions();
+ Extension e = extensions[0];
+ for ( ConfigurationElement element : e.getConfigurationElements() )
+ {
+ element.putAttribute( "class-name", StoreManagerDebug.class.getName() );
+ }
+ }
+
+ /**
+ * Get the currently configured store manager from JPOX. Will fail if
+ * {@link #setup(AbstractPersistenceManagerFactory)} is not called first.
+ *
+ * @param persistenceManager
+ * @return
+ */
+ public static StoreManagerDebug getConfiguredStoreManager( PersistenceManager persistenceManager )
+ {
+ return (StoreManagerDebug) ( (org.jpox.PersistenceManager) persistenceManager ).getStoreManager();
+ }
+
+ @Override
+ public int[] executeStatementBatch( String stmt, PreparedStatement ps )
+ throws SQLException
+ {
+ counter++;
+ return super.executeStatementBatch( stmt, ps );
+ }
+
+ @Override
+ public ResultSet executeStatementQuery( String stmt, PreparedStatement ps )
+ throws SQLException
+ {
+ counter++;
+ return super.executeStatementQuery( stmt, ps );
+ }
+
+ @Override
+ public int executeStatementUpdate( String stmt, PreparedStatement ps )
+ throws SQLException
+ {
+ counter++;
+ return super.executeStatementUpdate( stmt, ps );
+ }
+
+ public void resetCounter()
+ {
+ counter = 0;
+ }
+
+ public int counter()
+ {
+ return counter;
+ }
+}
diff --git a/redback-common/redback-common-jdo/src/main/resources/META-INF/spring-context.xml b/redback-common/redback-common-jdo/src/main/resources/META-INF/spring-context.xml
new file mode 100644
index 000000000..49255786e
--- /dev/null
+++ b/redback-common/redback-common-jdo/src/main/resources/META-INF/spring-context.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0"?>
+
+<!--
+ ~ 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.
+ -->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+ http://www.springframework.org/schema/context
+ http://www.springframework.org/schema/context/spring-context-3.0.xsd"
+ default-lazy-init="true">
+
+ <bean name="jdoFactory#users" class="org.codehaus.plexus.redback.common.jdo.UserConfigurableJdoFactory">
+ <property name="config" ref="userConfiguration"/>
+ </bean>
+</beans> \ No newline at end of file
diff --git a/redback-common/redback-common-ldap/pom.xml b/redback-common/redback-common-ldap/pom.xml
new file mode 100644
index 000000000..df2e102ee
--- /dev/null
+++ b/redback-common/redback-common-ldap/pom.xml
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2006 The Codehaus.
+ ~
+ ~ Licensed 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.
+ -->
+<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.codehaus.redback</groupId>
+ <artifactId>redback-common</artifactId>
+ <version>1.5-SNAPSHOT</version>
+ </parent>
+ <artifactId>redback-common-ldap</artifactId>
+ <name>Redback :: Ldap Common API</name>
+ <packaging>jar</packaging>
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.redback</groupId>
+ <artifactId>redback-configuration</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.redback</groupId>
+ <artifactId>redback-users-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context-support</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.annotation</groupId>
+ <artifactId>jsr250-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ </dependency>
+ <!--
+ <dependency>
+ <groupId>org.apache.directory.shared</groupId>
+ <artifactId>shared-ldap-client-api</artifactId>
+ </dependency>
+ -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/redback-common/redback-common-ldap/src/main/java/org/codehaus/plexus/redback/common/ldap/LdapUser.java b/redback-common/redback-common-ldap/src/main/java/org/codehaus/plexus/redback/common/ldap/LdapUser.java
new file mode 100644
index 000000000..cfb31da27
--- /dev/null
+++ b/redback-common/redback-common-ldap/src/main/java/org/codehaus/plexus/redback/common/ldap/LdapUser.java
@@ -0,0 +1,246 @@
+package org.codehaus.plexus.redback.common.ldap;
+
+/*
+ * Copyright 2001-2007 The Codehaus.
+ *
+ * Licensed 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.
+ */
+
+import org.codehaus.plexus.redback.users.User;
+
+import javax.naming.directory.Attributes;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+// TODO this class should be able to be replaced with a model
+public class LdapUser
+ implements User, Serializable
+{
+
+ private String key;
+
+ private String username;
+
+ private String fullName;
+
+ private String email;
+
+ private String encodedPassword;
+
+ private List<String> previousEncodedPasswords;
+
+ private boolean locked = false;
+
+ private boolean requiresPasswordChange = false;
+
+ private boolean permanent = true;
+
+ private boolean valid = true;
+
+ private Date creationDate = null;
+
+ private int failedLoginAttempts;
+
+ private Date lastLoginDate = null;
+
+ private Date lastPasswordChange = null;
+
+ // DO NOT STORE AS SUCH!!!
+ private String newPassword;
+
+ private Attributes originalAttributes;
+
+ public LdapUser( String username )
+ {
+ key = username;
+ this.username = username;
+ previousEncodedPasswords = new ArrayList<String>( 0 );
+ failedLoginAttempts = 0;
+ }
+
+ public LdapUser( String username, String fullName, String email )
+ {
+ this( username );
+ this.fullName = fullName;
+ this.email = email;
+ }
+
+ public LdapUser()
+ {
+ previousEncodedPasswords = new ArrayList<String>( 0 );
+ failedLoginAttempts = Integer.MIN_VALUE;
+ }
+
+ public void addPreviousEncodedPassword( String encodedPassword )
+ {
+ previousEncodedPasswords.add( encodedPassword );
+ }
+
+ public Date getAccountCreationDate()
+ {
+ return creationDate;
+ }
+
+ public int getCountFailedLoginAttempts()
+ {
+ return failedLoginAttempts;
+ }
+
+ public String getEmail()
+ {
+ return email;
+ }
+
+ public String getEncodedPassword()
+ {
+ return encodedPassword;
+ }
+
+ public String getFullName()
+ {
+ return fullName;
+ }
+
+ public Date getLastLoginDate()
+ {
+ return lastLoginDate;
+ }
+
+ public Date getLastPasswordChange()
+ {
+ return lastPasswordChange;
+ }
+
+ public String getPassword()
+ {
+ return newPassword;
+ }
+
+ public List<String> getPreviousEncodedPasswords()
+ {
+ return previousEncodedPasswords;
+ }
+
+ public Object getPrincipal()
+ {
+ return key;
+ }
+
+ public String getUsername()
+ {
+ return username;
+ }
+
+ public boolean isLocked()
+ {
+ return locked;
+ }
+
+ public boolean isPasswordChangeRequired()
+ {
+ return requiresPasswordChange;
+ }
+
+ public boolean isPermanent()
+ {
+ return permanent;
+ }
+
+ public boolean isValidated()
+ {
+ return valid;
+ }
+
+ public void setCountFailedLoginAttempts( int count )
+ {
+ failedLoginAttempts = count;
+ }
+
+ public void setEmail( String address )
+ {
+ email = address;
+ }
+
+ public void setEncodedPassword( String encodedPassword )
+ {
+ this.encodedPassword = encodedPassword;
+ }
+
+ public void setFullName( String name )
+ {
+ fullName = name;
+ }
+
+ public void setAccountCreationDate( Date date )
+ {
+ creationDate = date;
+ }
+
+ public void setLastLoginDate( Date date )
+ {
+ lastLoginDate = date;
+ }
+
+ public void setLastPasswordChange( Date passwordChangeDate )
+ {
+ lastPasswordChange = passwordChangeDate;
+ }
+
+ public void setLocked( boolean locked )
+ {
+ this.locked = locked;
+ }
+
+ public void setPassword( String rawPassword )
+ {
+ newPassword = rawPassword;
+ }
+
+ public void setPasswordChangeRequired( boolean changeRequired )
+ {
+ requiresPasswordChange = changeRequired;
+ }
+
+ public void setPermanent( boolean permanent )
+ {
+ this.permanent = permanent;
+ }
+
+ public void setPreviousEncodedPasswords( List<String> encodedPasswordList )
+ {
+ previousEncodedPasswords = new ArrayList<String>( encodedPasswordList );
+ }
+
+ public void setUsername( String name )
+ {
+ username = name;
+ }
+
+ public void setValidated( boolean valid )
+ {
+ this.valid = valid;
+ }
+
+ public Attributes getOriginalAttributes()
+ {
+ return originalAttributes;
+ }
+
+ public void setOriginalAttributes( Attributes originalAttributes )
+ {
+ this.originalAttributes = originalAttributes;
+ }
+
+}
diff --git a/redback-common/redback-common-ldap/src/main/java/org/codehaus/plexus/redback/common/ldap/LdapUserMapper.java b/redback-common/redback-common-ldap/src/main/java/org/codehaus/plexus/redback/common/ldap/LdapUserMapper.java
new file mode 100644
index 000000000..b437a3b54
--- /dev/null
+++ b/redback-common/redback-common-ldap/src/main/java/org/codehaus/plexus/redback/common/ldap/LdapUserMapper.java
@@ -0,0 +1,310 @@
+package org.codehaus.plexus.redback.common.ldap;
+
+/*
+ * Copyright 2001-2007 The Codehaus.
+ *
+ * Licensed 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.
+ */
+
+import org.codehaus.plexus.redback.configuration.UserConfiguration;
+import org.codehaus.plexus.redback.users.User;
+import org.apache.commons.lang.StringUtils;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.PostConstruct;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttributes;
+import java.util.Date;
+
+/**
+ * @author <a href="jesse@codehaus.org"> jesse
+ * @version $Id$
+ */
+@Service( "userMapper#ldap" )
+public class LdapUserMapper
+ implements UserMapper
+{
+ /**
+ *
+ */
+ String emailAttribute = "mail";
+
+ /**
+ *
+ */
+ String fullNameAttribute = "givenName";
+
+ /**
+ *
+ */
+ String passwordAttribute = "userPassword";
+
+ /**
+ *
+ */
+ String userIdAttribute = "cn";
+
+ /**
+ *
+ */
+ String userBaseDn;
+
+ /**
+ *
+ */
+ String userObjectClass = "inetOrgPerson";
+
+ /**
+ *
+ */
+ String userFilter;
+
+ /**
+ *
+ */
+ int maxResultCount = 0;
+
+ @Inject
+ @Named( value = "userConfiguration" )
+ private UserConfiguration userConf;
+
+ @PostConstruct
+ public void initialize()
+ {
+ emailAttribute = userConf.getString( "ldap.config.mapper.attribute.email", emailAttribute );
+ fullNameAttribute = userConf.getString( "ldap.config.mapper.attribute.fullname", fullNameAttribute );
+ passwordAttribute = userConf.getString( "ldap.config.mapper.attribute.password", passwordAttribute );
+ userIdAttribute = userConf.getString( "ldap.config.mapper.attribute.user.id", userIdAttribute );
+ userBaseDn = userConf.getConcatenatedList( "ldap.config.mapper.attribute.user.base.dn",
+ userConf.getConcatenatedList( "ldap.config.base.dn", userBaseDn ) );
+ userObjectClass = userConf.getString( "ldap.config.mapper.attribute.user.object.class", userObjectClass );
+ userFilter = userConf.getString( "ldap.config.mapper.attribute.user.filter", userFilter );
+ maxResultCount = userConf.getInt( "ldap.config.max.result.count", maxResultCount );
+ }
+
+ public Attributes getCreationAttributes( User user, boolean encodePasswordIfChanged )
+ throws MappingException
+ {
+ Attributes userAttrs = new BasicAttributes();
+
+ boolean passwordSet = false;
+
+ if ( !passwordSet && ( user.getEncodedPassword() != null ) )
+ {
+ userAttrs.put( getPasswordAttribute(), user.getEncodedPassword() );
+ }
+
+ if ( !StringUtils.isEmpty( user.getFullName() ) )
+ {
+ userAttrs.put( getUserFullNameAttribute(), user.getFullName() );
+ }
+
+ if ( !StringUtils.isEmpty( user.getEmail() ) )
+ {
+ userAttrs.put( getEmailAddressAttribute(), user.getEmail() );
+ }
+
+ return userAttrs;
+ }
+
+ public String getEmailAddressAttribute()
+ {
+ return emailAttribute;
+ }
+
+ public String getUserFullNameAttribute()
+ {
+ return fullNameAttribute;
+ }
+
+ public String getPasswordAttribute()
+ {
+ return passwordAttribute;
+ }
+
+ public String[] getUserAttributeNames()
+ {
+ return new String[]{ emailAttribute, fullNameAttribute, passwordAttribute, userIdAttribute };
+ }
+
+ public int getMaxResultCount()
+ {
+ return maxResultCount;
+ }
+
+ public UserUpdate getUpdate( LdapUser user )
+ throws MappingException
+ {
+
+ Attributes addAttrs = new BasicAttributes();
+
+ Attributes modAttrs = new BasicAttributes();
+
+ if ( !StringUtils.isEmpty( user.getFullName() ) )
+ {
+ if ( user.getFullName() == null )
+ {
+ addAttrs.put( getUserFullNameAttribute(), user.getFullName() );
+ }
+ else if ( !user.getFullName().equals( user.getFullName() ) )
+ {
+ modAttrs.put( getUserFullNameAttribute(), user.getFullName() );
+ }
+ }
+
+ if ( !StringUtils.isEmpty( user.getEmail() ) )
+ {
+ if ( user.getEmail() == null )
+ {
+ addAttrs.put( getEmailAddressAttribute(), user.getEmail() );
+ }
+ else if ( !user.getEmail().equals( user.getEmail() ) )
+ {
+ modAttrs.put( getEmailAddressAttribute(), user.getEmail() );
+ }
+ }
+
+ return null;
+ }
+
+ public LdapUser getUser( Attributes attributes )
+ throws MappingException
+ {
+ String userIdAttribute = getUserIdAttribute();
+ String emailAddressAttribute = getEmailAddressAttribute();
+ String nameAttribute = getUserFullNameAttribute();
+ String passwordAttribute = getPasswordAttribute();
+
+ String userId = ( LdapUtils.getAttributeValue( attributes, userIdAttribute, "username" ) );
+
+ LdapUser user = new LdapUser( userId );
+ user.setOriginalAttributes( attributes );
+
+ user.setEmail( LdapUtils.getAttributeValue( attributes, emailAddressAttribute, "email address" ) );
+ user.setFullName( LdapUtils.getAttributeValue( attributes, nameAttribute, "name" ) );
+
+ String encodedPassword = LdapUtils.getAttributeValueFromByteArray( attributes, passwordAttribute, "password" );
+
+ // it seems to be a common convention for the password to come back prepended with the encoding type..
+ // however we deal with that via configuration right now so just smoke it.
+ if ( encodedPassword != null && encodedPassword.startsWith( "{" ) )
+ {
+ encodedPassword = encodedPassword.substring( encodedPassword.indexOf( "}" ) + 1 );
+ }
+
+ user.setEncodedPassword( encodedPassword );
+
+ // REDBACK-215: skip NPE
+ user.setLastPasswordChange( new Date() );
+
+ return user;
+ }
+
+ public String getUserIdAttribute()
+ {
+ return userIdAttribute;
+ }
+
+ public String getEmailAttribute()
+ {
+ return emailAttribute;
+ }
+
+ public void setEmailAttribute( String emailAttribute )
+ {
+ this.emailAttribute = emailAttribute;
+ }
+
+ public String getFullNameAttribute()
+ {
+ return fullNameAttribute;
+ }
+
+ public void setFullNameAttribute( String fullNameAttribute )
+ {
+ this.fullNameAttribute = fullNameAttribute;
+ }
+
+ public void setMaxResultCount( int maxResultCount )
+ {
+ this.maxResultCount = maxResultCount;
+ }
+
+ public String getUserBaseDn()
+ {
+ return userBaseDn;
+ }
+
+ public void setUserBaseDn( String userBaseDn )
+ {
+ this.userBaseDn = userBaseDn;
+ }
+
+ public String getUserObjectClass()
+ {
+ return userObjectClass;
+ }
+
+ public String getUserFilter()
+ {
+ return userFilter;
+ }
+
+ public void setUserFilter( String userFilter )
+ {
+ this.userFilter = userFilter;
+ }
+
+ public void setUserObjectClass( String userObjectClass )
+ {
+ this.userObjectClass = userObjectClass;
+ }
+
+ public void setPasswordAttribute( String passwordAttribute )
+ {
+ this.passwordAttribute = passwordAttribute;
+ }
+
+ public void setUserIdAttribute( String userIdAttribute )
+ {
+ this.userIdAttribute = userIdAttribute;
+ }
+
+ public LdapUser newUserInstance( String username, String fullName, String email )
+ {
+ return new LdapUser( username, fullName, email );
+ }
+
+ public LdapUser newTemplateUserInstance()
+ {
+ return new LdapUser();
+ }
+
+ public String[] getReturningAttributes()
+ {
+ return new String[]{ getUserIdAttribute(), getEmailAttribute(), getFullNameAttribute(),
+ getPasswordAttribute() };
+ }
+
+ public UserConfiguration getUserConf()
+ {
+ return userConf;
+ }
+
+ public void setUserConf( UserConfiguration userConf )
+ {
+ this.userConf = userConf;
+ }
+}
diff --git a/redback-common/redback-common-ldap/src/main/java/org/codehaus/plexus/redback/common/ldap/LdapUtils.java b/redback-common/redback-common-ldap/src/main/java/org/codehaus/plexus/redback/common/ldap/LdapUtils.java
new file mode 100644
index 000000000..650408ac0
--- /dev/null
+++ b/redback-common/redback-common-ldap/src/main/java/org/codehaus/plexus/redback/common/ldap/LdapUtils.java
@@ -0,0 +1,129 @@
+package org.codehaus.plexus.redback.common.ldap;
+
+/*
+ * Copyright 2001-2007 The Codehaus.
+ *
+ * Licensed 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.
+ */
+
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+
+/**
+ *
+ * @version $Id$
+ */
+public final class LdapUtils
+{
+ private LdapUtils()
+ {
+ // no op
+ }
+
+ @SuppressWarnings("unchecked")
+ public static String getLabeledUriValue( Attributes attributes, String attrName, String label,
+ String attributeDescription )
+ throws MappingException
+ {
+ if ( attrName == null )
+ {
+ return null;
+ }
+
+ Attribute attribute = attributes.get( attrName );
+ if ( attribute != null )
+ {
+ NamingEnumeration attrs;
+ try
+ {
+ attrs = attribute.getAll();
+ }
+ catch ( NamingException e )
+ {
+ throw new MappingException(
+ "Failed to retrieve " + attributeDescription + " (attribute: \'" + attrName + "\').", e );
+ }
+
+ while ( attrs.hasMoreElements() )
+ {
+ Object value = attrs.nextElement();
+
+ String val = String.valueOf( value );
+
+ if ( val.endsWith( " " + label ) )
+ {
+ return val.substring( 0, val.length() - ( label.length() + 1 ) );
+ }
+ }
+ }
+
+ return null;
+ }
+
+ public static String getAttributeValue( Attributes attributes, String attrName, String attributeDescription )
+ throws MappingException
+ {
+ if ( attrName == null )
+ {
+ return null;
+ }
+
+ Attribute attribute = attributes.get( attrName );
+ if ( attribute != null )
+ {
+ try
+ {
+ Object value = attribute.get();
+
+ return String.valueOf( value );
+ }
+ catch ( NamingException e )
+ {
+ throw new MappingException(
+ "Failed to retrieve " + attributeDescription + " (attribute: \'" + attrName + "\').", e );
+ }
+ }
+
+ return null;
+ }
+
+ public static String getAttributeValueFromByteArray( Attributes attributes, String attrName,
+ String attributeDescription )
+ throws MappingException
+ {
+ if ( attrName == null )
+ {
+ return null;
+ }
+
+ Attribute attribute = attributes.get( attrName );
+ if ( attribute != null )
+ {
+ try
+ {
+ byte[] value = (byte[]) attribute.get();
+
+ return new String( value );
+ }
+ catch ( NamingException e )
+ {
+ throw new MappingException(
+ "Failed to retrieve " + attributeDescription + " (attribute: \'" + attrName + "\').", e );
+ }
+ }
+
+ return null;
+ }
+}
diff --git a/redback-common/redback-common-ldap/src/main/java/org/codehaus/plexus/redback/common/ldap/MappingException.java b/redback-common/redback-common-ldap/src/main/java/org/codehaus/plexus/redback/common/ldap/MappingException.java
new file mode 100644
index 000000000..d7c378b68
--- /dev/null
+++ b/redback-common/redback-common-ldap/src/main/java/org/codehaus/plexus/redback/common/ldap/MappingException.java
@@ -0,0 +1,36 @@
+package org.codehaus.plexus.redback.common.ldap;
+
+/*
+ * Copyright 2001-2007 The Codehaus.
+ *
+ * Licensed 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.
+ */
+
+/**
+ * @version $Id$
+ */
+public class MappingException
+ extends Exception
+{
+
+ public MappingException( String message, Throwable cause )
+ {
+ super( message, cause );
+ }
+
+ public MappingException( String message )
+ {
+ super( message );
+ }
+
+}
diff --git a/redback-common/redback-common-ldap/src/main/java/org/codehaus/plexus/redback/common/ldap/UserMapper.java b/redback-common/redback-common-ldap/src/main/java/org/codehaus/plexus/redback/common/ldap/UserMapper.java
new file mode 100644
index 000000000..ceaeafcc8
--- /dev/null
+++ b/redback-common/redback-common-ldap/src/main/java/org/codehaus/plexus/redback/common/ldap/UserMapper.java
@@ -0,0 +1,61 @@
+package org.codehaus.plexus.redback.common.ldap;
+
+/*
+ * Copyright 2001-2007 The Codehaus.
+ *
+ * Licensed 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.
+ */
+
+import org.codehaus.plexus.redback.users.User;
+
+import javax.naming.directory.Attributes;
+
+/**
+ * @version $Id$
+ */
+public interface UserMapper
+{
+ LdapUser getUser( Attributes attributes )
+ throws MappingException;
+
+ Attributes getCreationAttributes( User user, boolean encodePasswordIfChanged )
+ throws MappingException;
+
+ UserUpdate getUpdate( LdapUser user )
+ throws MappingException;
+
+ String[] getUserAttributeNames();
+
+ String getEmailAddressAttribute();
+
+ String getUserFullNameAttribute();
+
+ String getPasswordAttribute();
+
+ String getUserIdAttribute();
+
+ String getEmailAttribute();
+
+ String getUserBaseDn();
+
+ String getUserObjectClass();
+
+ String getUserFilter();
+
+ LdapUser newUserInstance( String username, String fullName, String email );
+
+ LdapUser newTemplateUserInstance();
+
+ String[] getReturningAttributes();
+
+}
diff --git a/redback-common/redback-common-ldap/src/main/java/org/codehaus/plexus/redback/common/ldap/UserUpdate.java b/redback-common/redback-common-ldap/src/main/java/org/codehaus/plexus/redback/common/ldap/UserUpdate.java
new file mode 100644
index 000000000..fa615aba6
--- /dev/null
+++ b/redback-common/redback-common-ldap/src/main/java/org/codehaus/plexus/redback/common/ldap/UserUpdate.java
@@ -0,0 +1,67 @@
+package org.codehaus.plexus.redback.common.ldap;
+
+/*
+ * Copyright 2001-2007 The Codehaus.
+ *
+ * Licensed 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.
+ */
+
+import javax.naming.directory.Attributes;
+
+/**
+ * @version $Id$
+ */
+public class UserUpdate
+{
+
+ private final Attributes created;
+
+ private final Attributes modified;
+
+ private final Attributes removed;
+
+ public UserUpdate( Attributes created, Attributes modified, Attributes removed )
+ {
+ this.created = created;
+ this.modified = modified;
+ this.removed = removed;
+ }
+
+ public Attributes getAddedAttributes()
+ {
+ return created;
+ }
+
+ public Attributes getModifiedAttributes()
+ {
+ return modified;
+ }
+
+ public Attributes getRemovedAttributes()
+ {
+ return removed;
+ }
+
+ public boolean hasAdditions()
+ {
+ return ( created != null ) && ( created.size() > 0 );
+ }
+
+ public boolean hasModifications()
+ {
+ return ( modified != null ) && ( modified.size() > 0 );
+ }
+
+
+
+}
diff --git a/redback-common/redback-common-ldap/src/main/java/org/codehaus/plexus/redback/common/ldap/connection/ConfigurableLdapConnectionFactory.java b/redback-common/redback-common-ldap/src/main/java/org/codehaus/plexus/redback/common/ldap/connection/ConfigurableLdapConnectionFactory.java
new file mode 100644
index 000000000..7039e4970
--- /dev/null
+++ b/redback-common/redback-common-ldap/src/main/java/org/codehaus/plexus/redback/common/ldap/connection/ConfigurableLdapConnectionFactory.java
@@ -0,0 +1,283 @@
+package org.codehaus.plexus.redback.common.ldap.connection;
+
+/*
+ * The MIT License
+ * Copyright (c) 2005, The Codehaus
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+import org.codehaus.plexus.redback.configuration.UserConfiguration;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.PostConstruct;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.naming.InvalidNameException;
+import javax.naming.ldap.LdapName;
+import javax.naming.ldap.Rdn;
+import javax.naming.spi.ObjectFactory;
+import javax.naming.spi.StateFactory;
+import java.util.Properties;
+
+/**
+ * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
+ * @version $Id$
+ */
+@Service( "ldapConnectionFactory#configurable" )
+public class ConfigurableLdapConnectionFactory
+ implements LdapConnectionFactory
+{
+ /**
+ *
+ */
+ private String hostname;
+
+ /**
+ *
+ */
+ private int port;
+
+ /**
+ *
+ */
+ private boolean ssl;
+
+ /**
+ *
+ */
+ private String baseDn;
+
+ /**
+ *
+ */
+ private String contextFactory;
+
+ /**
+ *
+ */
+ private String bindDn;
+
+ /**
+ *
+ */
+ private String password;
+
+ /**
+ *
+ */
+ private String authenticationMethod;
+
+ /**
+ *
+ */
+ private Properties extraProperties;
+
+ private LdapConnectionConfiguration configuration;
+
+
+ @Inject
+ @Named( value = "userConfiguration" )
+ private UserConfiguration userConf;
+
+ // ----------------------------------------------------------------------
+ // Component Lifecycle
+ // ----------------------------------------------------------------------
+ @PostConstruct
+ public void initialize()
+ {
+ try
+ {
+ configuration = new LdapConnectionConfiguration();
+ configuration.setHostname( userConf.getString( "ldap.config.hostname", hostname ) );
+ configuration.setPort( userConf.getInt( "ldap.config.port", port ) );
+ configuration.setSsl( userConf.getBoolean( "ldap.config.ssl", ssl ) );
+ configuration.setBaseDn( userConf.getConcatenatedList( "ldap.config.base.dn", baseDn ) );
+ configuration.setContextFactory( userConf.getString( "ldap.config.context.factory", contextFactory ) );
+ configuration.setBindDn( userConf.getConcatenatedList( "ldap.config.bind.dn", bindDn ) );
+ configuration.setPassword( userConf.getString( "ldap.config.password", password ) );
+ configuration.setAuthenticationMethod(
+ userConf.getString( "ldap.config.authentication.method", authenticationMethod ) );
+ configuration.setExtraProperties( extraProperties );
+ }
+ catch ( InvalidNameException e )
+ {
+ throw new RuntimeException( "Error while initializing connection factory.", e );
+ }
+ }
+
+ // ----------------------------------------------------------------------
+ // LdapConnectionFactory Implementation
+ // ----------------------------------------------------------------------
+
+ public LdapConnection getConnection()
+ throws LdapException
+ {
+ return new LdapConnection( configuration, null );
+ }
+
+ public LdapConnection getConnection( Rdn subRdn )
+ throws LdapException
+ {
+ return new LdapConnection( configuration, subRdn );
+ }
+
+ public LdapConnection getConnection( String bindDn, String password )
+ throws LdapException
+ {
+ return new LdapConnection( configuration, bindDn, password );
+ }
+
+ public LdapName getBaseDnLdapName()
+ throws LdapException
+ {
+ try
+ {
+ return new LdapName( baseDn );
+ }
+ catch ( InvalidNameException e )
+ {
+ throw new LdapException( "The base DN is not a valid name.", e );
+ }
+ }
+
+ public void addObjectFactory( Class<? extends ObjectFactory> objectFactoryClass )
+ {
+ configuration.getObjectFactories().add( objectFactoryClass );
+ }
+
+ public void addStateFactory( Class<? extends StateFactory> stateFactoryClass )
+ {
+ configuration.getStateFactories().add( stateFactoryClass );
+ }
+
+ // ----------------------------------------------------------------------
+ //
+ // ----------------------------------------------------------------------
+
+ public String toString()
+ {
+ return "{ConfigurableLdapConnectionFactory: configuration: " + configuration + "}";
+ }
+
+ public LdapConnectionConfiguration getConfiguration()
+ {
+ return configuration;
+ }
+
+ public String getHostname()
+ {
+ return hostname;
+ }
+
+ public void setHostname( String hostname )
+ {
+ this.hostname = hostname;
+ }
+
+ public int getPort()
+ {
+ return port;
+ }
+
+ public void setPort( int port )
+ {
+ this.port = port;
+ }
+
+ public boolean isSsl()
+ {
+ return ssl;
+ }
+
+ public void setSsl( boolean ssl )
+ {
+ this.ssl = ssl;
+ }
+
+ public String getBaseDn()
+ {
+ return baseDn;
+ }
+
+ public void setBaseDn( String baseDn )
+ {
+ this.baseDn = baseDn;
+ }
+
+ public String getContextFactory()
+ {
+ return contextFactory;
+ }
+
+ public void setContextFactory( String contextFactory )
+ {
+ this.contextFactory = contextFactory;
+ }
+
+ public String getBindDn()
+ {
+ return bindDn;
+ }
+
+ public void setBindDn( String bindDn )
+ {
+ this.bindDn = bindDn;
+ }
+
+ public String getPassword()
+ {
+ return password;
+ }
+
+ public void setPassword( String password )
+ {
+ this.password = password;
+ }
+
+ public String getAuthenticationMethod()
+ {
+ return authenticationMethod;
+ }
+
+ public void setAuthenticationMethod( String authenticationMethod )
+ {
+ this.authenticationMethod = authenticationMethod;
+ }
+
+ public Properties getExtraProperties()
+ {
+ return extraProperties;
+ }
+
+ public void setExtraProperties( Properties extraProperties )
+ {
+ this.extraProperties = extraProperties;
+ }
+
+ public UserConfiguration getUserConf()
+ {
+ return userConf;
+ }
+
+ public void setUserConf( UserConfiguration userConf )
+ {
+ this.userConf = userConf;
+ }
+}
diff --git a/redback-common/redback-common-ldap/src/main/java/org/codehaus/plexus/redback/common/ldap/connection/LdapConnection.java b/redback-common/redback-common-ldap/src/main/java/org/codehaus/plexus/redback/common/ldap/connection/LdapConnection.java
new file mode 100644
index 000000000..100359ef4
--- /dev/null
+++ b/redback-common/redback-common-ldap/src/main/java/org/codehaus/plexus/redback/common/ldap/connection/LdapConnection.java
@@ -0,0 +1,273 @@
+package org.codehaus.plexus.redback.common.ldap.connection;
+
+/*
+ * The MIT License
+ * Copyright (c) 2005, The Codehaus
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+import com.sun.jndi.ldap.LdapCtxFactory;
+import org.jvnet.animal_sniffer.IgnoreJRERequirement;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.naming.directory.DirContext;
+import javax.naming.ldap.LdapName;
+import javax.naming.ldap.Rdn;
+import java.util.Collections;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Properties;
+
+/**
+ * The configuration for a connection will not change.
+ *
+ * @author <a href="mailto:trygvis@inamo.no">trygvis</a>
+ * @version $Id$
+ */
+public class LdapConnection
+{
+
+ private static LdapCtxFactory ctxFactory;// = new LdapCtxFactory();
+
+
+ static
+ {
+ initCtxFactory();
+ }
+
+
+ private Logger log = LoggerFactory.getLogger( getClass() );
+
+ private LdapConnectionConfiguration config;
+
+ private DirContext context;
+
+ private List<Rdn> baseDnRdns;
+
+ @IgnoreJRERequirement
+ private static void initCtxFactory()
+ {
+ ctxFactory = new LdapCtxFactory();
+ }
+
+ @IgnoreJRERequirement
+ public LdapConnection( LdapConnectionConfiguration config, Rdn subRdn )
+ throws LdapException
+ {
+ this.config = config;
+
+ LdapName baseDn = new LdapName( config.getBaseDn().getRdns() );
+
+ if ( subRdn != null )
+ {
+ baseDn.add( subRdn );
+ }
+
+ baseDnRdns = Collections.unmodifiableList( baseDn.getRdns() );
+
+ if ( context != null )
+ {
+ throw new LdapException( "Already connected." );
+ }
+
+ Hashtable<Object, Object> e = getEnvironment();
+
+ try
+ {
+ context = (DirContext) ctxFactory.getInitialContext( e );
+ }
+ catch ( NamingException ex )
+ {
+ throw new LdapException( "Could not connect to the server.", ex );
+ }
+ }
+
+ /**
+ * This ldap connection will attempt to establish a connection using the configuration,
+ * replacing the principal and the password
+ *
+ * @param config
+ * @param bindDn
+ * @param password
+ * @throws LdapException
+ */
+ @IgnoreJRERequirement
+ public LdapConnection( LdapConnectionConfiguration config, String bindDn, String password )
+ throws LdapException
+ {
+ this.config = config;
+
+ Hashtable<Object, Object> e = getEnvironment();
+
+ e.put( Context.SECURITY_PRINCIPAL, bindDn );
+ e.put( Context.SECURITY_CREDENTIALS, password );
+
+ try
+ {
+ context = (DirContext) ctxFactory.getInitialContext( e );
+ }
+ catch ( NamingException ex )
+ {
+ throw new LdapException( "Could not connect to the server.", ex );
+ }
+ }
+
+ // ----------------------------------------------------------------------
+ // Connection Managment
+ // ----------------------------------------------------------------------
+
+ public Hashtable<Object, Object> getEnvironment()
+ throws LdapException
+ {
+ Properties env = new Properties();
+
+ env.putAll( config.getExtraProperties() );
+
+ config.check();
+
+ env.put( Context.INITIAL_CONTEXT_FACTORY, config.getContextFactory() );
+
+ // REDBACK-289/MRM-1488
+ // enable connection pooling when using Sun's LDAP context factory
+ if( config.getContextFactory().equals( "com.sun.jndi.ldap.LdapCtxFactory" ) )
+ {
+ env.put( "com.sun.jndi.ldap.connect.pool", "true");
+
+ env.put( "com.sun.jndi.ldap.connect.pool.timeout", "3600" );
+ }
+
+ if ( config.getHostname() != null )
+ {
+ String protocol = config.isSsl() ? "ldaps" : "ldap";
+ if ( config.getPort() != 0 )
+ {
+ env.put( Context.PROVIDER_URL, protocol + "://" + config.getHostname() + ":" + config.getPort() + "/" );
+ }
+ else
+ {
+ env.put( Context.PROVIDER_URL, protocol + "://" + config.getHostname() + "/" );
+ }
+ }
+
+ if ( config.getAuthenticationMethod() != null )
+ {
+ env.put( Context.SECURITY_AUTHENTICATION, config.getAuthenticationMethod() );
+ }
+
+ if ( config.getBindDn() != null )
+ {
+ env.put( Context.SECURITY_PRINCIPAL, config.getBindDn().toString() );
+ }
+
+ if ( config.getPassword() != null )
+ {
+ env.put( Context.SECURITY_CREDENTIALS, config.getPassword() );
+ }
+
+ // ----------------------------------------------------------------------
+ // Object Factories
+ // ----------------------------------------------------------------------
+
+ String objectFactories = null;
+
+ for ( Class<?> objectFactoryClass : config.getObjectFactories() )
+ {
+ if ( objectFactories == null )
+ {
+ objectFactories = objectFactoryClass.getName();
+ }
+ else
+ {
+ objectFactories += ":" + objectFactoryClass.getName();
+ }
+ }
+
+ if ( objectFactories != null )
+ {
+ env.setProperty( Context.OBJECT_FACTORIES, objectFactories );
+ }
+
+ // ----------------------------------------------------------------------
+ // State Factories
+ // ----------------------------------------------------------------------
+
+ String stateFactories = null;
+
+ for ( Class<?> stateFactoryClass : config.getStateFactories() )
+ {
+ if ( stateFactories == null )
+ {
+ stateFactories = stateFactoryClass.getName();
+ }
+ else
+ {
+ stateFactories += ":" + stateFactoryClass.getName();
+ }
+ }
+
+ if ( stateFactories != null )
+ {
+ env.setProperty( Context.STATE_FACTORIES, stateFactories );
+ }
+
+ return env;
+ }
+
+ public void close()
+ {
+ try
+ {
+ if ( context != null )
+ {
+ context.close();
+ }
+ }
+ catch ( NamingException ex )
+ {
+ log.info( "skip error closing ldap connection {}", ex.getMessage() );
+ }
+ finally
+ {
+ context = null;
+ }
+ }
+
+ // ----------------------------------------------------------------------
+ // Utils
+ // ----------------------------------------------------------------------
+
+ public LdapConnectionConfiguration getConfiguration()
+ {
+ return config;
+ }
+
+ public List<Rdn> getBaseDnRdns()
+ {
+ return baseDnRdns;
+ }
+
+ public DirContext getDirContext()
+ {
+ return context;
+ }
+}
diff --git a/redback-common/redback-common-ldap/src/main/java/org/codehaus/plexus/redback/common/ldap/connection/LdapConnectionConfiguration.java b/redback-common/redback-common-ldap/src/main/java/org/codehaus/plexus/redback/common/ldap/connection/LdapConnectionConfiguration.java
new file mode 100644
index 000000000..4fd9c834d
--- /dev/null
+++ b/redback-common/redback-common-ldap/src/main/java/org/codehaus/plexus/redback/common/ldap/connection/LdapConnectionConfiguration.java
@@ -0,0 +1,348 @@
+package org.codehaus.plexus.redback.common.ldap.connection;
+/*
+ * The MIT License
+ * Copyright (c) 2005, The Codehaus
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+import org.apache.commons.lang.StringUtils;
+
+import javax.naming.InvalidNameException;
+import javax.naming.ldap.LdapName;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+import java.util.TreeMap;
+
+/**
+ * This class contains the configuration for a ldap connection.
+ * <p/>
+ * Properties of a ldap connection:
+ * <ul>
+ * <li>Hostname - String, required.
+ * <li>Port - int, not required. If 0 then the default value is used by the ldap driver.
+ * <li>Ssl - boolean, not required. If true then the ldaps will be used.
+ * <li>Base DN - String, required.
+ * <li>Context factory - String, required.
+ * <li>Bind DN - String, not required.
+ * <li>Password - String, not required.
+ * </ul>
+ * Note that both the bind dn and password must be set if any are set.
+ *
+ * @author <a href="mailto:trygvis@inamo.no">trygvis</a>
+ * @version $Id$
+ */
+public class LdapConnectionConfiguration
+{
+ private String hostname;
+
+ private int port;
+
+ private boolean ssl;
+
+ private LdapName baseDn;
+
+ private String contextFactory;
+
+ private LdapName bindDn;
+
+ private String password;
+
+ private String authenticationMethod;
+
+ private List<Class<?>> objectFactories;
+
+ private List<Class<?>> stateFactories;
+
+ private Properties extraProperties;
+
+ public LdapConnectionConfiguration()
+ {
+ }
+
+ public LdapConnectionConfiguration( String hostname, int port, LdapName baseDn, String contextFactory,
+ LdapName bindDn, String password, String authenticationMethod,
+ Properties extraProperties )
+ throws LdapException
+ {
+ this.hostname = hostname;
+
+ this.port = port;
+
+ if ( baseDn != null )
+ {
+ this.baseDn = new LdapName( baseDn.getRdns() );
+ }
+
+ this.contextFactory = contextFactory;
+
+ if ( bindDn != null )
+ {
+ this.bindDn = new LdapName( bindDn.getRdns() );
+ }
+
+ this.password = password;
+
+ this.authenticationMethod = authenticationMethod;
+
+ this.extraProperties = extraProperties;
+
+ check();
+ }
+
+ public LdapConnectionConfiguration( String hostname, int port, String baseDn, String contextFactory, String bindDn,
+ String password, String authenticationMethod, Properties extraProperties )
+ throws InvalidNameException, LdapException
+ {
+ this.hostname = hostname;
+ this.port = port;
+
+ if ( baseDn != null )
+ {
+ this.baseDn = new LdapName( baseDn );
+ }
+
+ if ( bindDn != null )
+ {
+ this.bindDn = new LdapName( bindDn );
+ }
+
+ this.contextFactory = contextFactory;
+
+ this.password = password;
+
+ this.authenticationMethod = authenticationMethod;
+
+ this.extraProperties = extraProperties;
+
+ check();
+ }
+
+ public LdapConnectionConfiguration( String hostname, int port, LdapName baseDn, String contextFactory )
+ throws LdapException
+ {
+ this.hostname = hostname;
+
+ this.port = port;
+
+ this.baseDn = baseDn;
+
+ this.contextFactory = contextFactory;
+
+ check();
+ }
+
+ // ----------------------------------------------------------------------
+ // Accessors
+ // ----------------------------------------------------------------------
+
+ public String getHostname()
+ {
+ return hostname;
+ }
+
+ public void setHostname( String hostname )
+ {
+ this.hostname = hostname;
+ }
+
+ public int getPort()
+ {
+ return port;
+ }
+
+ public void setPort( int port )
+ {
+ this.port = port;
+ }
+
+ public boolean isSsl()
+ {
+ return ssl;
+ }
+
+ public void setSsl( boolean ssl )
+ {
+ this.ssl = ssl;
+ }
+
+ public LdapName getBaseDn()
+ {
+ return baseDn;
+ }
+
+ public void setBaseDn( LdapName baseDn )
+ {
+ this.baseDn = baseDn;
+ }
+
+ public void setBaseDn( String baseDn )
+ throws InvalidNameException
+ {
+ if ( baseDn != null )
+ {
+ this.baseDn = new LdapName( baseDn );
+ }
+ }
+
+ public String getContextFactory()
+ {
+ return contextFactory;
+ }
+
+ public void setContextFactory( String contextFactory )
+ {
+ this.contextFactory = contextFactory;
+ }
+
+ public LdapName getBindDn()
+ {
+ return bindDn;
+ }
+
+ public void setBindDn( LdapName bindDn )
+ {
+ this.bindDn = bindDn;
+ }
+
+ public void setBindDn( String bindDn )
+ throws InvalidNameException
+ {
+ if ( bindDn != null )
+ {
+ this.bindDn = new LdapName( bindDn );
+ }
+ }
+
+ public String getPassword()
+ {
+ return password;
+ }
+
+ public void setPassword( String password )
+ {
+ this.password = password;
+ }
+
+ public String getAuthenticationMethod()
+ {
+ return authenticationMethod;
+ }
+
+ public void setAuthenticationMethod( String authenticationMethod )
+ {
+ this.authenticationMethod = authenticationMethod;
+ }
+
+ public List<Class<?>> getObjectFactories()
+ {
+ if ( objectFactories == null )
+ {
+ objectFactories = new ArrayList<Class<?>>( 0 );
+ }
+
+ return objectFactories;
+ }
+
+ public void setObjectFactories( List<Class<?>> objectFactories )
+ {
+ this.objectFactories = objectFactories;
+ }
+
+ public List<Class<?>> getStateFactories()
+ {
+ if ( stateFactories == null )
+ {
+ stateFactories = new ArrayList<Class<?>>( 0 );
+ }
+
+ return stateFactories;
+ }
+
+ public void setStateFactories( List<Class<?>> stateFactories )
+ {
+ this.stateFactories = stateFactories;
+ }
+
+ public Properties getExtraProperties()
+ {
+ if ( extraProperties == null )
+ {
+ extraProperties = new Properties();
+ }
+
+ return extraProperties;
+ }
+
+ public void setExtraProperties( Properties extraProperties )
+ {
+ this.extraProperties = extraProperties;
+ }
+
+ // ----------------------------------------------------------------------
+ //
+ // ----------------------------------------------------------------------
+
+ public void check()
+ throws LdapException
+ {
+ if ( port < 0 || port > 65535 )
+ {
+ throw new LdapException( "The port must be between 1 and 65535." );
+ }
+ if ( baseDn == null )
+ {
+ throw new LdapException( "The base DN must be set." );
+ }
+ if ( StringUtils.isEmpty( contextFactory ) )
+ {
+ throw new LdapException( "The context factory must be set." );
+ }
+ if ( password != null && bindDn == null )
+ {
+ throw new LdapException( "The password cant be set unless the bind dn is." );
+ }
+
+ if ( extraProperties == null )
+ {
+ extraProperties = new Properties();
+ }
+ }
+
+ // ----------------------------------------------------------------------
+ //
+ // ----------------------------------------------------------------------
+
+ public String toString()
+ {
+ return "{LdapConnectionConfiguration: " +
+ "hostname: " + getHostname() + ", " +
+ "port: " + getPort() + ", " +
+ "ssl: " + isSsl() + ", " +
+ "baseDn: " + getBaseDn() + ", " +
+ "contextFactory: " + getContextFactory() + ", " +
+ "bindDn: " + getBindDn() + ", " +
+ "password: " + getPassword() + ", " +
+ "authenticationMethod: " + getAuthenticationMethod() + ", " +
+ "objectFactories: " + getObjectFactories() + ", " +
+ "stateFactories: " + getStateFactories() + ", " +
+ "extraProperties: " + new TreeMap<Object, Object>( extraProperties ).toString() + "}";
+ }
+}
diff --git a/redback-common/redback-common-ldap/src/main/java/org/codehaus/plexus/redback/common/ldap/connection/LdapConnectionFactory.java b/redback-common/redback-common-ldap/src/main/java/org/codehaus/plexus/redback/common/ldap/connection/LdapConnectionFactory.java
new file mode 100644
index 000000000..22d63e15b
--- /dev/null
+++ b/redback-common/redback-common-ldap/src/main/java/org/codehaus/plexus/redback/common/ldap/connection/LdapConnectionFactory.java
@@ -0,0 +1,56 @@
+package org.codehaus.plexus.redback.common.ldap.connection;
+
+/*
+ * The MIT License
+ * Copyright (c) 2005, The Codehaus
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+import javax.naming.ldap.LdapName;
+import javax.naming.ldap.Rdn;
+import javax.naming.spi.ObjectFactory;
+import javax.naming.spi.StateFactory;
+
+
+/**
+ * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
+ * @version $Id$
+ */
+public interface LdapConnectionFactory
+{
+ String ROLE = LdapConnectionFactory.class.getName();
+
+ LdapConnection getConnection()
+ throws LdapException;
+
+ LdapConnection getConnection( Rdn subRdn )
+ throws LdapException;
+
+ LdapConnection getConnection( String bindDn, String password )
+ throws LdapException;
+
+ LdapName getBaseDnLdapName()
+ throws LdapException;
+
+ void addObjectFactory( Class<? extends ObjectFactory> objectFactoryClass );
+
+ void addStateFactory( Class<? extends StateFactory> objectFactoryClass );
+
+}
diff --git a/redback-common/redback-common-ldap/src/main/java/org/codehaus/plexus/redback/common/ldap/connection/LdapException.java b/redback-common/redback-common-ldap/src/main/java/org/codehaus/plexus/redback/common/ldap/connection/LdapException.java
new file mode 100644
index 000000000..e754e529a
--- /dev/null
+++ b/redback-common/redback-common-ldap/src/main/java/org/codehaus/plexus/redback/common/ldap/connection/LdapException.java
@@ -0,0 +1,45 @@
+package org.codehaus.plexus.redback.common.ldap.connection;
+
+/*
+ * The MIT License
+ * Copyright (c) 2005, The Codehaus
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+import javax.naming.NamingException;
+
+/**
+ * @author <a href="mailto:trygvis@inamo.no">trygvis</a>
+ * @version $Id$
+ */
+public class LdapException
+ extends NamingException
+{
+ public LdapException( String message )
+ {
+ super( message );
+ }
+
+ public LdapException( String message, Throwable t )
+ {
+ super( message );
+ setRootCause( t );
+ }
+}
diff --git a/redback-common/redback-common-ldap/src/main/resources/META-INF/spring-context.xml b/redback-common/redback-common-ldap/src/main/resources/META-INF/spring-context.xml
new file mode 100644
index 000000000..93f3a6276
--- /dev/null
+++ b/redback-common/redback-common-ldap/src/main/resources/META-INF/spring-context.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0"?>
+
+<!--
+ ~ 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.
+ -->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+ http://www.springframework.org/schema/context
+ http://www.springframework.org/schema/context/spring-context-3.0.xsd"
+ default-lazy-init="true">
+
+ <context:annotation-config />
+ <context:component-scan base-package="org.codehaus.plexus.redback.common.ldap"/>
+
+</beans> \ No newline at end of file
diff --git a/redback-common/redback-common-ldap/src/test/java/org/codehaus/plexus/redback/common/ldap/LdapUserMapperTest.java b/redback-common/redback-common-ldap/src/test/java/org/codehaus/plexus/redback/common/ldap/LdapUserMapperTest.java
new file mode 100644
index 000000000..7b0542ed5
--- /dev/null
+++ b/redback-common/redback-common-ldap/src/test/java/org/codehaus/plexus/redback/common/ldap/LdapUserMapperTest.java
@@ -0,0 +1,41 @@
+package org.codehaus.plexus.redback.common.ldap;
+
+/*
+ * Copyright 2009 The Codehaus.
+ *
+ * Licensed 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.
+ */
+
+import junit.framework.TestCase;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+@RunWith( SpringJUnit4ClassRunner.class )
+@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" } )
+public class LdapUserMapperTest
+ extends TestCase
+{
+ @Inject @Named(value = "userMapper#ldap")
+ LdapUserMapper mapper;
+
+ @Test
+ public void testConfiguration()
+ {
+ assertEquals( "o=People,dc=codehaus,dc=org", mapper.getUserBaseDn() );
+ }
+}
diff --git a/redback-common/redback-common-ldap/src/test/java/org/codehaus/plexus/redback/common/ldap/connection/ConfigurableLdapConnectionFactoryTest.java b/redback-common/redback-common-ldap/src/test/java/org/codehaus/plexus/redback/common/ldap/connection/ConfigurableLdapConnectionFactoryTest.java
new file mode 100644
index 000000000..4648b9b18
--- /dev/null
+++ b/redback-common/redback-common-ldap/src/test/java/org/codehaus/plexus/redback/common/ldap/connection/ConfigurableLdapConnectionFactoryTest.java
@@ -0,0 +1,44 @@
+package org.codehaus.plexus.redback.common.ldap.connection;
+
+/*
+ * Copyright 2009 The Codehaus.
+ *
+ * Licensed 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.
+ */
+
+import junit.framework.TestCase;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+@RunWith( SpringJUnit4ClassRunner.class )
+@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" } )
+public class ConfigurableLdapConnectionFactoryTest
+ extends TestCase
+{
+
+ @Inject
+ @Named( value = "ldapConnectionFactory#configurable" )
+ ConfigurableLdapConnectionFactory factory;
+
+ @Test
+ public void testConfiguration()
+ {
+ assertEquals( "dc=codehaus,dc=org", factory.getConfiguration().getBaseDn().toString() );
+ assertEquals( "uid=user,dc=codehaus,dc=org", factory.getConfiguration().getBindDn().toString() );
+ }
+}
diff --git a/redback-common/redback-common-ldap/src/test/resources/spring-context.xml b/redback-common/redback-common-ldap/src/test/resources/spring-context.xml
new file mode 100644
index 000000000..817b798bb
--- /dev/null
+++ b/redback-common/redback-common-ldap/src/test/resources/spring-context.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0"?>
+
+<!--
+ ~ 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.
+ -->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+ http://www.springframework.org/schema/context
+ http://www.springframework.org/schema/context/spring-context-3.0.xsd">
+
+ <bean name="userConfiguration" class="org.codehaus.plexus.redback.configuration.UserConfiguration">
+ <property name="configs">
+ <list>
+ <value>src/test/resources/test.properties</value>
+ </list>
+ </property>
+ </bean>
+
+</beans> \ No newline at end of file
diff --git a/redback-common/redback-common-ldap/src/test/resources/test.properties b/redback-common/redback-common-ldap/src/test/resources/test.properties
new file mode 100644
index 000000000..ed65914e8
--- /dev/null
+++ b/redback-common/redback-common-ldap/src/test/resources/test.properties
@@ -0,0 +1,10 @@
+# LDAP settings
+
+ldap.bind.authenticator.enabled=true
+
+#ldap.config.hostname=
+#ldap.config.port=389
+ldap.config.base.dn=dc=codehaus,dc=org
+ldap.config.bind.dn=uid=user,dc=codehaus,dc=org
+
+ldap.config.mapper.attribute.user.base.dn=o=People,dc=codehaus,dc=org
diff --git a/redback-common/redback-common-test-resources/pom.xml b/redback-common/redback-common-test-resources/pom.xml
new file mode 100644
index 000000000..c81257c8f
--- /dev/null
+++ b/redback-common/redback-common-test-resources/pom.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2011 The Codehaus.
+ ~
+ ~ Licensed 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.
+ -->
+<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/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.codehaus.redback</groupId>
+ <artifactId>redback-common</artifactId>
+ <version>1.5-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>redback-common-test-resources</artifactId>
+ <version>1.5-SNAPSHOT</version>
+ <name>Redback :: Common TestResources</name>
+
+</project>
diff --git a/redback-common/redback-common-test-resources/src/main/resources/META-INF/redback/redback-core.xml b/redback-common/redback-common-test-resources/src/main/resources/META-INF/redback/redback-core.xml
new file mode 100644
index 000000000..975b9329e
--- /dev/null
+++ b/redback-common/redback-common-test-resources/src/main/resources/META-INF/redback/redback-core.xml
@@ -0,0 +1,228 @@
+<redback-role-model>
+ <modelVersion>1.0.0</modelVersion>
+ <applications>
+ <application>
+ <id>System</id>
+ <description>Roles that apply system-wide, across all of the applications</description>
+ <version>1.0.0</version>
+ <resources>
+ <resource>
+ <id>global</id>
+ <name>*</name>
+ <permanent>true</permanent>
+ <description>global resource implies full access for authorization</description>
+ </resource>
+ <resource>
+ <id>username</id>
+ <name>${username}</name>
+ <permanent>true</permanent>
+ <description>replaced with the username of the principal at authorization check time</description>
+ </resource>
+ </resources>
+ <operations>
+ <operation>
+ <id>configuration-edit</id>
+ <name>configuration-edit</name>
+ <description>edit configuration</description>
+ <permanent>true</permanent>
+ </operation>
+ <operation>
+ <id>user-management-user-create</id>
+ <name>user-management-user-create</name>
+ <description>create user</description>
+ <permanent>true</permanent>
+ </operation>
+ <operation>
+ <id>user-management-user-edit</id>
+ <name>user-management-user-edit</name>
+ <description>edit user</description>
+ <permanent>true</permanent>
+ </operation>
+ <operation>
+ <id>user-management-user-role</id>
+ <name>user-management-user-role</name>
+ <description>user roles</description>
+ <permanent>true</permanent>
+ </operation>
+ <operation>
+ <id>user-management-user-delete</id>
+ <name>user-management-user-delete</name>
+ <description>delete user</description>
+ <permanent>true</permanent>
+ </operation>
+ <operation>
+ <id>user-management-user-list</id>
+ <name>user-management-user-list</name>
+ <description>list users</description>
+ <permanent>true</permanent>
+ </operation>
+ <operation>
+ <id>user-management-role-grant</id>
+ <name>user-management-role-grant</name>
+ <description>grant role</description>
+ <permanent>true</permanent>
+ </operation>
+ <operation>
+ <id>user-management-role-drop</id>
+ <name>user-management-role-drop</name>
+ <description>drop role</description>
+ <permanent>true</permanent>
+ </operation>
+ <operation>
+ <id>user-management-rbac-admin</id>
+ <name>user-management-rbac-admin</name>
+ <description>administer rbac</description>
+ <permanent>true</permanent>
+ </operation>
+ <operation>
+ <id>guest-access</id>
+ <name>guest-access</name>
+ <description>access guest</description>
+ <permanent>true</permanent>
+ </operation>
+ <operation>
+ <id>user-management-manage-data</id>
+ <name>user-management-manage-data</name>
+ <description>manage data</description>
+ <permanent>true</permanent>
+ </operation>
+ </operations>
+ <roles>
+ <role>
+ <id>system-administrator</id>
+ <name>System Administrator</name>
+ <permanent>true</permanent>
+ <assignable>true</assignable>
+ <permissions>
+ <permission>
+ <id>edit-redback-configuration</id>
+ <name>Edit Redback Configuration</name>
+ <operation>configuration-edit</operation>
+ <resource>global</resource>
+ <permanent>true</permanent>
+ </permission>
+ <permission>
+ <id>manage-rbac-setup</id>
+ <name>User RBAC Management</name>
+ <operation>user-management-rbac-admin</operation>
+ <resource>global</resource>
+ <permanent>true</permanent>
+ </permission>
+ <permission>
+ <id>manage-rbac-data</id>
+ <name>RBAC Manage Data</name>
+ <operation>user-management-manage-data</operation>
+ <resource>global</resource>
+ <permanent>true</permanent>
+ </permission>
+ </permissions>
+ <childRoles>
+ <childRole>user-administrator</childRole>
+ </childRoles>
+ </role>
+ <role>
+ <id>user-administrator</id>
+ <name>User Administrator</name>
+ <permanent>true</permanent>
+ <assignable>true</assignable>
+ <permissions>
+ <permission>
+ <id>drop-roles-for-anyone</id>
+ <name>Drop Roles for Anyone</name>
+ <operation>user-management-role-drop</operation>
+ <resource>global</resource>
+ <permanent>true</permanent>
+ </permission>
+ <permission>
+ <id>grant-roles-for-anyone</id>
+ <name>Grant Roles for Anyone</name>
+ <operation>user-management-role-grant</operation>
+ <resource>global</resource>
+ <permanent>true</permanent>
+ </permission>
+ <permission>
+ <id>user-create</id>
+ <name>Create Users</name>
+ <operation>user-management-user-create</operation>
+ <resource>global</resource>
+ <permanent>true</permanent>
+ </permission>
+ <permission>
+ <id>user-delete</id>
+ <name>Delete Users</name>
+ <operation>user-management-user-delete</operation>
+ <resource>global</resource>
+ <permanent>true</permanent>
+ </permission>
+ <permission>
+ <id>user-edit</id>
+ <name>Edit Users</name>
+ <operation>user-management-user-edit</operation>
+ <resource>global</resource>
+ <permanent>true</permanent>
+ </permission>
+ <permission>
+ <id>access-users-roles</id>
+ <name>Access Users Roles</name>
+ <operation>user-management-user-role</operation>
+ <resource>global</resource>
+ <permanent>true</permanent>
+ </permission>
+ <permission>
+ <id>access-user-list</id>
+ <name>Access User List</name>
+ <operation>user-management-user-list</operation>
+ <resource>global</resource>
+ <permanent>true</permanent>
+ </permission>
+ </permissions>
+ </role>
+ <role>
+ <id>edit-users-list</id>
+ <name>edit users list</name>
+ <permanent>true</permanent>
+ <assignable>true</assignable>
+ <permissions>
+ <permission>
+ <id>access-user-list</id>
+ <name>Access User List</name>
+ <operation>user-management-user-list</operation>
+ <resource>global</resource>
+ <permanent>true</permanent>
+ </permission>
+ </permissions>
+ </role>
+ <role>
+ <id>registered-user</id>
+ <name>Registered User</name>
+ <permanent>true</permanent>
+ <assignable>true</assignable>
+ <permissions>
+ <permission>
+ <id>edit-user-by-username</id>
+ <name>Edit User Data by Username</name>
+ <operation>user-management-user-edit</operation>
+ <resource>username</resource>
+ <permanent>true</permanent>
+ </permission>
+ </permissions>
+ </role>
+ <role>
+ <id>guest</id>
+ <name>Guest</name>
+ <permanent>true</permanent>
+ <assignable>true</assignable>
+ <permissions>
+ <permission>
+ <id>guest-permission</id>
+ <name>Guest Permission</name>
+ <operation>guest-access</operation>
+ <resource>global</resource>
+ <permanent>true</permanent>
+ </permission>
+ </permissions>
+ </role>
+ </roles>
+ </application>
+ </applications>
+</redback-role-model> \ No newline at end of file
diff --git a/redback-common/redback-common-test-resources/src/main/resources/org/codehaus/plexus/redback/config-defaults.properties b/redback-common/redback-common-test-resources/src/main/resources/org/codehaus/plexus/redback/config-defaults.properties
new file mode 100644
index 000000000..f4c3dd0ca
--- /dev/null
+++ b/redback-common/redback-common-test-resources/src/main/resources/org/codehaus/plexus/redback/config-defaults.properties
@@ -0,0 +1,130 @@
+#
+# Copyright 2006 The Codehaus.
+#
+# Licensed 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.
+#
+
+# --------------------------------------------------------------------
+# Application Configuration
+
+application.timestamp=EEE d MMM yyyy HH:mm:ss Z
+
+# --------------------------------------------------------------------
+# JDBC Setup
+
+#jdbc.driver.name=org.hsqldb.jdbcDriver
+jdbc.driver.name=org.apache.derby.jdbc.EmbeddedDriver
+#jdbc.url=jdbc:hsqldb:mem:redback-users-tests
+#jdbc.url=jdbc:derby:memory:users-test;create=true
+jdbc.url=jdbc:derby:users-test;create=true
+jdbc.username=sa
+jdbc.password=
+
+# --------------------------------------------------------------------
+# Email Settings
+
+email.jndiSessionName=java:comp/env/mail/Session
+email.smtp.host=localhost
+email.smtp.port=25
+email.smtp.ssl.enabled=false
+email.smtp.tls.enabled=false
+email.smtp.username=
+email.smtp.password=
+
+#TODO: move description elsewhere, remove bad default
+# All emails sent by the system will be from the following address
+#email.from.address=${user.name}@localhost
+# All emails sent by the system will be from the following user name (used in conjunction with address)
+#email.from.name=Unconfigured Username
+
+# If all email addresses (from new user registration) require an account validation email.
+email.validation.required=true
+# Timeout (in minutes) for the key generated for an email validation to remain valid.
+# 2880 minutes = 48 hours
+email.validation.timeout=2880
+# The subject line for the email message.
+email.validation.subject=Welcome
+
+#TODO: move description elsewhere, remove bad default
+# Get the Feedback to use for any outgoing emails.
+# NOTE: if feedback.path starts with a "/" it is appended to the end of the value provided in application.url
+# This value can be in the format/syntax of "/feedback.action" or even "mailto:feedback@application.com"
+#email.feedback.path=/feedback.action
+
+#Set the application base URL. The default is to derive it from the HTTP request
+#application.url=http://myurl.mycompany.com
+
+# --------------------------------------------------------------------
+# Auto Login Settings
+
+security.rememberme.enabled=true
+# Timeout in minutes ( 525600 minutes = 1 year )
+security.rememberme.timeout=525600
+
+# Single Sign On
+# Timeout in minutes
+security.signon.timeout=30
+
+# --------------------------------------------------------------------
+# Default Username Values
+redback.default.admin=admin
+
+# --------------------------------------------------------------------
+# Security Policies
+
+#security.policy.password.encoder=
+security.policy.password.previous.count=6
+security.policy.password.expiration.enabled=true
+security.policy.password.expiration.days=90
+security.policy.password.expiration.notify.days=10
+security.policy.allowed.login.attempt=10
+
+# turn off the perclick enforcement of various security policies, slightly
+# more heavyweight since it will ensure that the User object on each click
+# is up to date
+security.policy.strict.enforcement.enabled=true
+security.policy.strict.force.password.change.enabled=true
+
+# --------------------------------------------------------------------
+# Password Rules
+security.policy.password.rule.alphanumeric.enabled=false
+security.policy.password.rule.alphacount.enabled=true
+security.policy.password.rule.alphacount.minimum=1
+security.policy.password.rule.characterlength.enabled=true
+security.policy.password.rule.characterlength.minimum=1
+security.policy.password.rule.characterlength.maximum=24
+security.policy.password.rule.musthave.enabled=true
+security.policy.password.rule.numericalcount.enabled=true
+security.policy.password.rule.numericalcount.minimum=1
+security.policy.password.rule.reuse.enabled=true
+security.policy.password.rule.nowhitespace.enabled=true
+
+# --------------------------------------------------------------------
+# ldap settings
+#
+ldap.bind.authenticator.enabled=false
+
+# ldap options for configuration via properties file
+#ldap.config.hostname=
+#ldap.config.port=
+#ldap.config.base.dn=
+#ldap.config.context.factory=
+#ldap.config.bind.dn=
+#ldap.config.password=
+#ldap.config.authentication.method=
+
+# config parameter for the ConfigurableUserManager
+user.manager.impl=cached
+
+
+