Debian Codegraph @

ssl-proxies/src/main/java/org/globus/gsi/gssapi/jaas/SimplePrincipal.java

raw
1 /*
2 * Copyright 1999-2010 University of Chicago
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
5 * compliance with the License. You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software distributed under the License is
10 * distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 * express or implied.
12 *
13 * See the License for the specific language governing permissions and limitations under the License.
14 */
15 package org.globus.gsi.gssapi.jaas;
16
17 import java.security.Principal;
18 import java.io.Serializable;
19
20 /**
21 * Simple string-based principal.
22 */
23 public class SimplePrincipal
24 implements Principal, Serializable {
25
26 private String name;
27
28 public SimplePrincipal() {
29 }
30
31 public SimplePrincipal(String name) {
32 this.name = name;
33 }
34
35 public String getName() {
36 return this.name;
37 }
38
39 public int hashCode() {
40 return (this.name == null) ? 0 : this.name.hashCode();
41 }
42
43 public boolean equals(Object another) {
44 if (!(another instanceof Principal)) {
45 return false;
46 }
47 String anotherName = ((Principal)another).getName();
48 if (this.name == null) {
49 return (this.name == anotherName);
50 } else {
51 return this.name.equals(anotherName);
52 }
53 }
54
55 public String toString() {
56 return getName();
57 }
58
59 }