Skip to content

Commit

Permalink
created simple authentication mechanism for FitNesse as a start towar…
Browse files Browse the repository at this point in the history
…ds an authentication plugin for LDAP
  • Loading branch information
timander committed Aug 17, 2009
1 parent 326b0c2 commit 44db4cb
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
target
*.iml
*.ipr
*.iws
12 changes: 12 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
This is a plugin for FitNesse to use LDAP Authentication.

To use:

1. Add the ldap-authentation-${version}.jar to the lib folder of your FitNesse server

2. Add the following line to your plugins.properties
Authenticator=fitnesse.authentication.LDAPAuthenticator

3. Start the FitNesse server with
java -cp "lib/ldap-authentation-${version}.jar:fitnesse.jar" fitnesseMain.FitNesseMain [optional args]
(NOTE Windows users should use ; for the classpath seperator)
24 changes: 24 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<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>
<groupId>org.fitnesse</groupId>
<artifactId>fitnesse-ldap-authenticator</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>FitNesse LDAP Authenticator</name>
<url>http://fitnesse.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.fitnesse</groupId>
<artifactId>fitnesse</artifactId>
<version>20090709</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
17 changes: 17 additions & 0 deletions src/main/java/fitnesse/authentication/LDAPAuthenticator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package fitnesse.authentication;

import java.util.Properties;

public class LDAPAuthenticator extends Authenticator {

public LDAPAuthenticator(Properties properties) {
}

@Override
public boolean isAuthenticated(String username, String password) throws Exception {
if (username == null || password == null) {
return false;
}
return username.equals(password);
}
}
28 changes: 28 additions & 0 deletions src/test/java/fitnesse/authentication/LDAPAuthenticatorTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package fitnesse.authentication;

import junit.framework.TestCase;


public class LDAPAuthenticatorTest extends TestCase {

public void testNullUsername() throws Exception {
LDAPAuthenticator authenticator = new LDAPAuthenticator(null);
assertFalse(authenticator.isAuthenticated(null, "password"));
}

public void testNullPassword() throws Exception {
LDAPAuthenticator authenticator = new LDAPAuthenticator(null);
assertFalse(authenticator.isAuthenticated("username", null));
}

public void testNullUsernameAndPassword() throws Exception {
LDAPAuthenticator authenticator = new LDAPAuthenticator(null);
assertFalse(authenticator.isAuthenticated(null, null));
}

public void testAuthenticated() throws Exception {
LDAPAuthenticator authenticator = new LDAPAuthenticator(null);
assertTrue(authenticator.isAuthenticated("same", "same"));
}

}

0 comments on commit 44db4cb

Please sign in to comment.