Skip to content
This repository was archived by the owner on Oct 17, 2020. It is now read-only.

Commit ee73ed7

Browse files
author
jesse
committed
[maven-scm] copy for tag plexus-security-1.0-alpha-8
0 parents  commit ee73ed7

446 files changed

Lines changed: 45543 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎LICENSE.txt‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Copyright 2006 The Codehaus.
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.

‎acegi-integration/pom.xml‎

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Copyright 2006 The Codehaus.
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
-->
17+
<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">
18+
<modelVersion>4.0.0</modelVersion>
19+
<parent>
20+
<groupId>org.codehaus.plexus.security</groupId>
21+
<artifactId>plexus-security</artifactId>
22+
<version>1.0-alpha-8</version>
23+
</parent>
24+
<artifactId>plexus-security-acegi-integration</artifactId>
25+
<name>Plexus Security :: Acegi Integration</name>
26+
<repositories>
27+
<repository>
28+
<id>acegi-snapshot</id>
29+
<name>Acegi snapshot repository</name>
30+
<url>http://acegisecurity.sourceforge.net/repository/snapshots</url>
31+
<releases>
32+
<enabled>false</enabled>
33+
</releases>
34+
</repository>
35+
</repositories>
36+
<dependencies>
37+
<dependency>
38+
<groupId>org.acegisecurity</groupId>
39+
<artifactId>acegi-security</artifactId>
40+
<version>1.0.2</version>
41+
</dependency>
42+
<dependency>
43+
<groupId>org.codehaus.plexus.security</groupId>
44+
<artifactId>plexus-security-system</artifactId>
45+
</dependency>
46+
<dependency>
47+
<groupId>org.codehaus.plexus.security</groupId>
48+
<artifactId>plexus-security-authentication-api</artifactId>
49+
</dependency>
50+
</dependencies>
51+
<scm>
52+
<connection>scm:svn:https://svn.codehaus.org/plexus/tags/plexus-security-1.0-alpha-8</connection>
53+
<developerConnection>scm:svn:https://svn.codehaus.org/plexus/tags/plexus-security-1.0-alpha-8</developerConnection>
54+
<url>https://svn.codehaus.org/plexus/tags/plexus-security-1.0-alpha-8</url>
55+
</scm>
56+
<build>
57+
<plugins>
58+
<plugin>
59+
<groupId>org.codehaus.plexus</groupId>
60+
<artifactId>plexus-maven-plugin</artifactId>
61+
<executions>
62+
<execution>
63+
<goals>
64+
<goal>descriptor</goal>
65+
</goals>
66+
</execution>
67+
</executions>
68+
</plugin>
69+
</plugins>
70+
</build>
71+
</project>
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/**
2+
*
3+
*/
4+
package org.codehaus.plexus.security.acegi;
5+
6+
import org.codehaus.plexus.security.authentication.AuthenticationDataSource;
7+
import org.codehaus.plexus.security.authentication.PasswordBasedAuthenticationDataSource;
8+
9+
import java.util.Map;
10+
11+
/**
12+
* {@link AuthenticationDataSource} implementation that wraps the authentication
13+
* credentials in a token map.<p>
14+
* The token map is used by the {@link AcegiAuthenticator} to create a an Acegi
15+
* authentication token to be used by the respective Acegi authentication
16+
* provider for authentication.
17+
*
18+
* @author <a href='mailto:rahul.thakur.xdev@gmail.com'>Rahul Thakur</a>
19+
* @version $Id$
20+
*/
21+
public class AcegiAuthenticationDataSource
22+
extends PasswordBasedAuthenticationDataSource
23+
{
24+
private static final String TOKEN_USERNAME = "username";
25+
26+
private static final String TOKEN_PASSWORD = "password";
27+
28+
/**
29+
* Store for credential tokens.
30+
*/
31+
private Map tokenMap;
32+
33+
public AcegiAuthenticationDataSource( Map tokenMap )
34+
{
35+
this.tokenMap = tokenMap;
36+
}
37+
38+
/**
39+
* @return the tokenMap
40+
*/
41+
public Map getTokenMap()
42+
{
43+
return tokenMap;
44+
}
45+
46+
/**
47+
* @param tokenMap the tokenMap to set
48+
*/
49+
public void setTokenMap( Map tokenMap )
50+
{
51+
this.tokenMap = tokenMap;
52+
}
53+
54+
public String getPassword()
55+
{
56+
return (String) this.tokenMap.get( TOKEN_PASSWORD );
57+
}
58+
59+
public String getUsername()
60+
{
61+
return (String) this.tokenMap.get( TOKEN_USERNAME );
62+
}
63+
64+
}
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
package org.codehaus.plexus.security.acegi;
2+
3+
/*
4+
* Copyright 2005 The Codehaus.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
import org.acegisecurity.Authentication;
20+
import org.acegisecurity.providers.ProviderManager;
21+
import org.codehaus.plexus.security.authentication.AuthenticationDataSource;
22+
import org.codehaus.plexus.security.authentication.AuthenticationResult;
23+
import org.codehaus.plexus.security.authentication.Authenticator;
24+
25+
import java.util.Map;
26+
27+
/**
28+
* {@link Authenticator} implementation that uses the appropriate Acegi
29+
* authentication provider implementation.<p>
30+
*
31+
* @author: Jesse McConnell <jesse@codehaus.org>
32+
* @version: $ID:$
33+
* @plexus.component role="org.codehaus.plexus.security.Authenticator" role-hint="acegi"
34+
*/
35+
public class AcegiAuthenticator
36+
implements Authenticator
37+
{
38+
public String getId()
39+
{
40+
return "Acegi Authenticator";
41+
}
42+
43+
/**
44+
* Token factory creates an Acegi authentication wrapper around credentials
45+
* that is used by the Acegi authentication provider.
46+
* @plexus.requirement
47+
*/
48+
private AuthenticationTokenFactory tokenFactory;
49+
50+
/**
51+
* ProviderManager is the actual Acegi entity here that does the authentication
52+
* after the {@link #tokenFactory} has return an Acegi {@link Authentication}
53+
* request object.
54+
* @plexus.requirement
55+
*/
56+
private ProviderManager manager;
57+
58+
/**
59+
* @see org.codehaus.plexus.security.authentication.Authenticator#authenticate(org.codehaus.plexus.security.authentication.AuthenticationDataSource)
60+
*/
61+
public AuthenticationResult authenticate( AuthenticationDataSource source )
62+
throws org.codehaus.plexus.security.authentication.AuthenticationException
63+
{
64+
AcegiAuthenticationDataSource authsource = (AcegiAuthenticationDataSource) source;
65+
66+
Map tokens = authsource.getTokenMap();
67+
Authentication authenticationToken = tokenFactory.getAuthenticationToken( tokens );
68+
69+
try
70+
{
71+
Authentication response = manager.doAuthentication( authenticationToken );
72+
73+
AuthenticationResult authResult = new AuthenticationResult( response.isAuthenticated(), response
74+
.getPrincipal().toString(), null );
75+
76+
return authResult;
77+
}
78+
catch ( org.acegisecurity.AuthenticationException e )
79+
{
80+
return new AuthenticationResult( false, authsource.getUsername(), e );
81+
}
82+
}
83+
84+
public boolean supportsDataSource( AuthenticationDataSource source )
85+
{
86+
return ( source instanceof AcegiAuthenticationDataSource );
87+
}
88+
}
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
package org.codehaus.plexus.security.acegi;
2+
3+
/*
4+
* Copyright 2006 The Apache Software Foundation.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
import org.acegisecurity.providers.encoding.MessageDigestPasswordEncoder;
20+
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
21+
import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
22+
import org.codehaus.plexus.security.policy.PasswordEncoder;
23+
24+
/**
25+
* Bridge between Maven User {@link PasswordEncoder} and Acegi {@link MessageDigestPasswordEncoder}
26+
*
27+
* @plexus.component role="org.codehaus.plexus.security.policy.PasswordEncoder" role-hint="acegi"
28+
*
29+
* @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
30+
* @version $Id$
31+
*/
32+
public class AcegiPasswordEncoder
33+
implements PasswordEncoder, org.acegisecurity.providers.encoding.PasswordEncoder, Initializable
34+
{
35+
private Object systemSalt;
36+
37+
private org.acegisecurity.providers.encoding.PasswordEncoder encoder;
38+
39+
/**
40+
* @plexus.configuration default-value="SHA-256"
41+
*/
42+
private String algorithm;
43+
44+
public void initialize()
45+
throws InitializationException
46+
{
47+
// setup encoder to use base64 encoded SHA-256
48+
encoder = new MessageDigestPasswordEncoder( algorithm, true );
49+
}
50+
51+
/**
52+
* Delegates to Acegi encoder
53+
*/
54+
public String encodePassword( String rawPass, Object salt )
55+
{
56+
return encoder.encodePassword( rawPass, salt );
57+
}
58+
59+
/**
60+
* Delegates to Acegi encoder
61+
*/
62+
public boolean isPasswordValid( String encPass, String rawPass, Object salt )
63+
{
64+
return encoder.isPasswordValid( encPass, rawPass, salt );
65+
}
66+
67+
public String encodePassword( String rawPass )
68+
{
69+
return encodePassword( rawPass, systemSalt );
70+
}
71+
72+
public boolean isPasswordValid( String encPass, String rawPass )
73+
{
74+
return isPasswordValid( encPass, rawPass, systemSalt );
75+
}
76+
77+
public void setSystemSalt( Object salt )
78+
{
79+
this.systemSalt = salt;
80+
}
81+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package org.codehaus.plexus.security.acegi;
2+
3+
/*
4+
* Copyright 2001-2006 The Codehaus.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
import org.acegisecurity.context.SecurityContextHolder;
20+
import org.codehaus.plexus.security.system.DefaultSecuritySession;
21+
22+
/**
23+
* AcegiSecuritySession
24+
*
25+
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
26+
* @version $Id$
27+
*/
28+
public class AcegiSecuritySession
29+
extends DefaultSecuritySession
30+
{
31+
public String getUserName()
32+
{
33+
org.acegisecurity.userdetails.User user = (org.acegisecurity.userdetails.User) SecurityContextHolder
34+
.getContext().getAuthentication().getPrincipal();
35+
36+
return user.getUsername();
37+
}
38+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package org.codehaus.plexus.security.acegi;
2+
3+
import org.acegisecurity.Authentication;
4+
import org.codehaus.plexus.security.authentication.AuthenticationException;
5+
6+
import java.util.Map;
7+
8+
/**
9+
* AuthenticationTokenFactory:
10+
*
11+
* @author: Jesse McConnell <jesse@codehaus.org>
12+
* @version: $ID:$
13+
*/
14+
public interface AuthenticationTokenFactory
15+
{
16+
public static final String ROLE = AuthenticationTokenFactory.class.getName();
17+
18+
Authentication getAuthenticationToken( Map tokenMap ) throws AuthenticationException;
19+
20+
}

0 commit comments

Comments
 (0)