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.springframework.context.annotation.Scope;
24import org.springframework.stereotype.Service;
252627/**28 * TokenBasedAuthenticationDataSource29 *30 * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>31 *32 */33 @Service( "authenticationDataSource#token" )
34 @Scope( "prototype" )
35publicclassTokenBasedAuthenticationDataSource36implementsAuthenticationDataSource37 {
38private String token;
3940private String principal;
4142privateboolean enforcePasswordChange = true;
4344publicTokenBasedAuthenticationDataSource( String principal )
45 {
46this.principal = principal;
47 }
4849publicTokenBasedAuthenticationDataSource()
50 {
51 }
5253public String getUsername()
54 {
55return principal;
56 }
5758public String getToken()
59 {
60return token;
61 }
6263publicvoid setPrincipal( String principal )
64 {
65this.principal = principal;
66 }
6768publicvoid setToken( String token )
69 {
70this.token = token;
71 }
7273public String toString()
74 {
75 StringBuilder sb = new StringBuilder();
76 sb.append( "TokenBasedAuthenticationDataSource[" );
77 sb.append( "principal=" ).append( principal );
78 sb.append( ",token=" ).append( token );
79 sb.append( ']' );
80return sb.toString();
81 }
8283publicvoid setEnforcePasswordChange( boolean enforcePasswordChange )
84 {
85this.enforcePasswordChange = enforcePasswordChange;
86 }
8788publicboolean isEnforcePasswordChange()
89 {
90return enforcePasswordChange;
91 }
92 }