001: /*
002: * $Revision: 1.2 $
003: * $Date: 2004/01/21 20:41:38 $
004: *
005: * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
006: *
007: * Redistribution and use in source and binary forms, with or without
008: * modification, are permitted provided that the following conditions
009: * are met:
010: *
011: * - Redistributions of source code must retain the above copyright
012: * notice, this list of conditions and the following disclaimer.
013: *
014: * - Redistribution in binary form must reproduce the above copyright
015: * notice, this list of conditions and the following disclaimer in
016: * the documentation and/or other materials provided with the
017: * distribution.
018: *
019: * Neither the name of Sun Microsystems, Inc. or the names of
020: * contributors may be used to endorse or promote products derived
021: * from this software without specific prior written permission.
022: *
023: * This software is provided "AS IS," without a warranty of any
024: * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
025: * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
026: * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
027: * EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES
028: * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
029: * DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN
030: * OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR
031: * FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR
032: * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF
033: * LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE SOFTWARE,
034: * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
035: *
036: * You acknowledge that Software is not designed, licensed or intended
037: * for use in the design, construction, operation or maintenance of
038: * any nuclear facility.
039: */
040:
041: package com.sun.identity.authentication.modules.idlookup;
042:
043: import java.io.IOException;
044:
045: import javax.security.auth.*;
046: import javax.security.auth.login.*;
047: import javax.security.auth.callback.*;
048:
049: import java.security.Principal;
050:
051: public class IdLookupAuthPrincipal implements Principal,
052: java.io.Serializable {
053: /**
054: * @serial
055: */
056: private String name;
057:
058: public IdLookupAuthPrincipal(String name) {
059: if (name == null)
060: throw new NullPointerException("illegal null input");
061:
062: this .name = name;
063: }
064:
065: /**
066: * Return the LDAP username for this <code>IdLookupAuthPrincipal</code>.
067: *
068: * <p>
069: *
070: * @return the LDAP username for this <code>IdLookupAuthPrincipal</code>
071: */
072: public String getName() {
073: return name;
074: }
075:
076: /**
077: * Return a string representation of this <code>IdLookupAuthPrincipal</code>.
078: *
079: * <p>
080: *
081: * @return a string representation of this <code>IdLookupAuthPrincipal</code>.
082: */
083: public String toString() {
084: return ("IdLookupAuthPrincipal: " + name);
085: }
086:
087: /**
088: * Compares the specified Object with this <code>IdLookupAuthPrincipal</code>
089: * for equality. Returns true if the given object is also a
090: * <code>IdLookupAuthPrincipal</code> and the two IdLookupAuthPrincipals
091: * have the same username.
092: *
093: * <p>
094: *
095: * @param o Object to be compared for equality with this
096: * <code>IdLookupAuthPrincipal</code>.
097: *
098: * @return true if the specified Object is equal equal to this
099: * <code>IdLookupAuthPrincipal</code>.
100: */
101: public boolean equals(Object o) {
102: if (o == null) {
103: return false;
104: }
105:
106: if (this == o) {
107: return true;
108: }
109:
110: if (!(o instanceof IdLookupAuthPrincipal)) {
111: return false;
112: }
113:
114: IdLookupAuthPrincipal that = (IdLookupAuthPrincipal) o;
115:
116: if (this .getName().equals(that.getName())) {
117: return true;
118: }
119:
120: return false;
121: }
122:
123: /**
124: * Return a hash code for this <code>IdLookupAuthPrincipal</code>.
125: *
126: * <p>
127: *
128: * @return a hash code for this <code>IdLookupAuthPrincipal</code>.
129: */
130: public int hashCode() {
131: return name.hashCode();
132: }
133: }
|