1. /*
  2. * @(#)NTSidUserPrincipal.java 1.13 03/01/27
  3. *
  4. * Copyright 2003 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.13, 01/27/03
  20. * @see java.security.Principal
  21. * @see javax.security.auth.Subject
  22. */
  23. public class NTSidUserPrincipal extends NTSid {
  24. /**
  25. * Create an <code>NTSidUserPrincipal</code> with a Windows NT SID.
  26. *
  27. * <p>
  28. *
  29. * @param name a string version of the Windows NT SID for this user.<p>
  30. *
  31. * @exception NullPointerException if the <code>name</code>
  32. * is <code>null</code>.
  33. */
  34. public NTSidUserPrincipal(String name) {
  35. super(name);
  36. }
  37. /**
  38. * Return a string representation of this <code>NTSidUserPrincipal</code>.
  39. *
  40. * <p>
  41. *
  42. * @return a string representation of this <code>NTSidUserPrincipal</code>.
  43. */
  44. public String toString() {
  45. java.text.MessageFormat form = new java.text.MessageFormat
  46. (sun.security.util.ResourcesMgr.getString
  47. ("NTSidUserPrincipal: name",
  48. "sun.security.util.AuthResources"));
  49. Object[] source = {getName()};
  50. return form.format(source);
  51. }
  52. /**
  53. * Compares the specified Object with this <code>NTSidUserPrincipal</code>
  54. * for equality. Returns true if the given object is also a
  55. * <code>NTSidUserPrincipal</code> and the two NTSidUserPrincipals
  56. * have the same SID.
  57. *
  58. * <p>
  59. *
  60. * @param o Object to be compared for equality with this
  61. * <code>NTSidUserPrincipal</code>.
  62. *
  63. * @return true if the specified Object is equal equal to this
  64. * <code>NTSidUserPrincipal</code>.
  65. */
  66. public boolean equals(Object o) {
  67. if (o == null)
  68. return false;
  69. if (this == o)
  70. return true;
  71. if (!(o instanceof NTSidUserPrincipal))
  72. return false;
  73. return super.equals(o);
  74. }
  75. }