Permalink
Browse files

Merge branch 'develop' of github.com:microsoft-dpe/wa-toolkit-android…

… into develop
  • Loading branch information...
2 parents 736df81 + 963da26 commit 902c9604531101567641b2408fc13b5327e4301e Juan Pablo Garcia Dalolla committed Nov 22, 2011
@@ -9,66 +9,25 @@
<uses-sdk android:minSdkVersion="8" />
<application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:name="SampleApplication">
-
- <activity android:name=".SecuredActivity" android:label="@string/app_name">
- <intent-filter >
- <action android:name="android.intent.action.MAIN" />
- </intent-filter>
- </activity>
-
- <activity android:name=".MainWindowActivity" android:label="@string/app_name">
- <intent-filter >
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.DEFAULT" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
-
- <activity android:name=".StorageTypeSelectorActivity" android:label="@string/app_name">
- <intent-filter>
- <action android:name="android.intent.action.VIEW" />
- <category android:name="android.intent.category.DEFAULT" />
- </intent-filter>
- </activity>
-
- <activity android:name=".StorageListActivity" android:label="@string/app_name">
- <intent-filter>
- <action android:name="android.intent.action.VIEW" />
- <category android:name="android.intent.category.DEFAULT" />
- </intent-filter>
- </activity>
-
- <activity android:name=".StorageCreateItemActivity" android:label="@string/app_name">
- <intent-filter>
- <action android:name="android.intent.action.VIEW" />
- <category android:name="android.intent.category.DEFAULT" />
- </intent-filter>
- </activity>
-
- <activity android:name=".StorageEntityListActivity" android:label="@string/app_name">
- <intent-filter>
- <action android:name="android.intent.action.VIEW" />
- <category android:name="android.intent.category.DEFAULT" />
- </intent-filter>
- </activity>
-
- <activity android:name=".StorageEntityActivity" android:label="@string/app_name">
- <intent-filter>
- <action android:name="android.intent.action.VIEW" />
- <category android:name="android.intent.category.DEFAULT" />
- </intent-filter>
- </activity>
-
- <activity android:name=".StorageBlobViewActivity" android:label="@string/app_name">
- <intent-filter>
- <action android:name="android.intent.action.VIEW" />
- <category android:name="android.intent.category.DEFAULT" />
- </intent-filter>
- </activity>
-
- <activity android:name="com.microsoft.samples.windowsazure.android.accesscontrol.login.AccessControlLoginActivity"></activity>
-
- <activity android:name="com.microsoft.samples.windowsazure.android.accesscontrol.login.AccessControlWebAuthActivity"></activity>
+
+ <activity android:name=".MainWindowActivity" android:label="@string/app_name">
+ <intent-filter >
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+
+ <activity android:name=".SecuredActivity" android:label="@string/app_name" />
+ <activity android:name=".StorageTypeSelectorActivity" android:label="@string/app_name" />
+ <activity android:name=".StorageListActivity" android:label="@string/app_name" />
+ <activity android:name=".StorageCreateItemActivity" android:label="@string/app_name" />
+ <activity android:name=".StorageEntityListActivity" android:label="@string/app_name" />
+ <activity android:name=".StorageEntityActivity" android:label="@string/app_name" />
+ <activity android:name=".StorageBlobViewActivity" android:label="@string/app_name" />
+
+ <activity android:name="com.microsoft.samples.windowsazure.android.accesscontrol.login.AccessControlLoginActivity" />
+ <activity android:name="com.microsoft.samples.windowsazure.android.accesscontrol.login.AccessControlWebAuthActivity" />
</application>
@@ -72,84 +72,63 @@ public void onCreate(Bundle savedInstanceState) {
return;
}
- CloudClientAccount cloudClientAccount = null;
- try {
- switch (ConnectionType.toConnectionType(connectionType)) {
- case DIRECT:
- String accountName = getString(R.string.direct_account_name);
- String accessKey = getString(R.string.direct_access_key);
+ CloudClientAccount cloudClientAccount = null;
+
+ try {
+ switch (ConnectionType.toConnectionType(connectionType)) {
+ case DIRECT:
+ String accountName = getString(R.string.direct_account_name);
+ String accessKey = getString(R.string.direct_access_key);
- if (!isValidConfigurationValue(accountName) || !isValidConfigurationValue(accessKey)) {
- showDialog(MISSING_DIRECT_PARAMETERS);
- }
-
- cloudClientAccount = new CloudStorageAccount(new StorageCredentialsAccountAndKey(accountName, accessKey));
- break;
- case CLOUDREADYACS:
- String namespace = getString(R.string.cloud_ready_acs_namespace);
- String realm = getString(R.string.cloud_ready_acs_realm);
- String proxyService = getString(R.string.cloud_ready_acs_proxy_service);
- String symmetricKey = getString(R.string.cloud_ready_acs_symmetric_key);
+ if (!isValidConfigurationValue(accountName) || !isValidConfigurationValue(accessKey)) {
+ showDialog(MISSING_DIRECT_PARAMETERS);
+ }
- if (!isValidConfigurationValue(namespace)
- || !isValidConfigurationValue(realm)
- || !isValidConfigurationValue(proxyService)
- || !isValidConfigurationValue(symmetricKey)) {
- showDialog(MISSING_CLOUDREADY_ACS_PARAMETERS);
- }
-
-
- IAccessToken token = getAccessControlToken();
-
- if (token == null || token.isExpired()) {
- String repository = String.format("https://%s.accesscontrol.windows.net/v2/metadata/IdentityProviders.js?protocol=javascriptnotify&realm=%s&version=1.0", namespace, realm);
- doAcsLogin(repository, realm, symmetricKey);
- } else {
- launchBootStrapActivity();
- }
-
- break;
- case CLOUDREADYSIMPLE:
- String service = getString(R.string.cloud_ready_simple_proxy_service);
- // TODO: Ask username and password? Add option to register?
+ cloudClientAccount = new CloudStorageAccount(new StorageCredentialsAccountAndKey(accountName, accessKey));
+ break;
+ case CLOUDREADYACS:
+ String namespace = getString(R.string.cloud_ready_acs_namespace);
+ String realm = getString(R.string.cloud_ready_acs_realm);
+ String proxyService = getString(R.string.cloud_ready_acs_proxy_service);
+ String symmetricKey = getString(R.string.cloud_ready_acs_symmetric_key);
- if (!isValidConfigurationValue(service)) {
- showDialog(MISSING_CLOUDREADY_SIMPLE_PARAMETERS);
- }
-
- cloudClientAccount = new WAZServiceAccount(new WAZServiceUsernameAndPassword("admin", "Passw0rd!"),
- new URI(service));
- break;
- }
-
- // Configure the account we'll use to access the storage
- this.getSampleApplication().setCloudClientAccount(cloudClientAccount);
- }
- catch (Exception exception)
- {
- this.showErrorMessage("Couldn't configure a cloud client account", exception);
- }
- }
-
- private void launchBootStrapActivity(){
- // If current activity is this class it launches the MainWindow bootstrap activity
- if (this.getComponentName().getClassName().equals(getCurrentClassName())){
- Intent mainActivity = new Intent(this, MainWindowActivity.class);
- startActivity (mainActivity);
- }
- }
-
- public static String getCurrentClassName(){
- return (new CurClassNameGetter()).getClassName();
- }
+ if (!isValidConfigurationValue(namespace)
+ || !isValidConfigurationValue(realm)
+ || !isValidConfigurationValue(proxyService)
+ || !isValidConfigurationValue(symmetricKey)) {
+ showDialog(MISSING_CLOUDREADY_ACS_PARAMETERS);
+ }
+
+
+ IAccessToken token = getAccessControlToken();
+
+ if (token == null || token.isExpired()) {
+ String repository = String.format("https://%s.accesscontrol.windows.net/v2/metadata/IdentityProviders.js?protocol=javascriptnotify&realm=%s&version=1.0", namespace, realm);
+ doAcsLogin(repository, realm, symmetricKey);
+ }
+
+ break;
+ case CLOUDREADYSIMPLE:
+ String service = getString(R.string.cloud_ready_simple_proxy_service);
+
+ if (!isValidConfigurationValue(service)) {
+ showDialog(MISSING_CLOUDREADY_SIMPLE_PARAMETERS);
+ }
+
+ // TODO: Ask user name and password? Add option to register?
+ cloudClientAccount = new WAZServiceAccount(new WAZServiceUsernameAndPassword("admin", "Passw0rd!"), new URI(service));
+ break;
+ }
+
+ // Configure the account we'll use to access the storage
+ this.getSampleApplication().setCloudClientAccount(cloudClientAccount);
+ }
+ catch (Exception exception)
+ {
+ this.showErrorMessage("Couldn't configure a cloud client account", exception);
+ }
+ }
- //Static Nested Class doing the trick
- public static class CurClassNameGetter extends SecurityManager{
- public String getClassName(){
- return getClassContext()[1].getName();
- }
- }
-
protected Dialog onCreateDialog(int id) {
AlertDialog dialog = new AlertDialog.Builder(this).create();
dialog.setTitle(getString(R.string.configuration_error_title));
@@ -194,8 +173,8 @@ private void doAcsLogin(String identityProvidersRepository, String realm, String
AccessControlLoginContext loginContext = new AccessControlLoginContext();
loginContext.IdentityProviderRepository = new IdentityProvidersRepository(identityProvidersRepository);
loginContext.AccessTokenHandler = new SimpleWebTokenHandler(realm, symmetricKey);
- loginContext.SuccessLoginActivity = SecuredActivity.class;
- loginContext.ErrorLoginActivity = SecuredActivity.class;
+ loginContext.SuccessLoginActivity = this.getClass();
+ //loginContext.ErrorLoginActivity = SecuredActivity.class; //TODO: add error activity
intent.putExtra(AccessControlLoginActivity.AccessControlLoginContextKey, loginContext);
startActivity(intent);

0 comments on commit 902c960

Please sign in to comment.