View Javadoc

    1   /* Copyright 2004, 2005 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.providers.AbstractAuthenticationToken;
    19  import org.acegisecurity.GrantedAuthority;
    20
    21  import java.security.cert.X509Certificate;
    22
    23  /***
    24   * <code>Authentication</code> implementation for X.509 client-certificate authentication.
    25   *
    26   * @author Luke Taylor
    27   * @version $Id: X509AuthenticationToken.java,v 1.5 2005/11/17 00:56:09 benalex Exp $
    28   */
    29  public class X509AuthenticationToken extends AbstractAuthenticationToken {
    30      //~ Instance fields ========================================================
    31
    32      private X509Certificate credentials;
    33      private Object principal;
    34      private GrantedAuthority[] authorities;
    35      private boolean authenticated = false;
    36      private Object details = null;
    37
    38      //~ Constructors ===========================================================
    39
    40      /*** Used for an authentication request */
    41      public X509AuthenticationToken(X509Certificate credentials) {
    42          this.credentials = credentials;
    43      }
    44
    45      public X509AuthenticationToken(Object principal, X509Certificate credentials, GrantedAuthority[] authorities) {
    46          this.credentials = credentials;
    47          this.principal = principal;
    48          this.authorities = authorities;
    49      }
    50
    51      //~ Methods ================================================================
    52
    53      public Object getDetails() {
    54          return details;
    55      }
    56
    57      public void setDetails(Object details) {
    58          this.details = details;
    59      }
    60
    61
    62      public void setAuthenticated(boolean isAuthenticated) {
    63          this.authenticated = isAuthenticated;
    64      }
    65
    66      public boolean isAuthenticated() {
    67          return authenticated;
    68      }
    69
    70      public GrantedAuthority[] getAuthorities() {
    71          return authorities;
    72      }
    73
    74      public Object getCredentials() {
    75          return credentials;
    76      }
    77
    78      public Object getPrincipal() {
    79          return principal;
    80      }
    81  }