AuthProvider.java 2.67 KB
Newer Older
Matt Tucker's avatar
Matt Tucker committed
1 2 3 4 5
/**
 * $RCSfile$
 * $Revision$
 * $Date$
 *
Matt Tucker's avatar
Matt Tucker committed
6
 * Copyright (C) 2004 Jive Software. All rights reserved.
Matt Tucker's avatar
Matt Tucker committed
7
 *
Matt Tucker's avatar
Matt Tucker committed
8 9
 * This software is published under the terms of the GNU Public License (GPL),
 * a copy of which is included in this distribution.
Matt Tucker's avatar
Matt Tucker committed
10 11 12 13 14
 */

package org.jivesoftware.messenger.auth;

/**
Matt Tucker's avatar
Matt Tucker committed
15 16 17 18
 * Provider interface for authentication. Users that wish to integrate with
 * their own authentication system must implement this class and then register
 * the implementation with Jive Messenger in the <tt>jive-messenger.xml</tt>
 * file. An entry in that file would look like the following:
Matt Tucker's avatar
Matt Tucker committed
19
 *
Matt Tucker's avatar
Matt Tucker committed
20 21 22 23 24 25
 * <pre>
 *   &lt;provider&gt;
 *     &lt;auth&gt;
 *       &lt;className&gt;com.foo.auth.CustomAuthProvider&lt;/className&gt;
 *     &lt;/auth&gt;
 *   &lt;/provider&gt;</pre>
Matt Tucker's avatar
Matt Tucker committed
26
 *
Matt Tucker's avatar
Matt Tucker committed
27
 * @author Matt Tucker
Matt Tucker's avatar
Matt Tucker committed
28 29 30 31
 */
public interface AuthProvider {

    /**
Matt Tucker's avatar
Matt Tucker committed
32 33 34
     * Returns true if this AuthProvider supports authentication using plain-text
     * passwords according to JEP--0078. Plain text authentication is not secure
     * and should generally only be used for a TLS/SSL connection.
Matt Tucker's avatar
Matt Tucker committed
35
     *
Matt Tucker's avatar
Matt Tucker committed
36 37
     * @return true if plain text password authentication is supported by
     *      this AuthProvider.
Matt Tucker's avatar
Matt Tucker committed
38 39 40 41
     */
    boolean isPlainSupported();

    /**
Matt Tucker's avatar
Matt Tucker committed
42 43
     * Returns true if this AuthProvider supports digest authentication
     * according to JEP-0078.
Matt Tucker's avatar
Matt Tucker committed
44
     *
Matt Tucker's avatar
Matt Tucker committed
45 46
     * @return true if digest authentication is supported by this
     *      AuthProvider.
Matt Tucker's avatar
Matt Tucker committed
47 48 49 50
     */
    boolean isDigestSupported();

    /**
Matt Tucker's avatar
Matt Tucker committed
51 52
     * Returns if the username and password are valid; otherwise this
     * method throws an UnauthorizedException.<p>
Matt Tucker's avatar
Matt Tucker committed
53
     *
Matt Tucker's avatar
Matt Tucker committed
54 55 56 57 58 59 60
     * If {@link #isPlainSupported()} returns false, this method should
     * throw an UnsupportedOperationException.
     *
     * @param username the username.
     * @param password the passwordl
     * @throws UnauthorizedException if the username and password do
     *      not match any existing user.
Matt Tucker's avatar
Matt Tucker committed
61 62 63 64
     */
    void authenticate(String username, String password) throws UnauthorizedException;

    /**
Matt Tucker's avatar
Matt Tucker committed
65 66 67 68 69
     * Returns if the username, token, and digest are valid; otherwise this
     * method throws an UnauthorizedException.<p>
     *
     * If {@link #isDigestSupported()} returns false, this method should
     * throw an UnsupportedOperationException.
Matt Tucker's avatar
Matt Tucker committed
70
     *
Matt Tucker's avatar
Matt Tucker committed
71 72 73 74
     * @param username the username.
     * @param token the token that was used with plain-text password to
     *      generate the digest.
     * @param digest the digest generated from plain-text password and unique token.
Matt Tucker's avatar
Matt Tucker committed
75
     * @throws UnauthorizedException if the username and password
Matt Tucker's avatar
Matt Tucker committed
76
     *      do not match any existing user.
Matt Tucker's avatar
Matt Tucker committed
77 78 79
     */
    void authenticate(String username, String token, String digest)
            throws UnauthorizedException;
Matt Tucker's avatar
Matt Tucker committed
80
}