Package org.openrefine.wikidata.commands
Class ConnectionManager
java.lang.Object
org.openrefine.wikidata.commands.ConnectionManager
Manages a connection to the current Wikibase instance.
The connection can be either BasicApiConnection or OAuthApiConnection.
- Author:
- Antonin Delpeuch, Lu Liu
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final StringWe used this key to read/write credentials from/to preferences in the past, which is insecure.static final int -
Method Summary
Modifier and TypeMethodDescriptionorg.wikidata.wdtk.wikibaseapi.ApiConnectiongetConnection(String mediaWikiApiEndpoint) static ConnectionManagergetUsername(String mediaWikiApiEndpoint) booleanisLoggedIn(String mediaWikiApiEndpoint) booleanLogs in to the Wikibase instance, using username/password.booleanlogin(String mediaWikiApiEndpoint, String consumerToken, String consumerSecret, String accessToken, String accessSecret) Logs in to the Wikibase instance, using owner-only consumer.booleanLogs in to the Wikibase instance, using cookies.void
-
Field Details
-
PREFERENCE_STORE_KEY
We used this key to read/write credentials from/to preferences in the past, which is insecure. Now this key is kept only to delete those credentials in the preferences.- See Also:
-
CONNECT_TIMEOUT
public static final int CONNECT_TIMEOUT- See Also:
-
READ_TIMEOUT
public static final int READ_TIMEOUT- See Also:
-
-
Method Details
-
getInstance
-
login
Logs in to the Wikibase instance, using username/password.If failed to login, the connection will be set to null.
- Parameters:
mediaWikiApiEndpoint- the api endpoint of the target Wikibase instanceusername- the username to log in withpassword- the password to log in with- Returns:
- true if logged in successfully, false otherwise
-
login
public boolean login(String mediaWikiApiEndpoint, String consumerToken, String consumerSecret, String accessToken, String accessSecret) Logs in to the Wikibase instance, using owner-only consumer.If failed to login, the connection will be set to null.
- Parameters:
mediaWikiApiEndpoint- the api endpoint of the target Wikibase instanceconsumerToken- consumer token of an owner-only consumerconsumerSecret- consumer secret of an owner-only consumeraccessToken- access token of an owner-only consumeraccessSecret- access secret of an owner-only consumer- Returns:
- true if logged in successfully, false otherwise
-
login
public boolean login(String mediaWikiApiEndpoint, String username, List<javax.servlet.http.Cookie> cookies) Logs in to the Wikibase instance, using cookies.If failed to login, the connection will be set to null.
- Parameters:
mediaWikiApiEndpoint- the api endpoint of the target Wikibase instanceusername- the usernamecookies- the cookies used to login- Returns:
- true if logged in successfully, false otherwise
-
logout
-
getConnection
-
isLoggedIn
-
getUsername
-