| Classes in this File | Line Coverage | Branch Coverage | Complexity | |||||||
| X509AuthenticationToken |
|
| 1.0;1 |
| 1 | /* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited |
|
| 2 | * |
|
| 3 | * Licensed under the Apache License, Version 2.0 (the "License"); |
|
| 4 | * you may not use this file except in compliance with the License. |
|
| 5 | * You may obtain a copy of the License at |
|
| 6 | * |
|
| 7 | * http://www.apache.org/licenses/LICENSE-2.0 |
|
| 8 | * |
|
| 9 | * Unless required by applicable law or agreed to in writing, software |
|
| 10 | * distributed under the License is distributed on an "AS IS" BASIS, |
|
| 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
| 12 | * See the License for the specific language governing permissions and |
|
| 13 | * limitations under the License. |
|
| 14 | */ |
|
| 15 | ||
| 16 | package org.acegisecurity.providers.x509; |
|
| 17 | ||
| 18 | import org.acegisecurity.GrantedAuthority; |
|
| 19 | ||
| 20 | import org.acegisecurity.providers.AbstractAuthenticationToken; |
|
| 21 | ||
| 22 | import java.security.cert.X509Certificate; |
|
| 23 | ||
| 24 | ||
| 25 | /** |
|
| 26 | * <code>Authentication</code> implementation for X.509 client-certificate authentication. |
|
| 27 | * |
|
| 28 | * @author Luke Taylor |
|
| 29 | * @version $Id: X509AuthenticationToken.java 1784 2007-02-24 21:00:24Z luke_t $ |
|
| 30 | */ |
|
| 31 | public class X509AuthenticationToken extends AbstractAuthenticationToken { |
|
| 32 | //~ Instance fields ================================================================================================ |
|
| 33 | ||
| 34 | private static final long serialVersionUID = 1L; |
|
| 35 | private Object principal; |
|
| 36 | private X509Certificate credentials; |
|
| 37 | ||
| 38 | //~ Constructors =================================================================================================== |
|
| 39 | ||
| 40 | /** |
|
| 41 | * Used for an authentication request. The {@link org.acegisecurity.Authentication#isAuthenticated()} will return |
|
| 42 | * <code>false</code>. |
|
| 43 | * |
|
| 44 | * @param credentials the certificate |
|
| 45 | */ |
|
| 46 | public X509AuthenticationToken(X509Certificate credentials) { |
|
| 47 | 7 | super(null); |
| 48 | 7 | this.credentials = credentials; |
| 49 | 7 | } |
| 50 | ||
| 51 | /** |
|
| 52 | * Used for an authentication response object. The {@link Authentication#isAuthenticated()} |
|
| 53 | * will return <code>true</code>. |
|
| 54 | * |
|
| 55 | * @param principal the principal, which is generally a |
|
| 56 | * <code>UserDetails</code> |
|
| 57 | * @param credentials the certificate |
|
| 58 | * @param authorities the authorities |
|
| 59 | */ |
|
| 60 | public X509AuthenticationToken(Object principal, X509Certificate credentials, GrantedAuthority[] authorities) { |
|
| 61 | 1 | super(authorities); |
| 62 | 1 | this.principal = principal; |
| 63 | 1 | this.credentials = credentials; |
| 64 | 1 | setAuthenticated(true); |
| 65 | 1 | } |
| 66 | ||
| 67 | //~ Methods ======================================================================================================== |
|
| 68 | ||
| 69 | public Object getCredentials() { |
|
| 70 | 5 | return credentials; |
| 71 | } |
|
| 72 | ||
| 73 | public Object getPrincipal() { |
|
| 74 | 0 | return principal; |
| 75 | } |
|
| 76 | } |