1 package org.apache.archiva.redback.authentication;
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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
22 import org.apache.archiva.redback.users.User;
24 import java.io.Serializable;
25 import java.util.HashMap;
26 import java.util.List;
30 * AuthenticationResult: wrapper object for information that comes back from the authentication system
32 * @author Jesse McConnell <jesse@codehaus.org>
34 public class AuthenticationResult
35 implements Serializable
38 private static final long serialVersionUID = 354054054054L;
40 private boolean isAuthenticated;
42 private String principal;
45 * as we can search the User store it here for reuse.
51 // TODO: why aren't these just thrown from the authenticate() method?
52 private Exception exception;
54 private List<AuthenticationFailureCause> authenticationFailureCauses;
56 public AuthenticationResult()
58 this.isAuthenticated = false;
59 this.principal = null;
60 this.exception = null;
63 public AuthenticationResult( boolean authenticated, String principal, Exception exception )
65 isAuthenticated = authenticated;
66 this.principal = principal;
67 this.exception = exception;
70 public AuthenticationResult( boolean authenticated, String principal, Exception exception,
71 List<AuthenticationFailureCause> authenticationFailureCauses )
73 isAuthenticated = authenticated;
74 this.principal = principal;
75 this.exception = exception;
76 this.authenticationFailureCauses = authenticationFailureCauses;
79 public boolean isAuthenticated()
81 return isAuthenticated;
84 public String getPrincipal()
89 public Exception getException()
94 public List<AuthenticationFailureCause> getAuthenticationFailureCauses()
96 return authenticationFailureCauses;
100 * <b>can be <code>null</code></b>
102 public User getUser()
107 public void setUser( User user )
112 public AuthenticationResult user( User user )
114 this.setUser( user );
118 public String toString()
120 StringBuilder sb = new StringBuilder();
121 sb.append( "AuthenticationResult[" );
122 sb.append( "principal=" ).append( principal );
123 sb.append( ",isAuthenticated=" ).append( Boolean.toString( isAuthenticated ) );
124 sb.append( ",exception=" );
125 if ( exception != null )
127 sb.append( exception.getClass().getName() );
128 sb.append( " : " ).append( exception.getMessage() );
132 sb.append( "<null>" );
135 return sb.toString();