Package org.openstreetmap.josm.io
Class OsmConnection
- java.lang.Object
-
- org.openstreetmap.josm.io.OsmConnection
-
- Direct Known Subclasses:
OsmApi
,OsmServerReader
public class OsmConnection extends Object
Base class that handles common things like authentication for the reader and writer to the osm server.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
OsmConnection.OAuthAccessTokenFetcher
Retrieves OAuth access token.
-
Field Summary
Fields Modifier and Type Field Description protected HttpClient
activeConnection
private static String
BASIC_AUTH
protected boolean
cancel
(package private) static OsmConnection.OAuthAccessTokenFetcher
fetcher
protected OAuthParameters
oauthParameters
-
Constructor Summary
Constructors Constructor Description OsmConnection()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addAuth(HttpClient connection)
protected void
addBasicAuthorizationHeader(HttpClient con)
Adds an authentication header for basic authenticationprotected void
addOAuthAuthorizationHeader(HttpClient connection)
Signs the connection with an OAuth authentication headervoid
cancel()
Cancels the connection.boolean
isCanceled()
Replies true if this connection is canceledprotected void
obtainAccessToken(HttpClient connection)
Obtains an OAuth access token for the connection.protected String
retrieveBasicAuthorizationLogin(HttpClient con)
Retrieves login from basic authentication header, if set.static void
setOAuthAccessTokenFetcher(OsmConnection.OAuthAccessTokenFetcher tokenFetcher)
Sets the OAuth access token fetcher.
-
-
-
Field Detail
-
BASIC_AUTH
private static final String BASIC_AUTH
- See Also:
- Constant Field Values
-
cancel
protected boolean cancel
-
activeConnection
protected HttpClient activeConnection
-
oauthParameters
protected OAuthParameters oauthParameters
-
fetcher
static volatile OsmConnection.OAuthAccessTokenFetcher fetcher
-
-
Constructor Detail
-
OsmConnection
public OsmConnection()
-
-
Method Detail
-
setOAuthAccessTokenFetcher
public static void setOAuthAccessTokenFetcher(OsmConnection.OAuthAccessTokenFetcher tokenFetcher)
Sets the OAuth access token fetcher.- Parameters:
tokenFetcher
- new OAuth access token fetcher. Cannot be null- Since:
- 12803
-
cancel
public void cancel()
Cancels the connection.
-
retrieveBasicAuthorizationLogin
protected String retrieveBasicAuthorizationLogin(HttpClient con) throws OsmTransferException
Retrieves login from basic authentication header, if set.- Parameters:
con
- the connection- Returns:
- login from basic authentication header, or
null
- Throws:
OsmTransferException
- if something went wrong. Check for nested exceptions- Since:
- 12992
-
addBasicAuthorizationHeader
protected void addBasicAuthorizationHeader(HttpClient con) throws OsmTransferException
Adds an authentication header for basic authentication- Parameters:
con
- the connection- Throws:
OsmTransferException
- if something went wrong. Check for nested exceptions
-
addOAuthAuthorizationHeader
protected void addOAuthAuthorizationHeader(HttpClient connection) throws OsmTransferException
Signs the connection with an OAuth authentication header- Parameters:
connection
- the connection- Throws:
MissingOAuthAccessTokenException
- if there is currently no OAuth Access Token configuredOsmTransferException
- if signing fails
-
obtainAccessToken
protected void obtainAccessToken(HttpClient connection) throws MissingOAuthAccessTokenException
Obtains an OAuth access token for the connection. Afterwards, the token is accessible viaOAuthAccessTokenHolder
/CredentialsManager
.- Parameters:
connection
- connection for which the access token should be obtained- Throws:
MissingOAuthAccessTokenException
- if the process cannot be completed successfully
-
addAuth
protected void addAuth(HttpClient connection) throws OsmTransferException
- Throws:
OsmTransferException
-
isCanceled
public boolean isCanceled()
Replies true if this connection is canceled- Returns:
- true if this connection is canceled
-
-