KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > management > config > AuthRealmConfigImpl


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.management.config;
25
26 import javax.management.ObjectName JavaDoc;
27 import javax.management.AttributeNotFoundException JavaDoc;
28 import javax.management.JMException JavaDoc;
29 import javax.management.Attribute JavaDoc;
30 import com.sun.enterprise.management.config.AMXConfigImplBase;
31 import com.sun.enterprise.management.support.Delegate;
32     
33 import com.sun.enterprise.management.support.oldconfig.OldAuthRealmMBean;
34
35 import com.sun.appserv.management.config.AuthRealmConfig;
36
37
38 /**
39     Configuration for the <auth-realm> element.
40 */

41
42
43 public final class AuthRealmConfigImpl extends AMXConfigImplBase
44     //implements AuthRealmConfig
45
{
46         public
47     AuthRealmConfigImpl( final Delegate delegate )
48     {
49         super( delegate );
50     }
51
52
53     static private final String JavaDoc[] STRING_SIG = new String JavaDoc[] { String JavaDoc.class.getName() };
54     static private final String JavaDoc[] UPG_SIG =
55         new String JavaDoc[] { String JavaDoc.class.getName(), String JavaDoc.class.getName(), String JavaDoc[].class.getName() };
56     
57         public void
58     addUser(
59         final String JavaDoc user,
60         final String JavaDoc password,
61         final String JavaDoc[] groupList )
62     {
63         getDelegate().invoke(
64             "addUser",
65             new Object JavaDoc[] { user, password, groupList },
66             UPG_SIG );
67     }
68     
69         public String JavaDoc[]
70     getGroupNames()
71     {
72         String JavaDoc[] result = null;
73         
74         // offline is implemented as an Attribute (as it should be)
75
// online is implemented (incorrectly) as an operation.
76
try
77         {
78             result = (String JavaDoc[])getDelegate().invoke( "getGroupNames", null, null );
79         }
80         catch( Exception JavaDoc e )
81         {
82             try
83             {
84                 result = (String JavaDoc[])delegateGetAttributeNoThrow( "GroupNames" );
85             }
86             catch( Exception JavaDoc ee )
87             {
88                 // may not be any for this type of realm
89
}
90         }
91         
92         return result;
93     }
94     
95         public String JavaDoc[]
96     getUserGroupNames( final String JavaDoc user )
97     {
98         return (String JavaDoc[])getDelegate().invoke(
99             "getUserGroupNames",
100             new Object JavaDoc[] { user },
101             STRING_SIG );
102     }
103     
104         public String JavaDoc[]
105     getUserNames()
106     {
107         String JavaDoc[] result = null;
108         
109         // offline is implemented as an Attribute (as it should be)
110
// online is implemented (incorrectly) as an operation.
111
try
112         {
113             result = (String JavaDoc[])getDelegate().invoke( "getUserNames", null, null );
114         }
115         catch( Exception JavaDoc e )
116         {
117             try
118             {
119                 result = (String JavaDoc[])delegateGetAttributeNoThrow( "UserNames" );
120             }
121             catch( Exception JavaDoc ee )
122             {
123                 // may not be any for this type of realm
124
}
125         }
126         
127         return result;
128     }
129
130         public void
131     removeUser( final String JavaDoc user )
132     {
133         getDelegate().invoke( "removeUser", new Object JavaDoc[] { user }, STRING_SIG );
134     }
135     
136         public void
137     updateUser(
138         final String JavaDoc user,
139         final String JavaDoc password,
140         final String JavaDoc[] groupList )
141     {
142         getDelegate().invoke( "updateUser",
143             new Object JavaDoc[] { user, password, groupList },
144             UPG_SIG );
145     }
146 }
147
148
149
150
151
152
153
154
155
156
157
Popular Tags