01: /*_############################################################################
02: _##
03: _## SNMP4J - UsmUserEvent.java
04: _##
05: _## Copyright (C) 2003-2008 Frank Fock and Jochen Katz (SNMP4J.org)
06: _##
07: _## Licensed under the Apache License, Version 2.0 (the "License");
08: _## you may not use this file except in compliance with the License.
09: _## You may obtain a copy of the License at
10: _##
11: _## http://www.apache.org/licenses/LICENSE-2.0
12: _##
13: _## Unless required by applicable law or agreed to in writing, software
14: _## distributed under the License is distributed on an "AS IS" BASIS,
15: _## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16: _## See the License for the specific language governing permissions and
17: _## limitations under the License.
18: _##
19: _##########################################################################*/
20:
21: package org.snmp4j.event;
22:
23: import java.util.EventObject;
24: import org.snmp4j.security.UsmUserEntry; // needed for JavaDoc
25: import org.snmp4j.security.USM;
26: import org.snmp4j.security.UsmUserTable;
27:
28: /**
29: * This Event is issued whenever a user of the {@link USM} is created
30: * modified or deleted.
31: *
32: * @author Frank Fock
33: * @version 1.0
34: */
35: public class UsmUserEvent extends EventObject {
36:
37: private static final long serialVersionUID = -2650579887988635391L;
38:
39: /**
40: * Constant: a new user was created.
41: */
42: public static final int USER_ADDED = 1;
43:
44: /**
45: * Constant: a user was deleted.
46: */
47: public static final int USER_REMOVED = 2;
48:
49: /**
50: * Constant: a user was changed (but not deleted).
51: */
52: public static final int USER_CHANGED = 3;
53:
54: private org.snmp4j.security.UsmUserEntry user;
55: private int type;
56:
57: /**
58: * Construct a UsmUserEvent.
59: *
60: * @param source
61: * the object that emitts this event
62: * @param changedEntry
63: * the changed entry
64: * @param type
65: * can be USER_ADDED, USER_REMOVED or USER_CHANGED.
66: */
67: public UsmUserEvent(Object source, UsmUserEntry changedEntry,
68: int type) {
69: super (source);
70: this .user = changedEntry;
71: this .type = type;
72: }
73:
74: /**
75: * Get the modified entry of the {@link UsmUserTable}.
76: *
77: * @return the entry <ul>
78: * <li> after the modification if the user was added or modified
79: * <li> before the modification if the user was deleted </ul>
80: */
81: public org.snmp4j.security.UsmUserEntry getUser() {
82: return user;
83: }
84:
85: /**
86: * Return the type of operation that triggered this event.
87: *
88: * @return One of USER_ADDED, USER_REMOVED or USER_CHANGED.
89: */
90: public int getType() {
91: return type;
92: }
93: }
|