001 /** 002 * 003 * Copyright 2003-2004 The Apache Software Foundation 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 package org.apache.geronimo.security.realm.providers; 018 019 import java.io.Serializable; 020 import java.security.Principal; 021 022 /** 023 * A principal that represents a group for the login modules distributed 024 * with Geronimo. Custom login modules may use this if convenient or provide 025 * their own Principal implementations -- it doesn't matter. 026 * 027 * @version $Rev: 355877 $ $Date: 2005-12-10 18:48:27 -0800 (Sat, 10 Dec 2005) $ 028 */ 029 public class GeronimoGroupPrincipal implements Principal, Serializable { 030 private final String name; 031 032 public GeronimoGroupPrincipal(String name) { 033 this.name = name; 034 } 035 036 /** 037 * Compares this principal to the specified object. Returns true 038 * if the object passed in is a GeronimoGroupPrincipal with the 039 * same name. 040 */ 041 public boolean equals(Object another) { 042 if (!(another instanceof GeronimoGroupPrincipal)) return false; 043 044 return ((GeronimoGroupPrincipal) another).name.equals(name); 045 } 046 047 /** 048 * Returns a string representation of this principal. 049 */ 050 public String toString() { 051 return name; 052 } 053 054 /** 055 * Returns a hashcode for this principal. 056 */ 057 public int hashCode() { 058 return name.hashCode(); 059 } 060 061 /** 062 * Returns the name of this principal. 063 */ 064 public String getName() { 065 return name; 066 } 067 }