001// License: GPL. For details, see LICENSE file. 002package org.openstreetmap.josm.gui.oauth; 003 004import static org.openstreetmap.josm.tools.I18n.tr; 005 006/** 007 * The type of procedure to use for retrieving OAuth credentials. 008 */ 009public enum AuthorizationProcedure { 010 /** 011 * Run a fully automatic procedure to get an access token from the OSM website. 012 * JOSM accesses the OSM website on behalf of the JOSM user and interacts 013 * with the site using an OSM session, form posting and screen scraping. 014 */ 015 FULLY_AUTOMATIC, 016 017 /** 018 * Run a semi-automatic procedure to get an access token from the OSM website. 019 * JOSM submits the standards OAuth requests to get a Request Token and an 020 * Access Token. It dispatches the user to the OSM website in an external browser 021 * to authenticate itself and to accept the request token submitted by JOSM. 022 */ 023 SEMI_AUTOMATIC, 024 025 /** 026 * Enter an Access Token manually. The Access Token could have been generated 027 * by another JOSM user and sent to the current JOSM user via email, i.e. in order 028 * to grant the current OSM user the right download its private GPS traces. Or it could 029 * have been generated in a former session and filed away in a secure place. 030 */ 031 MANUALLY; 032 033 /** 034 * Returns the translated name of this procedure 035 * @return the translated name of this procedure 036 */ 037 public String getText() { 038 switch(this) { 039 case FULLY_AUTOMATIC: 040 return tr("Fully automatic"); 041 case SEMI_AUTOMATIC: 042 return tr("Semi-automatic"); 043 case MANUALLY: 044 return tr("Manual"); 045 } 046 throw new IllegalStateException(); 047 } 048 049 /** 050 * Returns a translated description of this procedure 051 * @return a translated description of this procedure 052 */ 053 public String getDescription() { 054 switch(this) { 055 case FULLY_AUTOMATIC: 056 return tr( 057 "<html>Run a fully automatic procedure to get an access token from the OSM website.<br>" 058 + "JOSM accesses the OSM website on behalf of the JOSM user and fully<br>" 059 + "automatically authorizes the user and retrieves an Access Token.</html>" 060 ); 061 case SEMI_AUTOMATIC: 062 return tr( 063 "<html>Run a semi-automatic procedure to get an access token from the OSM website.<br>" 064 + "JOSM submits the standards OAuth requests to get a Request Token and an<br>" 065 + "Access Token. It dispatches the user to the OSM website in an external browser<br>" 066 + "to authenticate itself and to accept the request token submitted by JOSM.</html>" 067 ); 068 case MANUALLY: 069 return tr( 070 "<html>Enter an Access Token manually if it was generated and retrieved outside<br>" 071 + "of JOSM.</html>" 072 ); 073 } 074 throw new IllegalStateException(); 075 } 076}