-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated test app for network monitoring
Also did some refactoring to clean up the MainActivity
- Loading branch information
Anthony Oliveri
committed
Mar 31, 2017
1 parent
0ed583a
commit 89868bf
Showing
5 changed files
with
218 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
.../main/java/com/ibm/mobilefirstplatform/clientsdk/android/core/app/MyChallengeHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright 2017 IBM Corp. | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.ibm.mobilefirstplatform.clientsdk.android.core.app; | ||
|
||
|
||
import android.content.Context; | ||
|
||
import com.ibm.mobilefirstplatform.clientsdk.android.security.mca.api.AuthenticationContext; | ||
import com.ibm.mobilefirstplatform.clientsdk.android.security.mca.api.AuthenticationListener; | ||
|
||
import org.json.JSONException; | ||
import org.json.JSONObject; | ||
|
||
|
||
public class MyChallengeHandler implements AuthenticationListener { | ||
|
||
@Override | ||
public void onAuthenticationChallengeReceived(AuthenticationContext authContext, JSONObject challenge, Context context) { | ||
try { | ||
// provide your custom credentials here | ||
// you can display a dialog here to obtain user name and password | ||
JSONObject answer = new JSONObject("{\"userName\":\"asaf\",\"password\":\"123\"}"); | ||
|
||
// submit the credentials obtained from the user | ||
authContext.submitAuthenticationChallengeAnswer(answer); | ||
} catch (JSONException e) { | ||
e.printStackTrace(); | ||
} | ||
|
||
} | ||
|
||
@Override | ||
public void onAuthenticationSuccess(Context context, JSONObject info) { } | ||
|
||
@Override | ||
public void onAuthenticationFailure(Context context, JSONObject info) { } | ||
} |
49 changes: 49 additions & 0 deletions
49
.../main/java/com/ibm/mobilefirstplatform/clientsdk/android/core/app/MyResponseListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright 2017 IBM Corp. | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.ibm.mobilefirstplatform.clientsdk.android.core.app; | ||
|
||
|
||
import android.util.Log; | ||
|
||
import com.ibm.mobilefirstplatform.clientsdk.android.core.api.Response; | ||
import com.ibm.mobilefirstplatform.clientsdk.android.core.api.ResponseListener; | ||
|
||
import org.json.JSONObject; | ||
|
||
public class MyResponseListener implements ResponseListener { | ||
|
||
@Override | ||
public void onSuccess(Response response) { | ||
// here we handle authentication success | ||
Log.i("BMSCore", "Request succeeded!"); | ||
if (response != null && response.getResponseText() != null) { | ||
Log.i("BMSCore", "Response: " + response.getResponseText()); | ||
} | ||
} | ||
|
||
@Override | ||
public void onFailure(Response response, Throwable t, JSONObject extendedInfo) { | ||
// handle auth failure | ||
Log.i("BMSCore", "Request failed!"); | ||
if (response != null && response.getResponseText() != null) { | ||
Log.i("BMSCore", "Response: " + response.getResponseText()); | ||
} | ||
if (t != null && t.getMessage() != null) { | ||
Log.i("BMSCore", "Error: " + t.getMessage()); | ||
} | ||
if (extendedInfo != null && extendedInfo.toString() != null) { | ||
Log.i("BMSCore", "Extended info: " + extendedInfo.toString()); | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
lib/src/test/java/com/ibm/mobilefirstplatform/clientsdk/android/NetworkMonitorTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Copyright 2017 IBM Corp. | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.ibm.mobilefirstplatform.clientsdk.android; | ||
|
||
import org.junit.Test; | ||
|
||
|
||
public class NetworkMonitorTests { | ||
|
||
|
||
} |