| 1 |
package org.astrogrid.samp.web; |
| 2 |
|
| 3 |
import java.util.Map; |
| 4 |
import org.astrogrid.samp.client.SampException; |
| 5 |
import org.astrogrid.samp.httpd.HttpServer; |
| 6 |
|
| 7 |
/** |
| 8 |
* Extracts credentials for presentation to the user from available |
| 9 |
* information, so that the user can decide whether to allow registration. |
| 10 |
* |
| 11 |
* @author Mark Taylor |
| 12 |
* @since 18 Jun 2016 |
| 13 |
*/ |
| 14 |
public interface CredentialPresenter { |
| 15 |
|
| 16 |
/** |
| 17 |
* Returns an object which contains user-directed credential messages, |
| 18 |
* given available information from the registration request. |
| 19 |
* If the request or securityMap can be determined to be |
| 20 |
* definitely unsuitable for registration, a SampException is thrown. |
| 21 |
* |
| 22 |
* @param request HTTP request associated with the registration request |
| 23 |
* @param securityMap information explicitly supplied by the aspiring |
| 24 |
* client in support of its application to register |
| 25 |
* @param authContent content of AuthResourceBundle bundle |
| 26 |
* @return items for presentation to the user |
| 27 |
* @throws SampException if credentials should definitely not be accepted |
| 28 |
*/ |
| 29 |
Presentation createPresentation( HttpServer.Request request, |
| 30 |
Map securityMap, |
| 31 |
AuthResourceBundle.Content authContent ) |
| 32 |
throws SampException; |
| 33 |
|
| 34 |
/** |
| 35 |
* Aggregates credential information to be presented to the user. |
| 36 |
*/ |
| 37 |
interface Presentation { |
| 38 |
|
| 39 |
/** |
| 40 |
* Returns an ordered map of String->String entries |
| 41 |
* containing name, value pairs. |
| 42 |
* |
| 43 |
* @return map with ordered entries |
| 44 |
*/ |
| 45 |
Map getAuthEntries(); |
| 46 |
|
| 47 |
/** |
| 48 |
* Returns an array of "message" objects providing additional |
| 49 |
* information for the user. |
| 50 |
* |
| 51 |
* <p>If the supplied identity information looks OK, |
| 52 |
* then returning an empty array is a good idea. |
| 53 |
* But if there is some kind of inconsistency or cause for alarm, |
| 54 |
* a sequence of GUI elements may be returned. |
| 55 |
* |
| 56 |
* <p>The return value is suitable for use as the <code>msg</code> |
| 57 |
* argument of one of <code>JOptionPane</code>'s methods. |
| 58 |
* |
| 59 |
* @return message array describing the applicant to the user |
| 60 |
* @see javax.swing.JOptionPane |
| 61 |
*/ |
| 62 |
Object[] getAuthLines(); |
| 63 |
} |
| 64 |
} |