001: /**
002: * $Id: MSISDNAuthPrincipal.java,v 1.2 2004/01/21 20:41:39 sathyakn Exp $
003: * Copyright © 2003 Sun Microsystems, Inc. All rights reserved.
004: *
005: * U.S. Government Rights - Commercial software. Government users
006: * are subject to the Sun Microsystems, Inc. standard license
007: * agreement and applicable provisions of the FAR and its
008: * supplements.
009: *
010: * Use is subject to license terms.
011: *
012: * This distribution may include materials developed by third
013: * parties.Sun, Sun Microsystems, the Sun logo and Java are
014: * trademarks or registered trademarks of Sun Microsystems, Inc.
015: * in the U.S. and other countries.
016: *
017: * Copyright © 2003 Sun Microsystems, Inc. Tous droits réservés.
018: *
019: * L'utilisation est soumise aux termes du contrat de licence.
020: *
021: * Cette distribution peut comprendre des composants développés
022: * par des tierces parties.
023: *
024: * Sun, Sun Microsystems, le logo Sun et Java sont des marques de
025: * fabrique ou des marques déposées de Sun Microsystems, Inc. aux
026: * Etats-Unis et dans d'autres pays.
027: */package com.sun.identity.authentication.modules.msisdn;
028:
029: import java.io.IOException;
030:
031: import javax.security.auth.*;
032: import javax.security.auth.login.*;
033: import javax.security.auth.callback.*;
034:
035: import java.security.Principal;
036:
037: public class MSISDNAuthPrincipal implements Principal,
038: java.io.Serializable {
039:
040: /**
041: * @serial
042: */
043: private String name;
044:
045: public MSISDNAuthPrincipal(String name) {
046: if (name == null)
047: throw new NullPointerException("illegal null input");
048:
049: this .name = name;
050: }
051:
052: /**
053: * Return the LDAP username for this <code>MSISDNAuthPrincipal</code>.
054: *
055: * <p>
056: *
057: * @return the LDAP username for this <code>MSISDNAuthPrincipal</code>
058: */
059: public String getName() {
060: return name;
061: }
062:
063: /**
064: * Return a string representation of this <code>MSISDNAuthPrincipal</code>.
065: *
066: * <p>
067: *
068: * @return a string representation of this <code>MSISDNAuthPrincipal</code>.
069: */
070: public String toString() {
071: return ("MSISDNAuthPrincipal: " + name);
072: }
073:
074: /**
075: * Compares the specified Object with this <code>MSISDNAuthPrincipal</code>
076: * for equality. Returns true if the given object is also a
077: * <code>MSISDNAuthPrincipal</code> and the two MSISDNAuthPrincipals
078: * have the same username.
079: *
080: * <p>
081: *
082: * @param o Object to be compared for equality with this
083: * <code>MSISDNAuthPrincipal</code>.
084: *
085: * @return true if the specified Object is equal equal to this
086: * <code>MSISDNAuthPrincipal</code>.
087: */
088: public boolean equals(Object o) {
089: if (o == null)
090: return false;
091:
092: if (this == o)
093: return true;
094:
095: if (!(o instanceof MSISDNAuthPrincipal))
096: return false;
097: MSISDNAuthPrincipal that = (MSISDNAuthPrincipal) o;
098:
099: if (this .getName().equals(that.getName()))
100: return true;
101: return false;
102: }
103:
104: /**
105: * Return a hash code for this <code>MSISDNAuthPrincipal</code>.
106: *
107: * <p>
108: *
109: * @return a hash code for this <code>MSISDNAuthPrincipal</code>.
110: */
111: public int hashCode() {
112: return name.hashCode();
113: }
114: }
|