Package org.openstreetmap.josm.io
Class OsmConnection
- java.lang.Object
-
- org.openstreetmap.josm.io.OsmConnection
-
- Direct Known Subclasses:
OsmApi
,OsmServerReader
public class OsmConnection extends java.lang.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 java.lang.String
BASIC_AUTH
protected boolean
cancel
(package private) static OsmConnection.OAuthAccessTokenFetcher
fetcher
protected IOAuthParameters
oAuth20Parameters
-
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
addOAuth20AuthorizationHeader(HttpClient connection)
Signs the connection with an OAuth authentication headervoid
cancel()
Cancels the connection.boolean
isCanceled()
Replies true if this connection is canceledprivate void
obtainOAuth20Token()
Obtains an OAuth access token for the connection.protected java.lang.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 java.lang.String BASIC_AUTH
- See Also:
- Constant Field Values
-
cancel
protected boolean cancel
-
activeConnection
protected HttpClient activeConnection
-
oAuth20Parameters
protected IOAuthParameters oAuth20Parameters
-
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 java.lang.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
-
obtainOAuth20Token
private void obtainOAuth20Token() throws MissingOAuthAccessTokenException
Obtains an OAuth access token for the connection. Afterwards, the token is accessible viaOAuthAccessTokenHolder
/CredentialsManager
.- Throws:
MissingOAuthAccessTokenException
- if the process cannot be completed successfully
-
addOAuth20AuthorizationHeader
protected void addOAuth20AuthorizationHeader(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
-
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
-
-