001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 */ 019 020package org.apache.isis.core.commons.authentication; 021 022import java.io.Serializable; 023import java.util.List; 024 025import org.apache.isis.core.commons.encoding.Encodable; 026 027/** 028 * The representation within the system of an authenticated user. 029 */ 030public interface AuthenticationSession extends Encodable, Serializable { 031 032 /** 033 * The name of the authenticated user; for display purposes only. 034 */ 035 public String getUserName(); 036 037 public boolean hasUserNameOf(String userName); 038 039 /** 040 * The roles this user belongs to 041 */ 042 public List<String> getRoles(); 043 044 /** 045 * A unique code given to this session during authentication. 046 * 047 * <p> 048 * This can be used to confirm that this session has been properly created 049 * and the user has been authenticated. It should return an empty string ( 050 * <tt>""</tt>) if this is unauthenticated user (i.e., as created within an 051 * exploration system). 052 */ 053 public String getValidationCode(); 054 055 /** 056 * For viewers (in particular) to store additional attributes, analogous to 057 * an <tt>HttpSession</tt>. 058 */ 059 public Object getAttribute(String attributeName); 060 061 /** 062 * @see #getAttribute(String) 063 */ 064 public void setAttribute(String attributeName, Object attribute); 065 066 /** 067 * The {@link MessageBroker} that holds messages for this user. 068 */ 069 public MessageBroker getMessageBroker(); 070 /** 071 * Providing the ability for a {@link MessageBroker} to be set on this 072 * {@link AuthenticationSession} (is lazily created by the runtime). 073 */ 074 public void setMessageBroker(MessageBroker messageBroker); 075 076 077}