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