1. /*
  2. * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
  3. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  4. */
  5. package javax.resource.spi.security;
  6. import javax.resource.spi.SecurityException;
  7. /** The interface <code>javax.resource.spi.security.GenericCredential</code>
  8. * defines a security mechanism independent interface for accessing
  9. * security credential of a resource principal.
  10. *
  11. * <p>The <code>GenericCredential</code> interface provides a Java
  12. * wrapper over an underlying mechanism specific representation of
  13. * a security credential. For example, the <code>GenericCredential</code>
  14. * interface can be used to wrap Kerberos credentials.
  15. *
  16. * <p>The connector architecture does not define any standard format
  17. * and requirements for security mechanism specific credentials. For
  18. * example, a security credential wrapped by a GenericCredential
  19. * interface can have a native representation specific to an operating
  20. * system.
  21. *
  22. * <p>The GenericCredential interface enables a resource adapter to
  23. * extract information about a security credential. The resource adapter
  24. * can then manage EIS sign-on for a resource principal by either:
  25. * <UL>
  26. * <LI>using the credentials in an EIS specific manner if the underlying
  27. * EIS supports the security mechanism type represented by the
  28. * GenericCredential instance, or,
  29. * <LI>using GSS-API if the resource adapter and underlying EIS
  30. * instance support GSS-API.
  31. * </UL>
  32. *
  33. * @author Rahul Sharma
  34. * @version 0.7
  35. * @since 0.7
  36. * @see javax.security.auth.Subject
  37. * @see java.security.Principal
  38. **/
  39. public interface GenericCredential {
  40. /** Returns the name of the resource principal associated
  41. * with a GenericCredential instance.
  42. *
  43. * @return Name of the principal
  44. **/
  45. public
  46. String getName();
  47. /** Returns the mechanism type for the GenericCredential instance.
  48. * The mechanism type definition for GenericCredential should be
  49. * consistent with the Object Identifier (OID) based representation
  50. * specified in the GSS specification. In the GenericCredential
  51. * interface, the mechanism type is returned as a stringified
  52. * representation of the OID specification.
  53. *
  54. * @return mechanisn type
  55. **/
  56. public
  57. String getMechType();
  58. /** Gets security data for a specific security mechanism represented
  59. * by the GenericCredential. An example is authentication data required
  60. * for establishing a secure association with an EIS instance on
  61. * behalf of the associated resource principal.
  62. *
  63. * <p>The getCredentialData method returns the credential
  64. * representation as an array of bytes. Note that the connector
  65. * architecture does not define any standard format for the returned
  66. * credential data.
  67. *
  68. * @return credential representation as an array of bytes.
  69. * @throws SecurityException
  70. * Failed operation due to security related
  71. * error condition
  72. **/
  73. public
  74. byte[] getCredentialData() throws SecurityException;
  75. /** Tests if this GenericCredential instance refers to the same entity
  76. * as the supplied object. The two credentials must be acquired over
  77. * the same mechanisms and must refer to the same principal.
  78. *
  79. * Returns true if the two GenericCredentials refer to the same entity;
  80. * false otherwise.
  81. **/
  82. public
  83. boolean equals(Object another);
  84. /** Returns the hash code for this GenericCredential
  85. *
  86. * @return hash code for this GenericCredential
  87. **/
  88. public
  89. int hashCode();
  90. }