KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > slide > jaas > spi > SlideGroup


1 /*
2  * $Header: /home/cvs/jakarta-slide/src/jaas/org/apache/slide/jaas/spi/SlideGroup.java,v 1.1 2004/05/26 10:27:09 ozeigermann Exp $
3  * $Revision: 1.1 $
4  * $Date: 2004/05/26 10:27:09 $
5  *
6  * ====================================================================
7  *
8  * Copyright 1999-2002 The Apache Software Foundation
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  *
22  */

23 package org.apache.slide.jaas.spi;
24
25 import java.security.Principal JavaDoc;
26 import java.security.acl.Group JavaDoc;
27 import java.util.Enumeration JavaDoc;
28 import java.util.HashSet JavaDoc;
29 import java.util.Iterator JavaDoc;
30
31
32 public final class SlideGroup implements Group JavaDoc {
33     
34     private final HashSet JavaDoc m_members = new HashSet JavaDoc();
35     
36     public boolean addMember(Principal JavaDoc user) {
37         return m_members.add(user);
38     }
39     
40     public boolean isMember(Principal JavaDoc member) {
41         return m_members.contains(member);
42     }
43     
44     public Enumeration JavaDoc members() {
45         class MembersEnumeration implements Enumeration JavaDoc {
46             private Iterator JavaDoc m_iter;
47             public MembersEnumeration(Iterator JavaDoc iter) {
48                 m_iter = iter;
49             }
50             public boolean hasMoreElements () {
51                 return m_iter.hasNext();
52             }
53             public Object JavaDoc nextElement () {
54                 return m_iter.next();
55             }
56         }
57
58         return new MembersEnumeration(m_members.iterator());
59     }
60
61     public boolean removeMember(Principal JavaDoc user) {
62         return m_members.remove(user);
63     }
64     
65     public String JavaDoc getName() {
66         return "roles";
67     }
68
69 }
70
Popular Tags