Browse files

Merge branch 'master' of github.com:DomoTop/DomoTop

  • Loading branch information...
2 parents 6cd4b3f + 9124c09 commit 3c89f76c4c442245a7ed0684e1a73452267f28c1 @vi-n vi-n committed May 8, 2012
View
131 Product/Android/src/org/openremote/android/console/AppSettingsActivity.java
@@ -655,6 +655,7 @@ private ListView constructAutoServersView() {
new ArrayList<String>());
lv.setAdapter(serverListAdapter);
+
new IPAutoDiscoveryServer(){
@Override
protected void onProgressUpdate(Void... values) {
@@ -724,32 +725,37 @@ private void writeCustomServerToFile() {
* Submits a Certification Request to the controller
*/
private void requestAccess()
- {
+ {
final String hostname = AppSettingsActivity.currentServer;
- final ProgressDialog progress = new ProgressDialog(this);
- final Handler handler = new Handler()
- {
- public void handleMessage(Message msg) {
- if(progress.isShowing()) {
- progress.dismiss();
+
+ if(!TextUtils.isEmpty(hostname))
+ {
+ final ProgressDialog progress = new ProgressDialog(this);
+ final Handler handler = new Handler()
+ {
+ public void handleMessage(Message msg) {
+ if(progress.isShowing()) {
+ progress.dismiss();
+ }
}
+ };
+
+ if(isActivityResumed()) {
+ progress.show();
}
- };
-
- if(isActivityResumed()) {
- progress.show();
- }
-
- new Thread()
- {
- public void run()
+
+
+ new Thread()
{
- handler.sendEmptyMessage(
- ORPKCS10CertificationRequest.getInstance(getApplicationContext())
- .submitCertificationRequest(hostname)
- );
- }
- }.start();
+ public void run()
+ {
+ handler.sendEmptyMessage(
+ ORPKCS10CertificationRequest.getInstance(getApplicationContext())
+ .submitCertificationRequest(hostname)
+ );
+ }
+ }.start();
+ }
}
/**
@@ -793,46 +799,48 @@ private boolean checkAuthentication()
{
boolean returnValue = false;
- try
- {
- HttpRequestBase request = null;
- HttpResponse response = null;
- HttpParams params = new BasicHttpParams();
-
- // set time-out at 3 seconds
- HttpConnectionParams.setConnectionTimeout(params, 3 * 1000);
- HttpConnectionParams.setSoTimeout(params, 3 * 1000);
-
- HttpClient client = new DefaultHttpClient(params);
- request = new HttpGet(new URL(currentServer + "/rest/authentication/check").toURI());
-
- response = client.execute(request);
-
- returnValue = (response.getStatusLine().getStatusCode() == 200) ? true : false;
- }
- catch(IOException e)
- {
- returnValue = false;
- Log.e(Constants.LOG_CATEGORY + "AUTH_CHECK", "Can't check authentication: ", e);
- }
- catch (IllegalArgumentException e)
- {
- returnValue = false;
- Log.e(Constants.LOG_CATEGORY + "AUTH_CHECK", "Can't check authentication: ", e);
+ if (!TextUtils.isEmpty(currentServer))
+ {
+ try
+ {
+ HttpRequestBase request = null;
+ HttpResponse response = null;
+ HttpParams params = new BasicHttpParams();
+
+ // set time-out at 3 seconds
+ HttpConnectionParams.setConnectionTimeout(params, 3 * 1000);
+ HttpConnectionParams.setSoTimeout(params, 3 * 1000);
+
+ HttpClient client = new DefaultHttpClient(params);
+ request = new HttpGet(new URL(currentServer + "/rest/authentication/check").toURI());
+
+ response = client.execute(request);
+
+ returnValue = (response.getStatusLine().getStatusCode() == 200) ? true : false;
+ }
+ catch(IOException e)
+ {
+ returnValue = false;
+ Log.e(Constants.LOG_CATEGORY + "AUTH_CHECK", "Can't check authentication: ", e);
+ }
+ catch (IllegalArgumentException e)
+ {
+ returnValue = false;
+ Log.e(Constants.LOG_CATEGORY + "AUTH_CHECK", "Can't check authentication: ", e);
+ }
+ catch (URISyntaxException e)
+ {
+ returnValue = false;
+ Log.e(Constants.LOG_CATEGORY + "AUTH_CHECK", "Invalid URI: ", e);
+ }
}
- catch (URISyntaxException e)
- {
- returnValue = false;
- Log.e(Constants.LOG_CATEGORY + "AUTH_CHECK", "Invalid URI: ", e);
- }
return returnValue;
}
}.start();
}
private void retrieveCertificate()
{
- final ORKeyStore ks = ORKeyStore.getInstance(getApplicationContext());
final Button doneButton = (Button)findViewById(R.id.setting_done);
doneButton.setEnabled(false);
final ProgressDialog dialog = ProgressDialog.show(this, "Fetching certificate", "Busy fetching certificate");
@@ -850,17 +858,14 @@ public void handleMessage(Message msg) {
ViewHelper.showAlertViewWithTitle(AppSettingsActivity.this, "Connection error", "Can't connect to the server.");
} else {
ViewHelper.showAlertViewWithTitle(AppSettingsActivity.this, "No access", "You don't have access yet.\nPlease ask the administrator for permission.");
- }
-
+ }
}
- };
-
+ };
- ORKeyStore.getInstance(getApplicationContext()).checkCertificateChain(
- AppSettingsModel.getCurrentServer(getApplicationContext()),
- handler
- );
-
+ ORKeyStore.getInstance(getApplicationContext()).checkCertificateChain(
+ AppSettingsModel.getCurrentServer(getApplicationContext()),
+ handler
+ );
}
/**
View
2 Product/Android/src/org/openremote/android/console/ssl/ORKeyStore.java
@@ -42,7 +42,7 @@
import android.os.Handler;
import android.util.Log;
-/**
+/**
* Generates and manages the keystore used to authenticate in OpenRemote
* @author <a href="mailto:vincent.kriek@tass.nl">Vincent Kriek</a>
*/
View
22 Product/Android/src/org/openremote/android/console/ssl/ORPKCS10CertificationRequest.java
@@ -59,7 +59,7 @@
}
// Constants ------------------------------------------------------------------------------------
- public final static String LOG_CATEGORY = Constants.LOG_CATEGORY + ORKeyPair.class.getName();
+ public final static String LOG_CATEGORY = Constants.LOG_CATEGORY + ORPKCS10CertificationRequest.class.getName();
private static final String CSR_ALGORITHM = "SHA1WithRSA";
public static final String TIMESTAMP_FILE = "timestamp";
@@ -153,13 +153,13 @@ private PKCS10CertificationRequest getCertificationRequest(String devicename, St
new DERSet(attribute),
keypair.getPrivate());
} catch (InvalidKeyException e) {
- Log.e(LOG_CATEGORY, e.getMessage());
+ Log.e(LOG_CATEGORY, "getCertificationRequest: " + e.getMessage());
} catch (NoSuchAlgorithmException e) {
- Log.e(LOG_CATEGORY, e.getMessage());
+ Log.e(LOG_CATEGORY, "getCertificationRequest: " + e.getMessage());
} catch (NoSuchProviderException e) {
- Log.e(LOG_CATEGORY, e.getMessage());
+ Log.e(LOG_CATEGORY, "getCertificationRequest: " + e.getMessage());
} catch (SignatureException e) {
- Log.e(LOG_CATEGORY, e.getMessage());
+ Log.e(LOG_CATEGORY, "getCertificationRequest: " + e.getMessage());
}
return kpGen;
@@ -203,13 +203,13 @@ public int submitCertificationRequest(String host)
return response.getStatusLine().getStatusCode();
} catch (ClientProtocolException e) {
- Log.e(LOG_CATEGORY, e.getMessage());
+ Log.e(LOG_CATEGORY, "submitCertificationRequest: " + e.getMessage());
} catch (IOException e) {
- Log.e(LOG_CATEGORY, e.getMessage());
+ Log.e(LOG_CATEGORY, "submitCertificationRequest: " + e.getMessage());
} catch (IllegalStateException e) {
- Log.e(LOG_CATEGORY, e.getMessage());
+ Log.e(LOG_CATEGORY, "submitCertificationRequest: " + e.getMessage());
} catch (IllegalArgumentException e) {
- Log.e(LOG_CATEGORY, e.getMessage());
+ Log.e(LOG_CATEGORY, "submitCertificationRequest: " + e.getMessage());
}
return -1;
}
@@ -233,9 +233,9 @@ private void saveTimestamp(String timestamp, String host)
out.write(timestamp);
out.close();
} catch (FileNotFoundException e) {
- Log.e(LOG_CATEGORY, e.getMessage());
+ Log.e(LOG_CATEGORY, "saveTimestamp: " + e.getMessage());
} catch (IOException e) {
- Log.e(LOG_CATEGORY, e.getMessage());
+ Log.e(LOG_CATEGORY, "saveTimestamp: " + e.getMessage());
}
}
}

0 comments on commit 3c89f76

Please sign in to comment.