001/** 002 * Copyright 2014 Tampere University of Technology, Pori Department 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package core.tut.pori.users; 017 018import org.springframework.context.ApplicationEvent; 019 020/** 021 * Event class used for notifying changes in the user details. By default the event is of type USER_MODIFIED, and is targeted to all ServiceTypes 022 * 023 */ 024public class UserEvent extends ApplicationEvent{ 025 private static final long serialVersionUID = -7592873142973183830L; 026 private UserIdentity _userId = null; 027 private EventType _type = EventType.USER_MODIFIED; 028 private Class<?> _source = null; 029 030 /** 031 * Type of the event. 032 * 033 */ 034 public enum EventType{ 035 /** New user has been created, the details of the new user are contained in this event. */ 036 USER_CREATED, 037 /** user was modified and the event contains the new, updated details. */ 038 USER_MODIFIED, 039 /** User has been removed and does not exist in the system anymore. The last known details of the user are contained in this event. */ 040 USER_REMOVED, 041 /** User has given authorization for a specified service type(s) */ 042 USER_AUTHORIZATION_GIVEN, 043 /** User has revoked authorization for a specified service type(s)*/ 044 USER_AUTHORIZATION_REVOKED 045 } // enum EventType 046 047 /** 048 * 049 * @param source class of the event creator 050 * @param userId 051 */ 052 public UserEvent(Class<?> source, UserIdentity userId) { 053 super(source); 054 _userId = userId; 055 _source = source; 056 } 057 058 /** 059 * 060 * @param source 061 * @param userId 062 * @param type 063 */ 064 public UserEvent(Class<?> source, UserIdentity userId, EventType type) { 065 super(source); 066 _userId = userId; 067 _type = type; 068 _source = source; 069 } 070 071 /** 072 * @return the userId 073 */ 074 public UserIdentity getUserId() { 075 return _userId; 076 } 077 078 /** 079 * @return the type 080 */ 081 public EventType getType() { 082 return _type; 083 } 084 085 @Override 086 public Class<?> getSource() { 087 return _source; 088 } 089}