1. /*
  2. * @(#)NTSidUserPrincipal.java 1.15 03/12/19
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package com.sun.security.auth;
  8. /**
  9. * <p> This class extends <code>NTSid</code>
  10. * and represents a Windows NT user's SID.
  11. *
  12. * <p> Principals such as this <code>NTSidUserPrincipal</code>
  13. * may be associated with a particular <code>Subject</code>
  14. * to augment that <code>Subject</code> with an additional
  15. * identity. Refer to the <code>Subject</code> class for more information
  16. * on how to achieve this. Authorization decisions can then be based upon
  17. * the Principals associated with a <code>Subject</code>.
  18. *
  19. * @version 1.15, 12/19/03
  20. * @see java.security.Principal
  21. * @see javax.security.auth.Subject
  22. */
  23. public class NTSidUserPrincipal extends NTSid {
  24. private static final long serialVersionUID = -5573239889517749525L;
  25. /**
  26. * Create an <code>NTSidUserPrincipal</code> with a Windows NT SID.
  27. *
  28. * <p>
  29. *
  30. * @param name a string version of the Windows NT SID for this user.<p>
  31. *
  32. * @exception NullPointerException if the <code>name</code>
  33. * is <code>null</code>.
  34. */
  35. public NTSidUserPrincipal(String name) {
  36. super(name);
  37. }
  38. /**
  39. * Return a string representation of this <code>NTSidUserPrincipal</code>.
  40. *
  41. * <p>
  42. *
  43. * @return a string representation of this <code>NTSidUserPrincipal</code>.
  44. */
  45. public String toString() {
  46. java.text.MessageFormat form = new java.text.MessageFormat
  47. (sun.security.util.ResourcesMgr.getString
  48. ("NTSidUserPrincipal: name",
  49. "sun.security.util.AuthResources"));
  50. Object[] source = {getName()};
  51. return form.format(source);
  52. }
  53. /**
  54. * Compares the specified Object with this <code>NTSidUserPrincipal</code>
  55. * for equality. Returns true if the given object is also a
  56. * <code>NTSidUserPrincipal</code> and the two NTSidUserPrincipals
  57. * have the same SID.
  58. *
  59. * <p>
  60. *
  61. * @param o Object to be compared for equality with this
  62. * <code>NTSidUserPrincipal</code>.
  63. *
  64. * @return true if the specified Object is equal equal to this
  65. * <code>NTSidUserPrincipal</code>.
  66. */
  67. public boolean equals(Object o) {
  68. if (o == null)
  69. return false;
  70. if (this == o)
  71. return true;
  72. if (!(o instanceof NTSidUserPrincipal))
  73. return false;
  74. return super.equals(o);
  75. }
  76. }