1 package org.apache.archiva.redback.policy.encoders;
2
3 /*
4 * Copyright 2001-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.apache.archiva.redback.policy.PasswordEncoder;
20 import org.springframework.stereotype.Service;
21
22 /**
23 * PlainText PasswordEncoder for use in situtations where the password needs to be saved as-is.
24 * See {@link PasswordEncoder#encodePassword(String)} for details.
25 *
26 * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
27 *
28 */
29 @Service("passwordEncoder#plaintext")
30 public class PlainTextPasswordEncoder
31 implements PasswordEncoder
32 {
33
34 public String encodePassword( String rawPass )
35 {
36 return rawPass;
37 }
38
39 public String encodePassword( String rawPass, Object salt )
40 {
41 return rawPass;
42 }
43
44 public boolean isPasswordValid( String encPass, String rawPass )
45 {
46 if ( encPass == null && rawPass != null )
47 {
48 return false;
49 }
50
51 return encPass.equals( rawPass );
52 }
53
54 public boolean isPasswordValid( String encPass, String rawPass, Object salt )
55 {
56 return isPasswordValid( encPass, rawPass );
57 }
58
59 public void setSystemSalt( Object salt )
60 {
61 // Ignore, not used in this plaintext encoder.
62 }
63 }