|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| TestingAuthenticationToken.java | - | 100% | 100% | 100% |
|
||||||||||||||
| 1 | /* Copyright 2004 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; | |
| 17 | ||
| 18 | import org.acegisecurity.GrantedAuthority; | |
| 19 | ||
| 20 | ||
| 21 | /** | |
| 22 | * An {@link org.acegisecurity.Authentication} implementation that is | |
| 23 | * designed for use whilst unit testing. | |
| 24 | * | |
| 25 | * <p> | |
| 26 | * The corresponding authentication provider is {@link | |
| 27 | * TestingAuthenticationProvider}. | |
| 28 | * </p> | |
| 29 | * | |
| 30 | * @author Ben Alex | |
| 31 | * @version $Id: TestingAuthenticationToken.java,v 1.4 2005/11/17 00:55:49 benalex Exp $ | |
| 32 | */ | |
| 33 | public class TestingAuthenticationToken extends AbstractAuthenticationToken { | |
| 34 | //~ Instance fields ======================================================== | |
| 35 | ||
| 36 | private Object credentials; | |
| 37 | private Object principal; | |
| 38 | private GrantedAuthority[] authorities; | |
| 39 | private boolean authenticated = false; | |
| 40 | ||
| 41 | //~ Constructors =========================================================== | |
| 42 | ||
| 43 | 77 | public TestingAuthenticationToken(Object principal, Object credentials, |
| 44 | GrantedAuthority[] authorities) { | |
| 45 | 77 | this.principal = principal; |
| 46 | 77 | this.credentials = credentials; |
| 47 | 77 | this.authorities = authorities; |
| 48 | } | |
| 49 | ||
| 50 | 1 | protected TestingAuthenticationToken() { |
| 51 | 1 | throw new IllegalArgumentException("Cannot use default constructor"); |
| 52 | } | |
| 53 | ||
| 54 | //~ Methods ================================================================ | |
| 55 | ||
| 56 | 1 | public void setAuthenticated(boolean isAuthenticated) { |
| 57 | 1 | this.authenticated = isAuthenticated; |
| 58 | } | |
| 59 | ||
| 60 | 15 | public boolean isAuthenticated() { |
| 61 | 15 | return this.authenticated; |
| 62 | } | |
| 63 | ||
| 64 | 191 | public GrantedAuthority[] getAuthorities() { |
| 65 | 191 | return this.authorities; |
| 66 | } | |
| 67 | ||
| 68 | 17 | public Object getCredentials() { |
| 69 | 17 | return this.credentials; |
| 70 | } | |
| 71 | ||
| 72 | 57 | public Object getPrincipal() { |
| 73 | 57 | return this.principal; |
| 74 | } | |
| 75 | } |
|
||||||||||