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
12
* http://www.apache.org/licenses/LICENSE-2.0
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
20
* ====================================================================
24
package org.apache.subversion.javahl.callback;
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>
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>
35
public interface UserPasswordCallback
38
* Reject the connection to the server.
40
public static final int Reject = 0;
43
* Accept the connection to the server <i>once</i>.
45
public static final int AcceptTemporary = 1;
48
* Accept the connection to the server <i>forever</i>.
50
public static final int AcceptPermanently = 2;
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
59
public int askTrustSSLServer(String info, boolean allowPermanently);
62
* Ask the user for username and password
63
* The entered username/password is retrieved by the getUsername
64
* getPasswort methods.
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
72
public boolean prompt(String realm, String username);
75
* ask the user a yes/no question
76
* @param realm for which server realm this information is
78
* @param question question to be asked
79
* @param yesIsDefault if yes should be the default
82
public boolean askYesNo(String realm, String question,
83
boolean yesIsDefault);
86
* ask the user a question where she answers with a text.
87
* @param realm for which server realm this information is
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
93
public String askQuestion(String realm, String question,
97
* retrieve the username entered during the prompt call
98
* @return the username
100
public String getUsername();
103
* retrieve the password entered during the prompt call
104
* @return the password
106
public String getPassword();
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).
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
126
public boolean prompt(String realm, String username, boolean maySave);
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).
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
144
public String askQuestion(String realm, String question,
145
boolean showAnswer, boolean maySave);
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>.
154
public boolean userAllowedSave();