01: /*
02: * ====================================================================
03: * Copyright (c) 2004-2008 TMate Software Ltd. All rights reserved.
04: *
05: * This software is licensed as described in the file COPYING, which
06: * you should have received as part of this distribution. The terms
07: * are also available at http://svnkit.com/license.html
08: * If newer versions of this license are posted there, you may use a
09: * newer version instead, at your option.
10: * ====================================================================
11: */
12: package org.tmatesoft.svn.core.auth;
13:
14: import org.tmatesoft.svn.core.SVNErrorMessage;
15: import org.tmatesoft.svn.core.SVNURL;
16:
17: /**
18: * The <b>ISVNAuthenticationProvider</b> interface is implemented by user
19: * credentials providers. Such a provider is set to an authentication manager
20: * calling {@link ISVNAuthenticationManager#setAuthenticationProvider(ISVNAuthenticationProvider) setAuthenticationProvider()}.
21: * When a repository server pulls user's credentials, an <b>SVNRepository</b> driver
22: * asks the registered <b>ISVNAuthenticationManager</b> for credentials. The auth manager in its turn
23: * will ask the registered auth provider for credentials.
24: *
25: * <p>
26: * <b>ISVNAuthenticationProvider</b> may be implemented to keep a list of credentials, for example, there is
27: * such a default SVNKit implementation (that comes along with a default implementation of
28: * <b>ISVNAuthenticationManager</b> - <b>org.tmatesoft.svn.core.internal.wc.DefaultSVNAuthenticationManager</b>),
29: * that saves credentials in and retrieves them from the in-memory cache only during runtime (not on the disk);
30: * or the default one that uses the auth area cache (read the <a href="http://svnbook.red-bean.com/nightly/en/svn-book.html#svn.serverconfig.netmodel.credcache">Subversion book chapter</a>).
31: *
32: * @version 1.1.1
33: * @author TMate Software Ltd.
34: * @see ISVNAuthenticationManager
35: * @see org.tmatesoft.svn.core.io.SVNRepository
36: */
37: public interface ISVNAuthenticationProvider {
38: /**
39: * Denotes that a user credential is rejected by a server.
40: */
41: public int REJECTED = 0;
42:
43: /**
44: * Denotes that a user credential is accepted by a server and will be
45: * cached only during runtime, not on the disk.
46: */
47: public int ACCEPTED_TEMPORARY = 1;
48:
49: /**
50: * Denotes that a user credential is accepted by a server and will be
51: * cached on the disk.
52: */
53: public int ACCEPTED = 2;
54:
55: /**
56: * Returns a next user credential of the specified kind for the given
57: * authentication realm.
58: *
59: * <p>
60: * If this provider has got more than one credentials (say, a list of credentials),
61: * to get the first one of them <code>previousAuth</code> is set to
62: * <span class="javakeyword">null</span>.
63: *
64: * @param kind a credential kind (for example, like those defined in
65: * {@link ISVNAuthenticationManager})
66: * @param url a repository location that is to be accessed
67: * @param realm a repository authentication realm (host, port, realm string)
68: * @param errorMessage the recent authentication failure error message
69: * @param previousAuth the credential that was previously retrieved (to tell if it's
70: * not accepted)
71: * @param authMayBeStored if <span class="javakeyword">true</span> then the returned credential
72: * can be cached, otherwise it won't be cached anyway
73: * @return a next user credential
74: */
75: public SVNAuthentication requestClientAuthentication(String kind,
76: SVNURL url, String realm, SVNErrorMessage errorMessage,
77: SVNAuthentication previousAuth, boolean authMayBeStored);
78:
79: /**
80: * Checks a server authentication certificate and whether accepts it
81: * (if the client trusts it) or not.
82: *
83: * <p>
84: * This method is used by an SSL manager (see {@link ISVNSSLManager}).
85: *
86: * @param url a repository location that is accessed
87: * @param realm a repository authentication realm (host, port, realm string)
88: * @param certificate a server certificate object
89: * @param resultMayBeStored if <span class="javakeyword">true</span> then the server certificate
90: * can be cached, otherwise not
91: * @return the result of the certificate check ({@link #REJECTED}, {@link #ACCEPTED_TEMPORARY}, or {@link #ACCEPTED})
92: */
93: public int acceptServerAuthentication(SVNURL url, String realm,
94: Object certificate, boolean resultMayBeStored);
95: }
|