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