1. /*
  2. * @(#)AuthProvider.java 1.3 04/02/03
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package java.security;
  8. import javax.security.auth.Subject;
  9. import javax.security.auth.login.LoginException;
  10. import javax.security.auth.callback.CallbackHandler;
  11. /**
  12. * This class defines login and logout methods for a provider.
  13. *
  14. * <p> While callers may invoke <code>login</code> directly,
  15. * the provider may also invoke <code>login</code> on behalf of callers
  16. * if it determines that a login must be performed
  17. * prior to certain operations.
  18. *
  19. * @version 1.3, 02/03/04
  20. * @since 1.5
  21. */
  22. public abstract class AuthProvider extends Provider {
  23. /**
  24. * Constructs a provider with the specified name, version number,
  25. * and information.
  26. *
  27. * @param name the provider name.
  28. * @param version the provider version number.
  29. * @param info a description of the provider and its services.
  30. */
  31. protected AuthProvider(String name, double version, String info) {
  32. super(name, version, info);
  33. }
  34. /**
  35. * Log in to this provider.
  36. *
  37. * <p> The provider relies on a <code>CallbackHandler</code>
  38. * to obtain authentication information from the caller
  39. * (a PIN, for example). If the caller passes a <code>null</code>
  40. * handler to this method, the provider uses the handler set in the
  41. * <code>setCallbackHandler</code> method.
  42. * If no handler was set in that method, the provider queries the
  43. * <i>auth.login.defaultCallbackHandler</i> security property
  44. * for the fully qualified class name of a default handler implementation.
  45. * If the security property is not set,
  46. * the provider is assumed to have alternative means
  47. * for obtaining authentication information.
  48. *
  49. * @param subject the <code>Subject</code> which may contain
  50. * principals/credentials used for authentication,
  51. * or may be populated with additional principals/credentials
  52. * after successful authentication has completed.
  53. * This parameter may be <code>null</code>.
  54. * @param handler the <code>CallbackHandler</code> used by
  55. * this provider to obtain authentication information
  56. * from the caller, which may be <code>null</code>
  57. *
  58. * @exception LoginException if the login operation fails
  59. * @exception SecurityException if the caller does not pass a
  60. * security check for
  61. * <code>SecurityPermission("authProvider.<i>name</i>")</code>,
  62. * where <i>name</i> is the value returned by
  63. * this provider's <code>getName</code> method
  64. */
  65. public abstract void login(Subject subject, CallbackHandler handler)
  66. throws LoginException;
  67. /**
  68. * Log out from this provider.
  69. *
  70. * @exception LoginException if the logout operation fails
  71. * @exception SecurityException if the caller does not pass a
  72. * security check for
  73. * <code>SecurityPermission("authProvider.<i>name</i>")</code>,
  74. * where <i>name</i> is the value returned by
  75. * this provider's <code>getName</code> method
  76. */
  77. public abstract void logout() throws LoginException;
  78. /**
  79. * Set a <code>CallbackHandler</code>.
  80. *
  81. * <p> The provider uses this handler if one is not passed to the
  82. * <code>login</code> method. The provider also uses this handler
  83. * if it invokes <code>login</code> on behalf of callers.
  84. * In either case if a handler is not set via this method,
  85. * the provider queries the
  86. * <i>auth.login.defaultCallbackHandler</i> security property
  87. * for the fully qualified class name of a default handler implementation.
  88. * If the security property is not set,
  89. * the provider is assumed to have alternative means
  90. * for obtaining authentication information.
  91. *
  92. * @param handler a <code>CallbackHandler</code> for obtaining
  93. * authentication information, which may be <code>null</code>
  94. *
  95. * @exception SecurityException if the caller does not pass a
  96. * security check for
  97. * <code>SecurityPermission("authProvider.<i>name</i>")</code>,
  98. * where <i>name</i> is the value returned by
  99. * this provider's <code>getName</code> method
  100. */
  101. public abstract void setCallbackHandler(CallbackHandler handler);
  102. }