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