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 java.io.Serializable;
26 * AuthenticationResult: wrapper object for information that comes back from the authentication system
28 * @author Jesse McConnell <jesse@codehaus.org>
31 public class AuthenticationResult
32 implements Serializable
34 private boolean isAuthenticated;
37 * FIXME olamy this Object is a pain !!!
39 private Object principal;
41 // TODO: why aren't these just thrown from the authenticate() method?
42 private Exception exception;
44 private Map<String,String> exceptionsMap;
46 public AuthenticationResult()
48 this.isAuthenticated = false;
49 this.principal = null;
50 this.exception = null;
53 public AuthenticationResult( boolean authenticated, Object principal, Exception exception )
55 isAuthenticated = authenticated;
56 this.principal = principal;
57 this.exception = exception;
60 public AuthenticationResult( boolean authenticated, Object principal, Exception exception, Map<String,String> exceptionsMap )
62 isAuthenticated = authenticated;
63 this.principal = principal;
64 this.exception = exception;
65 this.exceptionsMap = exceptionsMap;
68 public boolean isAuthenticated()
70 return isAuthenticated;
73 public Object getPrincipal()
78 public Exception getException()
83 public Map<String,String> getExceptionsMap()
88 public String toString()
90 StringBuffer sb = new StringBuffer();
91 sb.append( "AuthenticationResult[" );
92 sb.append( "principal=" ).append( principal );
93 sb.append( ",isAuthenticated=" ).append( Boolean.toString( isAuthenticated ) );
94 sb.append( ",exception=" );
95 if ( exception != null )
97 sb.append( exception.getClass().getName() );
98 sb.append( " : " ).append( exception.getMessage() );
102 sb.append( "<null>" );
105 return sb.toString();