1package org.apache.archiva.redback.authentication;
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.AuthenticationDataSource;
23import org.apache.commons.lang.StringUtils;
24import org.springframework.context.annotation.Scope;
25import org.springframework.stereotype.Service;
2627/**28 * PasswordBasedAuthenticationDataSource: the username is considered the principal with this data source29 *30 * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>31 *32 * 33 */34 @Service("authenticationDataSource#password")
35 @Scope("prototype")
36publicclassPasswordBasedAuthenticationDataSource37implementsAuthenticationDataSource38 {
39private String password;
4041private String principal;
4243publicPasswordBasedAuthenticationDataSource()
44 {
4546 }
4748publicPasswordBasedAuthenticationDataSource( String principal, String password )
49 {
50this.principal = principal;
51this.password = password;
52 }
5354public String getPassword()
55 {
56return password;
57 }
5859public String getUsername()
60 {
61return principal;
62 }
6364publicvoid setPassword( String password )
65 {
66this.password = password;
67 }
6869publicvoid setPrincipal( String principal )
70 {
71this.principal = principal;
72 }
7374public String toString()
75 {
76 StringBuilder sb = new StringBuilder();
77 sb.append( "PasswordBasedAuthenticationDataSource[" );
78 sb.append( "principal=" ).append( principal );
79 sb.append( ",password=" );
80if ( StringUtils.isNotEmpty( password ) )
81 {
82// Intentionally not showing real password 83 sb.append( "***" );
84 }
85 sb.append( ']' );
86return sb.toString();
87 }
8889publicboolean isEnforcePasswordChange()
90 {
91returntrue;
92 }
93 }