~ubuntu-branches/ubuntu/trusty/subversion/trusty-proposed

« back to all changes in this revision

Viewing changes to subversion/bindings/javahl/src/org/apache/subversion/javahl/callback/UserPasswordCallback.java

  • Committer: Package Import Robot
  • Author(s): Andy Whitcroft
  • Date: 2012-06-21 15:36:36 UTC
  • mfrom: (0.4.13 sid)
  • Revision ID: package-import@ubuntu.com-20120621153636-amqqmuidgwgxz1ly
Tags: 1.7.5-1ubuntu1
* Merge from Debian unstable.  Remaining changes:
  - Create pot file on build.
  - Build a python-subversion-dbg package.
  - Build-depend on python-dbg.
  - Build-depend on default-jre-headless/-jdk.
  - Do not apply java-build patch.
  - debian/rules: Manually create the doxygen output directory, otherwise
    we get weird build failures when running parallel builds.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * @copyright
 
3
 * ====================================================================
 
4
 *    Licensed to the Apache Software Foundation (ASF) under one
 
5
 *    or more contributor license agreements.  See the NOTICE file
 
6
 *    distributed with this work for additional information
 
7
 *    regarding copyright ownership.  The ASF licenses this file
 
8
 *    to you under the Apache License, Version 2.0 (the
 
9
 *    "License"); you may not use this file except in compliance
 
10
 *    with the License.  You may obtain a copy of the License at
 
11
 *
 
12
 *      http://www.apache.org/licenses/LICENSE-2.0
 
13
 *
 
14
 *    Unless required by applicable law or agreed to in writing,
 
15
 *    software distributed under the License is distributed on an
 
16
 *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 
17
 *    KIND, either express or implied.  See the License for the
 
18
 *    specific language governing permissions and limitations
 
19
 *    under the License.
 
20
 * ====================================================================
 
21
 * @endcopyright
 
22
 */
 
23
 
 
24
package org.apache.subversion.javahl.callback;
 
25
 
 
26
/**
 
27
 * <p>The interface for requesting authentication credentials from the
 
28
 * user.  Should the javahl bindings need the matching information,
 
29
 * these methodes will be called.</p>
 
30
 *
 
31
 * <p>This callback can also be used to provide the equivalent of the
 
32
 * <code>--no-auth-cache</code> and <code>--non-interactive</code>
 
33
 * arguments accepted by the command-line client.</p>
 
34
 */
 
35
public interface UserPasswordCallback
 
36
{
 
37
    /**
 
38
     * Reject the connection to the server.
 
39
     */
 
40
    public static final int Reject = 0;
 
41
 
 
42
    /**
 
43
     * Accept the connection to the server <i>once</i>.
 
44
     */
 
45
    public static final int AcceptTemporary = 1;
 
46
 
 
47
    /**
 
48
     * Accept the connection to the server <i>forever</i>.
 
49
     */
 
50
    public static final int AcceptPermanently = 2;
 
51
 
 
52
    /**
 
53
     * If there are problems with the certifcate of the SSL-server, this
 
54
     * callback will be used to deside if the connection will be used.
 
55
     * @param info              the probblems with the certificate.
 
56
     * @param allowPermanently  if AcceptPermantly is a legal answer
 
57
     * @return                  one of Reject/AcceptTemporary/AcceptPermanently
 
58
     */
 
59
    public int askTrustSSLServer(String info, boolean allowPermanently);
 
60
 
 
61
    /**
 
62
     * Ask the user for username and password
 
63
     * The entered username/password is retrieved by the getUsername
 
64
     * getPasswort methods.
 
65
     *
 
66
     * @param realm     for which server realm this information is requested.
 
67
     * @param username  the default username
 
68
     * @return Whether the prompt for authentication credentials was
 
69
     * successful (e.g. in a GUI application whether the dialog box
 
70
     * was canceled).
 
71
     */
 
72
    public boolean prompt(String realm, String username);
 
73
 
 
74
    /**
 
75
     * ask the user a yes/no question
 
76
     * @param realm         for which server realm this information is
 
77
     *                      requested.
 
78
     * @param question      question to be asked
 
79
     * @param yesIsDefault  if yes should be the default
 
80
     * @return              the answer
 
81
     */
 
82
    public boolean askYesNo(String realm, String question,
 
83
                            boolean yesIsDefault);
 
84
 
 
85
    /**
 
86
     * ask the user a question where she answers with a text.
 
87
     * @param realm         for which server realm this information is
 
88
     *                      requested.
 
89
     * @param question      question to be asked
 
90
     * @param showAnswer    if the answer is shown or hidden
 
91
     * @return              the entered text or null if canceled
 
92
     */
 
93
    public String askQuestion(String realm, String question,
 
94
                              boolean showAnswer);
 
95
 
 
96
    /**
 
97
     * retrieve the username entered during the prompt call
 
98
     * @return the username
 
99
     */
 
100
    public String getUsername();
 
101
 
 
102
    /**
 
103
     * retrieve the password entered during the prompt call
 
104
     * @return the password
 
105
     */
 
106
    public String getPassword();
 
107
 
 
108
    /**
 
109
     * Request a user name and password from the user, and (usually)
 
110
     * store the auth credential caching preference specified by
 
111
     * <code>maySave</code> (used by {@link #userAllowedSave()}).
 
112
     * Applications wanting to emulate the behavior of
 
113
     * <code>--non-interactive</code> will implement this method in a
 
114
     * manner which does not require user interaction (e.g. a no-op
 
115
     * which assumes pre-cached auth credentials).
 
116
     *
 
117
     * @param realm The realm from which the question originates.
 
118
     * @param username The name of the user in <code>realm</code>.
 
119
     * @param maySave Whether caching of credentials is allowed.
 
120
     * Usually affects the return value of the {@link
 
121
     * #userAllowedSave()} method.
 
122
     * @return Whether the prompt for authentication credentials was
 
123
     * successful (e.g. in a GUI application whether the dialog box
 
124
     * was canceled).
 
125
     */
 
126
    public boolean prompt(String realm, String username, boolean maySave);
 
127
 
 
128
    /**
 
129
     * Ask the user a question, and (usually) store the auth
 
130
     * credential caching preference specified by <code>maySave</code>
 
131
     * (used by {@link #userAllowedSave()}).  Applications wanting to
 
132
     * emulate the behavior of <code>--non-interactive</code> will
 
133
     * implement this method in a manner which does not require user
 
134
     * interaction (e.g. a no-op).
 
135
     *
 
136
     * @param realm The realm from which the question originates.
 
137
     * @param question The text of the question.
 
138
     * @param showAnswer Whether the answer may be displayed.
 
139
     * @param maySave Whether caching of credentials is allowed.
 
140
     * Usually affects the return value of the {@link
 
141
     * #userAllowedSave()} method.
 
142
     * @return              answer as entered or null if canceled
 
143
     */
 
144
    public String askQuestion(String realm, String question,
 
145
                              boolean showAnswer, boolean maySave);
 
146
 
 
147
    /**
 
148
     * @return Whether the caller allowed caching of credentials the
 
149
     * last time {@link #prompt(String, String, boolean)} was called.
 
150
     * Applications wanting to emulate the behavior of
 
151
     * <code>--no-auth-cache</code> will probably always return
 
152
     * <code>false</code>.
 
153
     */
 
154
    public boolean userAllowedSave();
 
155
}