This project has retired. For details please refer to its Attic page.
PasswordBasedAuthenticationDataSource xref
View Javadoc

1   package org.apache.archiva.redback.authentication;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   * http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import org.apache.archiva.redback.authentication.AuthenticationDataSource;
23  import org.apache.commons.lang.StringUtils;
24  import org.springframework.context.annotation.Scope;
25  import org.springframework.stereotype.Service;
26  
27  /**
28   * PasswordBasedAuthenticationDataSource: the username is considered the principal with this data source
29   *
30   * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
31   *
32   * 
33   */
34  @Service("authenticationDataSource#password")
35  @Scope("prototype")
36  public class PasswordBasedAuthenticationDataSource
37      implements AuthenticationDataSource
38  {
39      private String password;
40  
41      private String principal;
42  
43      public PasswordBasedAuthenticationDataSource()
44      {
45  
46      }
47  
48      public PasswordBasedAuthenticationDataSource( String principal, String password )
49      {
50          this.principal = principal;
51          this.password = password;
52      }
53  
54      public String getPassword()
55      {
56          return password;
57      }
58  
59      public String getUsername()
60      {
61          return principal;
62      }
63  
64      public void setPassword( String password )
65      {
66          this.password = password;
67      }
68  
69      public void setPrincipal( String principal )
70      {
71          this.principal = principal;
72      }
73  
74      public String toString()
75      {
76          StringBuilder sb = new StringBuilder();
77          sb.append( "PasswordBasedAuthenticationDataSource[" );
78          sb.append( "principal=" ).append( principal );
79          sb.append( ",password=" );
80          if ( StringUtils.isNotEmpty( password ) )
81          {
82              // Intentionally not showing real password 
83              sb.append( "***" );
84          }
85          sb.append( ']' );
86          return sb.toString();
87      }
88  
89      public boolean isEnforcePasswordChange()
90      {
91          return true;
92      }
93  }