1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.oauth;
|
---|
3 |
|
---|
4 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
5 |
|
---|
6 | /**
|
---|
7 | * The type of procedure to use for retrieving OAuth credentials.
|
---|
8 | */
|
---|
9 | public enum AuthorizationProcedure {
|
---|
10 | /**
|
---|
11 | * Run a fully automatic procedure to get an access token from the OSM website.
|
---|
12 | * JOSM accesses the OSM website on behalf of the JOSM user and interacts
|
---|
13 | * with the site using an OSM session, form posting and screen scraping.
|
---|
14 | */
|
---|
15 | FULLY_AUTOMATIC,
|
---|
16 |
|
---|
17 | /**
|
---|
18 | * Run a semi-automatic procedure to get an access token from the OSM website.
|
---|
19 | * JOSM submits the standards OAuth requests to get a Request Token and an
|
---|
20 | * Access Token. It dispatches the user to the OSM website in an external browser
|
---|
21 | * to authenticate itself and to accept the request token submitted by JOSM.
|
---|
22 | */
|
---|
23 | SEMI_AUTOMATIC,
|
---|
24 |
|
---|
25 | /**
|
---|
26 | * Enter an Access Token manually. The Access Token could have been generated
|
---|
27 | * by another JOSM user and sent to the current JOSM user via email, i.e. in order
|
---|
28 | * to grant the current OSM user the right download its private GPS traces. Or it could
|
---|
29 | * have been generated in a former session and filed away in a secure place.
|
---|
30 | */
|
---|
31 | MANUALLY;
|
---|
32 |
|
---|
33 | /**
|
---|
34 | * Returns the translated name of this procedure
|
---|
35 | * @return the translated name of this procedure
|
---|
36 | */
|
---|
37 | public String getText() {
|
---|
38 | switch(this) {
|
---|
39 | case FULLY_AUTOMATIC:
|
---|
40 | return tr("Fully automatic");
|
---|
41 | case SEMI_AUTOMATIC:
|
---|
42 | return tr("Semi-automatic");
|
---|
43 | case MANUALLY:
|
---|
44 | return tr("Manual");
|
---|
45 | }
|
---|
46 | throw new IllegalStateException();
|
---|
47 | }
|
---|
48 |
|
---|
49 | /**
|
---|
50 | * Returns a translated description of this procedure
|
---|
51 | * @return a translated description of this procedure
|
---|
52 | */
|
---|
53 | public String getDescription() {
|
---|
54 | switch(this) {
|
---|
55 | case FULLY_AUTOMATIC:
|
---|
56 | return tr(
|
---|
57 | "<html>Run a fully automatic procedure to get an access token from the OSM website.<br>"
|
---|
58 | + "JOSM accesses the OSM website on behalf of the JOSM user and fully<br>"
|
---|
59 | + "automatically authorizes the user and retrieves an Access Token.</html>"
|
---|
60 | );
|
---|
61 | case SEMI_AUTOMATIC:
|
---|
62 | return tr(
|
---|
63 | "<html>Run a semi-automatic procedure to get an access token from the OSM website.<br>"
|
---|
64 | + "JOSM submits the standards OAuth requests to get a Request Token and an<br>"
|
---|
65 | + "Access Token. It dispatches the user to the OSM website in an external browser<br>"
|
---|
66 | + "to authenticate itself and to accept the request token submitted by JOSM.</html>"
|
---|
67 | );
|
---|
68 | case MANUALLY:
|
---|
69 | return tr(
|
---|
70 | "<html>Enter an Access Token manually if it was generated and retrieved outside<br>"
|
---|
71 | + "of JOSM.</html>"
|
---|
72 | );
|
---|
73 | }
|
---|
74 | throw new IllegalStateException();
|
---|
75 | }
|
---|
76 | }
|
---|