1. /*
  2. * @(#)NTSidDomainPrincipal.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 domain SID.
  11. *
  12. * <p> An NT user only has a domain SID if in fact they are logged
  13. * into an NT domain. If the user is logged into a workgroup or
  14. * just a standalone configuration, they will NOT have a domain SID.
  15. *
  16. * <p> Principals such as this <code>NTSidDomainPrincipal</code>
  17. * may be associated with a particular <code>Subject</code>
  18. * to augment that <code>Subject</code> with an additional
  19. * identity. Refer to the <code>Subject</code> class for more information
  20. * on how to achieve this. Authorization decisions can then be based upon
  21. * the Principals associated with a <code>Subject</code>.
  22. *
  23. * @version 1.15, 12/19/03
  24. * @see java.security.Principal
  25. * @see javax.security.auth.Subject
  26. */
  27. public class NTSidDomainPrincipal extends NTSid {
  28. private static final long serialVersionUID = 5247810785821650912L;
  29. /**
  30. * Create an <code>NTSidDomainPrincipal</code> with a Windows NT SID.
  31. *
  32. * <p>
  33. *
  34. * @param name a string version of the Windows NT SID for this
  35. * user's domain.<p>
  36. *
  37. * @exception NullPointerException if the <code>name</code>
  38. * is <code>null</code>.
  39. */
  40. public NTSidDomainPrincipal(String name) {
  41. super(name);
  42. }
  43. /**
  44. * Return a string representation of this <code>NTSidDomainPrincipal</code>.
  45. *
  46. * <p>
  47. *
  48. * @return a string representation of this
  49. * <code>NTSidDomainPrincipal</code>.
  50. */
  51. public String toString() {
  52. java.text.MessageFormat form = new java.text.MessageFormat
  53. (sun.security.util.ResourcesMgr.getString
  54. ("NTSidDomainPrincipal: name",
  55. "sun.security.util.AuthResources"));
  56. Object[] source = {getName()};
  57. return form.format(source);
  58. }
  59. /**
  60. * Compares the specified Object with this <code>NTSidDomainPrincipal</code>
  61. * for equality. Returns true if the given object is also a
  62. * <code>NTSidDomainPrincipal</code> and the two NTSidDomainPrincipals
  63. * have the same SID.
  64. *
  65. * <p>
  66. *
  67. * @param o Object to be compared for equality with this
  68. * <code>NTSidDomainPrincipal</code>.
  69. *
  70. * @return true if the specified Object is equal equal to this
  71. * <code>NTSidDomainPrincipal</code>.
  72. */
  73. public boolean equals(Object o) {
  74. if (o == null)
  75. return false;
  76. if (this == o)
  77. return true;
  78. if (!(o instanceof NTSidDomainPrincipal))
  79. return false;
  80. return super.equals(o);
  81. }
  82. }