From d4a68cb2610f3b39114f3e6f821b87dcb84cab4a Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Sat, 7 Apr 2012 20:36:44 +0000 Subject: package move to o.a.a.r module redback-authentication-memory git-svn-id: https://svn.apache.org/repos/asf/archiva/redback/redback-core/trunk@1310857 13f79535-47bb-0310-9956-ffa450edef68 --- .../authentication/memory/MemoryAuthenticator.java | 88 ++++++++++++++++++++++ .../authentication/memory/MemoryAuthenticator.java | 88 ---------------------- .../src/main/resources/META-INF/spring-context.xml | 2 +- .../memory/MemoryAuthenticatorTest.java | 65 ++++++++++++++++ .../memory/MemoryAuthenticatorTest.java | 65 ---------------- .../src/test/resources/spring-context.xml | 2 +- 6 files changed, 155 insertions(+), 155 deletions(-) create mode 100644 redback-authentication/redback-authentication-providers/redback-authentication-memory/src/main/java/org/apache/archiva/redback/authentication/memory/MemoryAuthenticator.java delete mode 100644 redback-authentication/redback-authentication-providers/redback-authentication-memory/src/main/java/org/codehaus/plexus/redback/authentication/memory/MemoryAuthenticator.java create mode 100644 redback-authentication/redback-authentication-providers/redback-authentication-memory/src/test/java/org/apache/archiva/redback/authentication/memory/MemoryAuthenticatorTest.java delete mode 100644 redback-authentication/redback-authentication-providers/redback-authentication-memory/src/test/java/org/codehaus/plexus/redback/authentication/memory/MemoryAuthenticatorTest.java (limited to 'redback-authentication') diff --git a/redback-authentication/redback-authentication-providers/redback-authentication-memory/src/main/java/org/apache/archiva/redback/authentication/memory/MemoryAuthenticator.java b/redback-authentication/redback-authentication-providers/redback-authentication-memory/src/main/java/org/apache/archiva/redback/authentication/memory/MemoryAuthenticator.java new file mode 100644 index 000000000..82558e4a2 --- /dev/null +++ b/redback-authentication/redback-authentication-providers/redback-authentication-memory/src/main/java/org/apache/archiva/redback/authentication/memory/MemoryAuthenticator.java @@ -0,0 +1,88 @@ +package org.apache.archiva.redback.authentication.memory; + +/* + * 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. + */ + +import org.apache.archiva.redback.authentication.AuthenticationDataSource; +import org.apache.archiva.redback.authentication.AuthenticationException; +import org.apache.archiva.redback.authentication.AuthenticationResult; +import org.apache.archiva.redback.authentication.Authenticator; +import org.apache.archiva.redback.authentication.PasswordBasedAuthenticationDataSource; +import org.springframework.stereotype.Service; + +/** + * MemoryAuthenticator: + * + * @author: Jesse McConnell + * @version: $Id$ + */ +@Service("authenticator#memory") +public class MemoryAuthenticator + implements Authenticator +{ + private String login; + + private String password; + + public String getId() + { + return "MemoryAuthenticator"; + } + + public AuthenticationResult authenticate( AuthenticationDataSource s ) + throws AuthenticationException + { + PasswordBasedAuthenticationDataSource source = (PasswordBasedAuthenticationDataSource) s; + + login = source.getPrincipal(); + password = source.getPassword(); + + if ( source.getPassword().equals( password ) ) + { + return new AuthenticationResult( true, login, null ); + } + + return new AuthenticationResult( false, null, null ); + } + + public boolean supportsDataSource( AuthenticationDataSource source ) + { + return ( source instanceof PasswordBasedAuthenticationDataSource ); + } + + public String getLogin() + { + return login; + } + + public void setLogin( String login ) + { + this.login = login; + } + + public String getPassword() + { + return password; + } + + public void setPassword( String password ) + { + this.password = password; + } +} diff --git a/redback-authentication/redback-authentication-providers/redback-authentication-memory/src/main/java/org/codehaus/plexus/redback/authentication/memory/MemoryAuthenticator.java b/redback-authentication/redback-authentication-providers/redback-authentication-memory/src/main/java/org/codehaus/plexus/redback/authentication/memory/MemoryAuthenticator.java deleted file mode 100644 index 1a6853a0b..000000000 --- a/redback-authentication/redback-authentication-providers/redback-authentication-memory/src/main/java/org/codehaus/plexus/redback/authentication/memory/MemoryAuthenticator.java +++ /dev/null @@ -1,88 +0,0 @@ -package org.codehaus.plexus.redback.authentication.memory; - -/* - * 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. - */ - -import org.apache.archiva.redback.authentication.AuthenticationDataSource; -import org.apache.archiva.redback.authentication.AuthenticationException; -import org.apache.archiva.redback.authentication.AuthenticationResult; -import org.apache.archiva.redback.authentication.Authenticator; -import org.apache.archiva.redback.authentication.PasswordBasedAuthenticationDataSource; -import org.springframework.stereotype.Service; - -/** - * MemoryAuthenticator: - * - * @author: Jesse McConnell - * @version: $Id$ - */ -@Service("authenticator#memory") -public class MemoryAuthenticator - implements Authenticator -{ - private String login; - - private String password; - - public String getId() - { - return "MemoryAuthenticator"; - } - - public AuthenticationResult authenticate( AuthenticationDataSource s ) - throws AuthenticationException - { - PasswordBasedAuthenticationDataSource source = (PasswordBasedAuthenticationDataSource) s; - - login = source.getPrincipal(); - password = source.getPassword(); - - if ( source.getPassword().equals( password ) ) - { - return new AuthenticationResult( true, login, null ); - } - - return new AuthenticationResult( false, null, null ); - } - - public boolean supportsDataSource( AuthenticationDataSource source ) - { - return ( source instanceof PasswordBasedAuthenticationDataSource ); - } - - public String getLogin() - { - return login; - } - - public void setLogin( String login ) - { - this.login = login; - } - - public String getPassword() - { - return password; - } - - public void setPassword( String password ) - { - this.password = password; - } -} diff --git a/redback-authentication/redback-authentication-providers/redback-authentication-memory/src/main/resources/META-INF/spring-context.xml b/redback-authentication/redback-authentication-providers/redback-authentication-memory/src/main/resources/META-INF/spring-context.xml index c002c44f0..edf6bba64 100644 --- a/redback-authentication/redback-authentication-providers/redback-authentication-memory/src/main/resources/META-INF/spring-context.xml +++ b/redback-authentication/redback-authentication-providers/redback-authentication-memory/src/main/resources/META-INF/spring-context.xml @@ -29,6 +29,6 @@ + base-package="org.apache.archiva.redback.authentication.memory"/> \ No newline at end of file diff --git a/redback-authentication/redback-authentication-providers/redback-authentication-memory/src/test/java/org/apache/archiva/redback/authentication/memory/MemoryAuthenticatorTest.java b/redback-authentication/redback-authentication-providers/redback-authentication-memory/src/test/java/org/apache/archiva/redback/authentication/memory/MemoryAuthenticatorTest.java new file mode 100644 index 000000000..141305da9 --- /dev/null +++ b/redback-authentication/redback-authentication-providers/redback-authentication-memory/src/test/java/org/apache/archiva/redback/authentication/memory/MemoryAuthenticatorTest.java @@ -0,0 +1,65 @@ +package org.apache.archiva.redback.authentication.memory; + +/* + * 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. + */ + +import junit.framework.TestCase; +import org.apache.archiva.redback.authentication.AuthenticationResult; +import org.apache.archiva.redback.authentication.Authenticator; +import org.apache.archiva.redback.authentication.PasswordBasedAuthenticationDataSource; +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; + +/** + * MemoryAuthenticatorTest: + * + * @author: Jesse McConnell + * @version: $Id$ + */ +@RunWith( SpringJUnit4ClassRunner.class ) +@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" } ) +public class MemoryAuthenticatorTest + extends TestCase +{ + @Inject + @Named(value = "authenticator#memory") + Authenticator authenticator; + + @Test + public void testSimpleAuthentication() + throws Exception + { + assertNotNull( authenticator ); + + PasswordBasedAuthenticationDataSource ds = new PasswordBasedAuthenticationDataSource(); + ds.setPrincipal( "jason" ); + ds.setPassword( "kungfu" ); + + AuthenticationResult ar = authenticator.authenticate( ds ); + + assertTrue( ar.isAuthenticated() ); + + assertEquals( "jason", ar.getPrincipal() ); + } +} diff --git a/redback-authentication/redback-authentication-providers/redback-authentication-memory/src/test/java/org/codehaus/plexus/redback/authentication/memory/MemoryAuthenticatorTest.java b/redback-authentication/redback-authentication-providers/redback-authentication-memory/src/test/java/org/codehaus/plexus/redback/authentication/memory/MemoryAuthenticatorTest.java deleted file mode 100644 index 311aa644d..000000000 --- a/redback-authentication/redback-authentication-providers/redback-authentication-memory/src/test/java/org/codehaus/plexus/redback/authentication/memory/MemoryAuthenticatorTest.java +++ /dev/null @@ -1,65 +0,0 @@ -package org.codehaus.plexus.redback.authentication.memory; - -/* - * 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. - */ - -import junit.framework.TestCase; -import org.apache.archiva.redback.authentication.AuthenticationResult; -import org.apache.archiva.redback.authentication.Authenticator; -import org.apache.archiva.redback.authentication.PasswordBasedAuthenticationDataSource; -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; - -/** - * MemoryAuthenticatorTest: - * - * @author: Jesse McConnell - * @version: $Id$ - */ -@RunWith( SpringJUnit4ClassRunner.class ) -@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" } ) -public class MemoryAuthenticatorTest - extends TestCase -{ - @Inject - @Named(value = "authenticator#memory") - Authenticator authenticator; - - @Test - public void testSimpleAuthentication() - throws Exception - { - assertNotNull( authenticator ); - - PasswordBasedAuthenticationDataSource ds = new PasswordBasedAuthenticationDataSource(); - ds.setPrincipal( "jason" ); - ds.setPassword( "kungfu" ); - - AuthenticationResult ar = authenticator.authenticate( ds ); - - assertTrue( ar.isAuthenticated() ); - - assertEquals( "jason", ar.getPrincipal() ); - } -} diff --git a/redback-authentication/redback-authentication-providers/redback-authentication-memory/src/test/resources/spring-context.xml b/redback-authentication/redback-authentication-providers/redback-authentication-memory/src/test/resources/spring-context.xml index 937229579..b2d754794 100644 --- a/redback-authentication/redback-authentication-providers/redback-authentication-memory/src/test/resources/spring-context.xml +++ b/redback-authentication/redback-authentication-providers/redback-authentication-memory/src/test/resources/spring-context.xml @@ -26,7 +26,7 @@ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> - + -- cgit v1.2.3