1package org.apache.archiva.redback.authentication.memory;
23/*4 * Licensed to the Apache Software Foundation (ASF) under one5 * or more contributor license agreements. See the NOTICE file6 * distributed with this work for additional information7 * regarding copyright ownership. The ASF licenses this file8 * to you under the Apache License, Version 2.0 (the9 * "License"); you may not use this file except in compliance10 * with the License. You may obtain a copy of the License at11 *12 * http://www.apache.org/licenses/LICENSE-2.013 *14 * Unless required by applicable law or agreed to in writing,15 * software distributed under the License is distributed on an16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY17 * KIND, either express or implied. See the License for the18 * specific language governing permissions and limitations19 * under the License.20 */2122import org.apache.archiva.redback.authentication.AbstractAuthenticator;
23import org.apache.archiva.redback.authentication.AuthenticationDataSource;
24import org.apache.archiva.redback.authentication.AuthenticationException;
25import org.apache.archiva.redback.authentication.AuthenticationResult;
26import org.apache.archiva.redback.authentication.Authenticator;
27import org.apache.archiva.redback.authentication.PasswordBasedAuthenticationDataSource;
28import org.springframework.stereotype.Service;
2930/**31 * MemoryAuthenticator:32 *33 * @author: Jesse McConnell <jesse@codehaus.org>34 */35 @Service("authenticator#memory")
36publicclassMemoryAuthenticator37extendsAbstractAuthenticator38implementsAuthenticator39 {
40private String login;
4142private String password;
4344public String getId()
45 {
46return"MemoryAuthenticator";
47 }
4849publicAuthenticationResult authenticate( AuthenticationDataSource s )
50throwsAuthenticationException51 {
52PasswordBasedAuthenticationDataSource source = (PasswordBasedAuthenticationDataSource) s;
5354 login = source.getUsername();
55 password = source.getPassword();
5657if ( source.getPassword().equals( password ) )
58 {
59returnnewAuthenticationResult( true, login, null );
60 }
6162returnnewAuthenticationResult( false, null, null );
63 }
6465publicboolean supportsDataSource( AuthenticationDataSource source )
66 {
67return ( source instanceof PasswordBasedAuthenticationDataSource );
68 }
6970public String getLogin()
71 {
72return login;
73 }
7475publicvoid setLogin( String login )
76 {
77this.login = login;
78 }
7980public String getPassword()
81 {
82return password;
83 }
8485publicvoid setPassword( String password )
86 {
87this.password = password;
88 }
89 }