src/share/classes/com/sun/security/auth/LdapPrincipal.java

Print this page




  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.security.auth;
  27 
  28 import java.security.Principal;
  29 import javax.naming.InvalidNameException;
  30 import javax.naming.ldap.LdapName;
  31 
  32 /**
  33  * A principal identified by a distinguished name as specified by
  34  * <a href="http://ietf.org//rfc/rfc2253.txt">RFC 2253</a>.
  35  *
  36  * <p>
  37  * After successful authentication, a user {@link java.security.Principal}
  38  * can be associated with a particular {@link javax.security.auth.Subject}
  39  * to augment that <code>Subject</code> with an additional identity.
  40  * Authorization decisions can then be based upon the
  41  * <code>Principal</code>s that are associated with a <code>Subject</code>.
  42  *
  43  * <p>
  44  * This class is immutable.
  45  *
  46  * @since 1.6
  47  */
  48 public final class LdapPrincipal implements Principal, java.io.Serializable {
  49 
  50     private static final long serialVersionUID = 6820120005580754861L;
  51 
  52     /**
  53      * The principal's string name
  54      *


 105     /**
 106      * Computes the hash code for this principal.
 107      *
 108      * @return The principal's hash code.
 109      */
 110     public int hashCode() {
 111         return name.hashCode();
 112     }
 113 
 114     /**
 115      * Returns the name originally used to create this principal.
 116      *
 117      * @return The principal's string name.
 118      */
 119     public String getName() {
 120         return nameString;
 121     }
 122 
 123     /**
 124      * Creates a string representation of this principal's name in the format
 125      * defined by <a href="http://ietf.org/rfc/rfc2253.txt">RFC 2253</a>.
 126      * If the name has zero components an empty string is returned.
 127      *
 128      * @return The principal's string name.
 129      */
 130     public String toString() {
 131         return name.toString();
 132     }
 133 
 134     // Create an LdapName object from a string distinguished name.
 135     private LdapName getLdapName(String name) throws InvalidNameException {
 136         return new LdapName(name);
 137     }
 138 }


  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.security.auth;
  27 
  28 import java.security.Principal;
  29 import javax.naming.InvalidNameException;
  30 import javax.naming.ldap.LdapName;
  31 
  32 /**
  33  * A principal identified by a distinguished name as specified by
  34  * <a href="http://www.ietf.org/rfc/rfc2253.txt">RFC 2253</a>.
  35  *
  36  * <p>
  37  * After successful authentication, a user {@link java.security.Principal}
  38  * can be associated with a particular {@link javax.security.auth.Subject}
  39  * to augment that <code>Subject</code> with an additional identity.
  40  * Authorization decisions can then be based upon the
  41  * <code>Principal</code>s that are associated with a <code>Subject</code>.
  42  *
  43  * <p>
  44  * This class is immutable.
  45  *
  46  * @since 1.6
  47  */
  48 public final class LdapPrincipal implements Principal, java.io.Serializable {
  49 
  50     private static final long serialVersionUID = 6820120005580754861L;
  51 
  52     /**
  53      * The principal's string name
  54      *


 105     /**
 106      * Computes the hash code for this principal.
 107      *
 108      * @return The principal's hash code.
 109      */
 110     public int hashCode() {
 111         return name.hashCode();
 112     }
 113 
 114     /**
 115      * Returns the name originally used to create this principal.
 116      *
 117      * @return The principal's string name.
 118      */
 119     public String getName() {
 120         return nameString;
 121     }
 122 
 123     /**
 124      * Creates a string representation of this principal's name in the format
 125      * defined by <a href="http://www.ietf.org/rfc/rfc2253.txt">RFC 2253</a>.
 126      * If the name has zero components an empty string is returned.
 127      *
 128      * @return The principal's string name.
 129      */
 130     public String toString() {
 131         return name.toString();
 132     }
 133 
 134     // Create an LdapName object from a string distinguished name.
 135     private LdapName getLdapName(String name) throws InvalidNameException {
 136         return new LdapName(name);
 137     }
 138 }