setupOnlineMenu();
return;
}
OAuthTokenizer tokenizer = new OAuthTokenizer();
AESEncrypter aes = new AESEncrypter();
try {
aes.decrypt(new FileInputStream(Global.getFileManager().getHomeDirFile("oauth.txt")));
} catch (FileNotFoundException e) {
// File not found, so we'll just get empty strings anyway.
}
if (Global.getProxyValue("url").equals("")) {
System.setProperty("http.proxyHost","") ;
System.setProperty("http.proxyPort", "") ;
System.setProperty("https.proxyHost","") ;
System.setProperty("https.proxyPort", "") ;
} else {
// PROXY
System.setProperty("http.proxyHost",Global.getProxyValue("url")) ;
System.setProperty("http.proxyPort", Global.getProxyValue("port")) ;
System.setProperty("https.proxyHost",Global.getProxyValue("url")) ;
System.setProperty("https.proxyPort", Global.getProxyValue("port")) ;
if (Global.getProxyValue("userid").equals("")) {
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new
PasswordAuthentication(Global.getProxyValue("userid"),Global.getProxyValue("password").toCharArray());
}
});
}
}
syncRunner.userStoreUrl = Global.userStoreUrl;
syncRunner.noteStoreUrl = Global.noteStoreUrl;
syncRunner.noteStoreUrlBase = Global.noteStoreUrlBase;
String authString = aes.getString();
if (!authString.equals("")) {
tokenizer.tokenize(authString);
syncRunner.authToken = tokenizer.oauth_token;
syncRunner.enConnect();
}
Global.isConnected = syncRunner.isConnected;
if (!Global.isConnected) {
OAuthWindow window = new OAuthWindow(logger);
if (window.error) {
setMessage(window.errorMessage);
return;
}
window.exec();
if (window.error) {
setMessage(window.errorMessage);
return;
}
tokenizer.tokenize(window.response);
if (tokenizer.oauth_token.equals("")) {
setMessage(tr("Invalid authorization token received."));
return;
}
aes.setString(window.response);
try {
aes.encrypt(new FileOutputStream(Global.getFileManager().getHomeDirFile("oauth.txt")));
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
syncRunner.authToken = tokenizer.oauth_token;