Package org.openrefine.wikibase.commands
Class ConnectionManager
- java.lang.Object
-
- org.openrefine.wikibase.commands.ConnectionManager
-
public class ConnectionManager extends Object
Manages a connection to the current Wikibase instance.The connection can be either
BasicApiConnectionorOAuthApiConnection.- Author:
- Antonin Delpeuch, Lu Liu
-
-
Field Summary
Fields Modifier and Type Field Description static intCONNECT_TIMEOUTstatic StringPREFERENCE_STORE_KEYWe used this key to read/write credentials from/to preferences in the past, which is insecure.static intREAD_TIMEOUT
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description org.wikidata.wdtk.wikibaseapi.ApiConnectiongetConnection(String mediaWikiApiEndpoint)static ConnectionManagergetInstance()StringgetUsername(String mediaWikiApiEndpoint)booleanisLoggedIn(String mediaWikiApiEndpoint)booleanlogin(String mediaWikiApiEndpoint, String username, String password)Logs 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.booleanlogin(String mediaWikiApiEndpoint, String username, List<javax.servlet.http.Cookie> cookies)Logs in to the Wikibase instance, using cookies.voidlogout(String mediaWikiApiEndpoint)
-
-
-
Field Detail
-
PREFERENCE_STORE_KEY
public static final String 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:
- Constant Field Values
-
CONNECT_TIMEOUT
public static final int CONNECT_TIMEOUT
- See Also:
- Constant Field Values
-
READ_TIMEOUT
public static final int READ_TIMEOUT
- See Also:
- Constant Field Values
-
-
Method Detail
-
getInstance
public static ConnectionManager getInstance()
-
login
public boolean login(String mediaWikiApiEndpoint, String username, String password)
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
public void logout(String mediaWikiApiEndpoint)
-
getConnection
public org.wikidata.wdtk.wikibaseapi.ApiConnection getConnection(String mediaWikiApiEndpoint)
-
isLoggedIn
public boolean isLoggedIn(String mediaWikiApiEndpoint)
-
-