1 // 2 // ======================================================================== 3 // Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd. 4 // ------------------------------------------------------------------------ 5 // All rights reserved. This program and the accompanying materials 6 // are made available under the terms of the Eclipse Public License v1.0 7 // and Apache License v2.0 which accompanies this distribution. 8 // 9 // The Eclipse Public License is available at 10 // http://www.eclipse.org/legal/epl-v10.html 11 // 12 // The Apache License v2.0 is available at 13 // http://www.opensource.org/licenses/apache2.0.php 14 // 15 // You may elect to redistribute this code under either of these licenses. 16 // ======================================================================== 17 // 18 19 package org.eclipse.jetty.jaas; 20 21 import java.io.Serializable; 22 import java.security.Principal; 23 24 /** 25 * JAASPrincipal 26 * <p> 27 * Impl class of Principal interface. 28 */ 29 public class JAASPrincipal implements Principal, Serializable 30 { 31 private static final long serialVersionUID = -5538962177019315479L; 32 33 private String _name = null; 34 35 public JAASPrincipal(String userName) 36 { 37 this._name = userName; 38 } 39 40 public boolean equals (Object p) 41 { 42 if (! (p instanceof JAASPrincipal)) 43 return false; 44 45 return getName().equals(((JAASPrincipal)p).getName()); 46 } 47 48 public int hashCode () 49 { 50 return getName().hashCode(); 51 } 52 53 public String getName () 54 { 55 return this._name; 56 } 57 58 public String toString () 59 { 60 return getName(); 61 } 62 } 63 64