1. /*
  2. * @(#)SaslServerFactory.java 1.14 04/05/05
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package javax.security.sasl;
  8. import java.util.Map;
  9. import javax.security.auth.callback.CallbackHandler;
  10. /**
  11. * An interface for creating instances of <tt>SaslServer</tt>.
  12. * A class that implements this interface
  13. * must be thread-safe and handle multiple simultaneous
  14. * requests. It must also have a public constructor that accepts no
  15. * argument.
  16. *<p>
  17. * This interface is not normally accessed directly by a server, which will use the
  18. * <tt>Sasl</tt> static methods
  19. * instead. However, a particular environment may provide and install a
  20. * new or different <tt>SaslServerFactory</tt>.
  21. *
  22. * @since 1.5
  23. *
  24. * @see SaslServer
  25. * @see Sasl
  26. *
  27. * @author Rosanna Lee
  28. * @author Rob Weltman
  29. */
  30. public abstract interface SaslServerFactory {
  31. /**
  32. * Creates a <tt>SaslServer</tt> using the parameters supplied.
  33. * It returns null
  34. * if no <tt>SaslServer</tt> can be created using the parameters supplied.
  35. * Throws <tt>SaslException</tt> if it cannot create a <tt>SaslServer</tt>
  36. * because of an error.
  37. *
  38. * @param mechanism The non-null
  39. * IANA-registered name of a SASL mechanism. (e.g. "GSSAPI", "CRAM-MD5").
  40. * @param protocol The non-null string name of the protocol for which
  41. * the authentication is being performed (e.g., "ldap").
  42. * @param serverName The non-null fully qualified host name of the server
  43. * to authenticate to.
  44. * @param props The possibly null set of properties used to select the SASL
  45. * mechanism and to configure the authentication exchange of the selected
  46. * mechanism. See the <tt>Sasl</tt> class for a list of standard properties.
  47. * Other, possibly mechanism-specific, properties can be included.
  48. * Properties not relevant to the selected mechanism are ignored.
  49. *
  50. * @param cbh The possibly null callback handler to used by the SASL
  51. * mechanisms to get further information from the application/library
  52. * to complete the authentication. For example, a SASL mechanism might
  53. * require the authentication ID, password and realm from the caller.
  54. * The authentication ID is requested by using a <tt>NameCallback</tt>.
  55. * The password is requested by using a <tt>PasswordCallback</tt>.
  56. * The realm is requested by using a <tt>RealmChoiceCallback</tt> if there is a list
  57. * of realms to choose from, and by using a <tt>RealmCallback</tt> if
  58. * the realm must be entered.
  59. *
  60. *@return A possibly null <tt>SaslServer</tt> created using the parameters
  61. * supplied. If null, this factory cannot produce a <tt>SaslServer</tt>
  62. * using the parameters supplied.
  63. *@exception SaslException If cannot create a <tt>SaslServer</tt> because
  64. * of an error.
  65. */
  66. public abstract SaslServer createSaslServer(
  67. String mechanism,
  68. String protocol,
  69. String serverName,
  70. Map<String,?> props,
  71. CallbackHandler cbh) throws SaslException;
  72. /**
  73. * Returns an array of names of mechanisms that match the specified
  74. * mechanism selection policies.
  75. * @param props The possibly null set of properties used to specify the
  76. * security policy of the SASL mechanisms. For example, if <tt>props</tt>
  77. * contains the <tt>Sasl.POLICY_NOPLAINTEXT</tt> property with the value
  78. * <tt>"true"</tt>, then the factory must not return any SASL mechanisms
  79. * that are susceptible to simple plain passive attacks.
  80. * See the <tt>Sasl</tt> class for a complete list of policy properties.
  81. * Non-policy related properties, if present in <tt>props</tt>, are ignored.
  82. * @return A non-null array containing a IANA-registered SASL mechanism names.
  83. */
  84. public abstract String[] getMechanismNames(Map<String,?> props);
  85. }