KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > activemq > jaas > GroupPrincipal


1 /**
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one or more
4  * contributor license agreements. See the NOTICE file distributed with
5  * this work for additional information regarding copyright ownership.
6  * The ASF licenses this file to You under the Apache License, Version 2.0
7  * (the "License"); you may not use this file except in compliance with
8  * the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18 package org.apache.activemq.jaas;
19
20 import java.security.Principal JavaDoc;
21
22
23 /**
24  * @version $Rev: $ $Date: $
25  */

26 public class GroupPrincipal implements Principal JavaDoc {
27
28     private final String JavaDoc name;
29     private transient int hash;
30
31     public GroupPrincipal(String JavaDoc name) {
32         if (name == null) throw new IllegalArgumentException JavaDoc("name cannot be null");
33         this.name = name;
34     }
35
36     public String JavaDoc getName() {
37         return name;
38     }
39
40     public boolean equals(Object JavaDoc o) {
41         if (this == o) return true;
42         if (o == null || getClass() != o.getClass()) return false;
43
44         final GroupPrincipal that = (GroupPrincipal) o;
45
46         if (!name.equals(that.name)) return false;
47
48         return true;
49     }
50
51     public int hashCode() {
52         if (hash == 0) {
53             hash = name.hashCode();
54         }
55         return hash;
56     }
57
58     public String JavaDoc toString() {
59         return name;
60     }
61 }
62
Popular Tags