KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ccvs > core > IUserAuthenticator


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  * Atsuhiko Yamanaka, JCraft,Inc. - adding promptForKeyboradInteractive method
11  *******************************************************************************/

12 package org.eclipse.team.internal.ccvs.core;
13
14 /**
15  * IUserAuthenticators are used to ensure that the user
16  * is validated for access to a given repository. The
17  * user is prompted for a username and password as
18  * appropriate for the given repository type.
19  */

20 public interface IUserAuthenticator {
21     
22     /**
23      * Button id for an "Ok" button (value 0).
24      */

25     public int OK_ID = 0;
26
27     /**
28      * Button id for a "Cancel" button (value 1).
29      */

30     public int CANCEL_ID = 1;
31
32     /**
33      * Button id for a "Yes" button (value 2).
34      */

35     public int YES_ID = 2;
36
37     /**
38      * Button id for a "No" button (value 3).
39      */

40     public int NO_ID = 3;
41     
42     /**
43      * Constant for a prompt with no type (value 0).
44      */

45     public final static int NONE = 0;
46
47     /**
48      * Constant for an error prompt (value 1).
49      */

50     public final static int ERROR = 1;
51
52     /**
53      * Constant for an information prompt (value 2).
54      */

55     public final static int INFORMATION = 2;
56
57     /**
58      * Constant for a question prompt (value 3).
59      */

60     public final static int QUESTION = 3;
61
62     /**
63      * Constant for a warning dialog (value 4).
64      */

65     public final static int WARNING = 4;
66     
67     /**
68      * Authenticates the user for access to a given repository.
69      * The obtained values for user name and password will be placed
70      * into the supplied user info object. Implementors are allowed to
71      * save user names and passwords. The user should be prompted for
72      * user name and password if there is no saved one, or if <code>retry</code>
73      * is <code>true</code>.
74      *
75      * @param location The repository location to authenticate the user for or <code>null</code>
76      * if this authentication is not for a CVS repository location.
77      * @param info The object to place user validation information into.
78      * @param retry <code>true</code> if a previous attempt to log in failed.
79      * @param message An optional message to display if, e.g., previous authentication failed.
80      * @return true if the validation was successful, and false otherwise.
81      */

82     public void promptForUserInfo(ICVSRepositoryLocation location, IUserInfo userInfo, String JavaDoc message) throws CVSException;
83     
84     /**
85      * Prompts the user for a number values using text fields. The labels are provided in
86      * the <core>prompt</code> array. Implementors will return the entered values, or null if
87      * the user cancel the prompt.
88      *
89      * @param location The repository location to authenticate the user for or <code>null</code>
90      * if this authentication is not for a CVS repository location.
91      * @param destination The destination in the format like username@hostname:port
92      * @param name A name about this dialog.
93      * @param instruction A message for the instruction.
94      * @param prompt Labels for text fields.
95      * @param echo the array to show which fields are secret.
96      * @return the entered values, or null if the user canceled.
97      *
98      * @since 3.0
99      */

100     public String JavaDoc[] promptForKeyboradInteractive(ICVSRepositoryLocation location, String JavaDoc destination, String JavaDoc name, String JavaDoc instruction, String JavaDoc[] prompt, boolean[] echo) throws CVSException;
101
102     /**
103      * Prompts the authenticator for additional information regarding this authentication
104      * request. A default implementation of this method should return the <code>defaultResponse</code>,
105      * whereas alternate implementations could prompt the user with a dialog.
106      *
107      * @param location the repository location for this authentication or <code>null</code>
108      * if this authentication is not for a CVS repository location.
109      * @param promptType one of the following values:
110      * <ul>
111      * <li> <code>NONE</code> for a unspecified prompt type </li>
112      * <li> <code>ERROR</code> for an error prompt </li>
113      * <li> <code>INFORMATION</code> for an information prompt </li>
114      * <li> <code>QUESTION </code> for a question prompt </li>
115      * <li> <code>WARNING</code> for a warning prompt </li>
116      * </ul>
117      * @param title the prompt title that could be displayed to the user
118      * @param message the prompt
119      * @param promptResponses the possible responses to the prompt
120      * @param defaultResponse the default response to the prompt
121      * @return the response to the prompt
122      *
123      * @since 3.0
124      */

125     public int prompt(ICVSRepositoryLocation location, int promptType, String JavaDoc title, String JavaDoc message, int[] promptResponses, int defaultResponseIndex);
126
127     /**
128      * The host key for the given location has changed.
129      * @param location
130      * @return true if new host key should be accepted
131      */

132     public boolean promptForHostKeyChange(ICVSRepositoryLocation location);
133 }
134
Popular Tags