001 /* 002 * CDDL HEADER START 003 * 004 * The contents of this file are subject to the terms of the 005 * Common Development and Distribution License, Version 1.0 only 006 * (the "License"). You may not use this file except in compliance 007 * with the License. 008 * 009 * You can obtain a copy of the license at 010 * docs/licenses/cddl.txt 011 * or http://www.opensource.org/licenses/cddl1.php. 012 * See the License for the specific language governing permissions 013 * and limitations under the License. 014 * 015 * When distributing Covered Code, include this CDDL HEADER in each 016 * file and include the License file at 017 * docs/licenses/cddl.txt. If applicable, 018 * add the following below this CDDL HEADER, with the fields enclosed 019 * by brackets "[]" replaced with your own identifying information: 020 * Portions Copyright [yyyy] [name of copyright owner] 021 * 022 * CDDL HEADER END 023 * 024 * 025 * Copyright 2011-2014 UnboundID Corp. 026 */ 027 028 package com.unboundid.directory.sdk.http.types; 029 030 import java.io.Serializable; 031 import java.util.Collection; 032 033 /** 034 * Represents a HTTP authentication result. 035 */ 036 public class AuthenticationResult implements Serializable 037 { 038 private static final long serialVersionUID = 8564121520143995963L; 039 private final Object principal; 040 private final Collection<String> authorities; 041 042 // The time that the user authenticated with the server, in milliseconds 043 // since midnight January 1, 1970 GMT 044 private final long authTime; 045 046 /** 047 * Construct a new Authentication Result with the provided information. 048 * 049 * @param principal The object representing the authenticated principal. 050 * @param authorities The authorities that the principal has been granted. 051 * @param authTime The time at which the resource owner was authenticated with 052 * the Identity Broker, in milliseconds since 1/1/70 12:00 AM. 053 */ 054 public AuthenticationResult(final Object principal, 055 final Collection<String> authorities, 056 final long authTime) 057 { 058 this.principal = principal; 059 this.authorities = authorities; 060 this.authTime = authTime; 061 } 062 063 /** 064 * The identity of the authenticated principal. 065 * 066 * @return the authenticated <code>Principal</code>. 067 */ 068 public Object getPrincipal() 069 { 070 return principal; 071 } 072 073 /** 074 * The authorities that the principal has been granted. 075 * 076 * @return the authorities granted to the principal, Never null. 077 */ 078 public Collection<String> getAuthorities() 079 { 080 return authorities; 081 } 082 083 /** 084 * Retrieves the time that the user authenticated with the server. 085 * 086 * @return Authentication time in milliseconds since midnight 1/1/1970 GMT. 087 */ 088 public long getAuthTime() { 089 return authTime; 090 } 091 }