KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > admin > event > AuthRealmEvent


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 package com.sun.enterprise.admin.event;
25
26 import com.sun.enterprise.admin.event.AdminEvent;
27
28 //i18n import
29
import com.sun.enterprise.util.i18n.StringManager;
30
31 /**
32  * AuthRealmEvent - emitted by DAS after comletion of
33  * create/delete/update operation on security-service.auth-realm element
34  * Contains name of realm and action type.
35  * This event does not cover the case of changes in realm content
36  * for this realm (It is the subject for another event - UserMgmtEvent)
37  */

38 public class AuthRealmEvent extends AdminEvent {
39
40     /**
41      * Constant denoting action code
42      */

43     public static final int ACTION_CREATE = 1;
44     public static final int ACTION_DELETE = 2;
45     public static final int ACTION_UPDATE = 3;
46
47     /**
48      * Event type
49      */

50     static final String JavaDoc eventType = AuthRealmEvent.class.getName();
51
52     /**
53      * Attributes
54      */

55     private int actionType;
56     private String JavaDoc realmName;
57
58     // i18n StringManager
59
private static StringManager localStrings = StringManager.getManager( AuthRealmEvent.class );
60
61     /**
62      * Create a new AuthRealmEvent.
63      * @param type event type, a string representation for the event
64      * @param instance name of the instance to which the event applies
65      * @param realm name of the AuthRealm on which event happened.
66      * @param action type of action - one of AuthRealmEvent.ACTION_CREATE,
67      * AuthRealmEvent.ACTION_DELETE, AuthRealmEvent.ACTION_UPDATE
68      * @throws IllegalArgumentException if specified action is not valid
69      */

70     public AuthRealmEvent(String JavaDoc instance, String JavaDoc realm, int action) {
71         this(eventType, instance, realm, action);
72     }
73
74     /**
75      * Create a new AuthRealmEvent.
76      * @param type event type, a string representation for the event
77      * @param instance name of the instance to which the event applies
78      * @param realm name of the AuthRealm on which event happened.
79      * @param action type of action - one of AuthRealmEvent.ACTION_CREATE,
80      * AuthRealmEvent.ACTION_DELETE, AuthRealmEvent.ACTION_UPDATE
81      * @throws IllegalArgumentException if specified action is not valid
82      */

83     public AuthRealmEvent(String JavaDoc type, String JavaDoc instance, String JavaDoc realm, int action) {
84         super(type, instance);
85         realmName = realm;
86         setAction(action);
87     }
88
89     /**
90      * Get name of the AuthRealm on which event happened
91      */

92     public String JavaDoc getAuthRealmName() {
93         return realmName;
94     }
95
96     /**
97      * Get action type for this event.
98      */

99     public int getActionType() {
100         return actionType;
101     }
102
103     /**
104      * Set action to specified value. If action is not one of allowed,
105      * then IllegalArgumentException is thrown.
106      * @throws IllegalArgumentException if action is invalid
107      */

108     private void setAction(int action) {
109         boolean valid = false;
110         if (action==ACTION_CREATE ||
111             action==ACTION_DELETE ||
112             action==ACTION_UPDATE )
113             valid = true;
114         if (!valid) {
115             String JavaDoc msg = localStrings.getString( "admin.event.invalid_action", ""+action );
116             throw new IllegalArgumentException JavaDoc( msg );
117         }
118         this.actionType = action;
119     }
120
121 }
122
Popular Tags