Skip to content

Commit 04b30ba

Browse files
committed
Changes for v1.4.0
1 parent 9f899c5 commit 04b30ba

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1534
-924
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# cordova-plugin-oracle-idm-auth 1.3.0
1+
# cordova-plugin-oracle-idm-auth 1.4.0
22

33
## About the cordova-plugin-oracle-idm-auth
44
The plugin provides authentication and authorization functionality for cordova based mobile applications,

RELEASENOTES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Release Notes
22

3+
## 1.4.0 (8 Apr, 2020)
4+
* Removing the referencing of UIWebView as per Apple guideline.
5+
36
## 1.3.0 (3 Dec, 2019)
47
* API to control buttons shown on webview for OAuth usecase.
58
* Ability to store data into local authenticator secure keystore.

docs/FedAuthPropertiesBuilder.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ <h2><span class="attribs"><span class="type-signature"></span></span>FedAuthProp
3838
For example, user may accidentally click a link on the login page. In this case, user can use "Back" button to come back to the login page.
3939
For example, if the login page is not loaded correctly, user may want to try reloading the page, before cancelling the login.
4040
If user cancels the login, the promise returned by <a href="AuthenticationFlow.html#login">AuthenticationFlow#login</a> will be rejected.
41-
For iOS, UIWebView will be used by default.
42-
App can choose to use WKWebView through <a href="FedAuthPropertiesBuilder.html#enableWkWebView">configuration</a>.
41+
For iOS, WKWebView will be used by default.
4342
</p>
4443
<p>
4544
While logging out, the plugin brings up a WebView and loads the <a href="FedAuthPropertiesBuilder.html#logoutUrl">logout page</a> provided in the configuration.
@@ -3409,4 +3408,4 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Authentic
34093408
<script> prettyPrint(); </script>
34103409
<script src="scripts/linenumber.js"> </script>
34113410
</body>
3412-
</html>
3411+
</html>

docs/IdmAuthFlows.js.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,8 +1050,8 @@ <h1 class="page-title">Source: IdmAuthFlows.js</h1>
10501050
* For example, user may accidentally click a link on the login page. In this case, user can use "Back" button to come back to the login page.
10511051
* For example, if the login page is not loaded correctly, user may want to try reloading the page, before cancelling the login.
10521052
* If user cancels the login, the promise returned by {@link AuthenticationFlow#login} will be rejected.
1053-
* For iOS, {@link https://developer.apple.com/documentation/uikit/uiwebview|UIWebView} will be used by default.
1054-
* App can choose to use {@link https://developer.apple.com/documentation/webkit/wkwebview|WKWebView} through {@link FedAuthPropertiesBuilder#enableWkWebView|configuration}.
1053+
* For iOS, {@link https://developer.apple.com/documentation/webkit/wkwebview|WKWebView} will
1054+
* be used by default.
10551055
* &lt;/p>
10561056
* &lt;p>
10571057
* While logging out, the plugin brings up a WebView and loads the {@link FedAuthPropertiesBuilder#logoutUrl|logout page} provided in the configuration.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cordova-plugin-oracle-idm-auth",
3-
"version": "1.3.0",
3+
"version": "1.4.0",
44
"description": "Provides authentication and authorization functionality using the Oracle IDM SDK, supporting standard protocols like Basic Auth, OAUTH, OpenID Connect and WebSSO.",
55
"cordova": {
66
"id": "cordova-plugin-oracle-idm-auth",

plugin.xml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
77
xmlns:android="http://schemas.android.com/apk/res/android"
88
id="cordova-plugin-oracle-idm-auth"
9-
version="1.2.0">
9+
version="1.4.0">
1010
<name>cordova-plugin-oracle-idm-auth</name>
1111
<description>Provides authentication and authorization functionality using the Oracle IDM SDK, supporting standard protocols like Basic Auth, OAUTH, OpenID Connect and WebSSO</description>
1212
<keywords>cordova,idm,authentication,auth</keywords>
@@ -244,8 +244,8 @@
244244
<header-file src="src/ios/sdk/IDMMobileSDKv2/Common/OMTimer/OMTimeEvent.h"/>
245245
<header-file src="src/ios/sdk/IDMMobileSDKv2/Common/OMTimer/OMTimer.h"/>
246246
<header-file src="src/ios/sdk/IDMMobileSDKv2/Common/OMURLProtocol.h"/>
247-
<header-file src="src/ios/sdk/IDMMobileSDKv2/Common/OMWebViewClient.h"/>
248247
<header-file src="src/ios/sdk/IDMMobileSDKv2/CredentialStoreService/KeychainItemWrapper.h"/>
248+
<header-file src="src/ios/sdk/IDMMobileSDKv2/CredentialStoreService/OMClassicCredential.h"/>
249249
<header-file src="src/ios/sdk/IDMMobileSDKv2/CredentialStoreService/OMCredential.h"/>
250250
<header-file src="src/ios/sdk/IDMMobileSDKv2/CredentialStoreService/OMCredentialStore.h"/>
251251
<header-file src="src/ios/sdk/IDMMobileSDKv2/CredentialStoreService/OMKeyChain.h"/>
@@ -276,6 +276,7 @@
276276
<header-file src="src/ios/sdk/IDMMobileSDKv2/OMClientCertLogoutService.h"/>
277277
<header-file src="src/ios/sdk/IDMMobileSDKv2/OMClientCredentialGrant.h"/>
278278
<header-file src="src/ios/sdk/IDMMobileSDKv2/OMConnectionHandler.h"/>
279+
<header-file src="src/ios/sdk/IDMMobileSDKv2/OMCSRFRequestHandler.h"/>
279280
<header-file src="src/ios/sdk/IDMMobileSDKv2/OMFedAuthAuthenticationService.h"/>
280281
<header-file src="src/ios/sdk/IDMMobileSDKv2/OMFedAuthConfiguration.h"/>
281282
<header-file src="src/ios/sdk/IDMMobileSDKv2/OMFedAuthLogoutService.h"/>
@@ -309,6 +310,7 @@
309310
<header-file src="src/ios/sdk/IDMMobileSDKv2/OMToken.h"/>
310311
<header-file src="src/ios/sdk/IDMMobileSDKv2/OMVersion.h"/>
311312
<header-file src="src/ios/sdk/IDMMobileSDKv2/OMWKWebViewClient.h"/>
313+
<header-file src="src/ios/sdk/IDMMobileSDKv2/OMWKWebViewCookieHandler.h"/>
312314
<header-file src="src/ios/sdk/IDMMobileSDKv2/SecureStorage/OMDataSerializationHelper.h"/>
313315
<header-file src="src/ios/sdk/IDMMobileSDKv2/SecureStorage/OMSecureCrypto.h"/>
314316
<header-file src="src/ios/sdk/IDMMobileSDKv2/SecureStorage/OMSecureStorage.h"/>
@@ -328,8 +330,8 @@
328330
<source-file src="src/ios/sdk/IDMMobileSDKv2/Common/OMTimer/OMTimeEvent.m"/>
329331
<source-file src="src/ios/sdk/IDMMobileSDKv2/Common/OMTimer/OMTimer.m"/>
330332
<source-file src="src/ios/sdk/IDMMobileSDKv2/Common/OMURLProtocol.m"/>
331-
<source-file src="src/ios/sdk/IDMMobileSDKv2/Common/OMWebViewClient.m"/>
332333
<source-file src="src/ios/sdk/IDMMobileSDKv2/CredentialStoreService/KeychainItemWrapper.m"/>
334+
<source-file src="src/ios/sdk/IDMMobileSDKv2/CredentialStoreService/OMClassicCredential.m"/>
333335
<source-file src="src/ios/sdk/IDMMobileSDKv2/CredentialStoreService/OMCredential.m"/>
334336
<source-file src="src/ios/sdk/IDMMobileSDKv2/CredentialStoreService/OMCredentialStore.m"/>
335337
<source-file src="src/ios/sdk/IDMMobileSDKv2/CredentialStoreService/OMKeyChain.m"/>
@@ -358,6 +360,7 @@
358360
<source-file src="src/ios/sdk/IDMMobileSDKv2/OMClientCertLogoutService.m"/>
359361
<source-file src="src/ios/sdk/IDMMobileSDKv2/OMClientCredentialGrant.m"/>
360362
<source-file src="src/ios/sdk/IDMMobileSDKv2/OMConnectionHandler.m"/>
363+
<source-file src="src/ios/sdk/IDMMobileSDKv2/OMCSRFRequestHandler.m"/>
361364
<source-file src="src/ios/sdk/IDMMobileSDKv2/OMFedAuthAuthenticationService.m"/>
362365
<source-file src="src/ios/sdk/IDMMobileSDKv2/OMFedAuthConfiguration.m"/>
363366
<source-file src="src/ios/sdk/IDMMobileSDKv2/OMFedAuthLogoutService.m"/>
@@ -390,6 +393,7 @@
390393
<source-file src="src/ios/sdk/IDMMobileSDKv2/OMServiceDiscoveryHandler.m"/>
391394
<source-file src="src/ios/sdk/IDMMobileSDKv2/OMToken.m"/>
392395
<source-file src="src/ios/sdk/IDMMobileSDKv2/OMWKWebViewClient.m"/>
396+
<source-file src="src/ios/sdk/IDMMobileSDKv2/OMWKWebViewCookieHandler.m"/>
393397
<source-file src="src/ios/sdk/IDMMobileSDKv2/SecureStorage/OMDataSerializationHelper.m"/>
394398
<source-file src="src/ios/sdk/IDMMobileSDKv2/SecureStorage/OMSecureCrypto.m"/>
395399
<source-file src="src/ios/sdk/IDMMobileSDKv2/SecureStorage/OMSecureStorage.m"/>

src/android/src/oracle/idm/auth/plugin/IdmAuthentication.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,7 @@ private Map<String, Object> _fetchOauthHeaders(OMAuthenticationContext context,
756756
List<OMToken> tokens = context.getTokens(scopes);
757757
if (tokens.size() > 0)
758758
{
759+
addExpiryTimeHeader(headers, tokens.get(0).getExpiryTime());
759760
addAuthorizationHeader(headers, _BEARER, tokens.get(0).getValue());
760761
}
761762
return headers;
@@ -805,6 +806,15 @@ private void addAuthorizationHeader(Map<String, Object> headers, String tokenTyp
805806
headers.put(_AUTHORIZATION, String.format(_TOKEN_FORMAT, tokenType, token));
806807
}
807808

809+
/**
810+
* Adds expiry time header to the map.
811+
* @param headers
812+
* @param expiryTime
813+
*/
814+
private void addExpiryTimeHeader(Map<String, Object> headers, Date expiryTime)
815+
{
816+
headers.put(_EXPIRY_TIME, expiryTime);
817+
}
808818

809819
/**
810820
* @return true When OM_PROP_PARSE_TOKEN_RELAY_RESPONSE set to true, false otherwise.
@@ -843,6 +853,7 @@ private void unbindChromeTabs() {
843853
private static final String _TOKEN_FORMAT = "%s %s";
844854
private static final String _BEARER = "Bearer";
845855
private static final String _BASIC = "Basic";
856+
private static final String _EXPIRY_TIME = "ExpiryTime";
846857
private static final String _CHALLENGE_ERROR = "error";
847858
private static final String _REFRESH_EXPIRED_TOKENS = "refreshExpiredTokens";
848859
private static final String _IS_AUTHENTICATED_KEY = "isAuthenticated";

src/android/src/oracle/idm/auth/plugin/IdmAuthenticationPlugin.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,16 @@ else if ("getLocalAuthSupportInfo".equals(action))
130130
_localAuth.getLocalAuthSupportInfo(args, callbackContext);
131131
return true;
132132
}
133+
else if ("setPreference".equals(action))
134+
{
135+
_localAuth.setPreference(args, callbackContext);
136+
return true;
137+
}
138+
else if ("getPreference".equals(action))
139+
{
140+
_localAuth.getPreference(args, callbackContext);
141+
return true;
142+
}
133143

134144
invokeCallbackError(callbackContext, "Invalid action: " + action);
135145
return false;

src/android/src/oracle/idm/auth/plugin/local/LocalAuthentication.java

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@
2020
import oracle.idm.mobile.auth.local.OMFingerprintAuthenticator;
2121
import oracle.idm.mobile.auth.local.OMPinAuthenticator;
2222
import org.apache.cordova.CallbackContext;
23+
24+
import oracle.idm.mobile.auth.local.*;
25+
import oracle.idm.mobile.credentialstore.OMCredentialStore;
26+
import oracle.idm.mobile.crypto.OMKeyManagerException;
27+
import oracle.idm.mobile.crypto.OMSecureStorageException;
28+
import oracle.idm.mobile.crypto.OMSecureStorageService;
29+
import java.io.Serializable;
30+
2331
import org.apache.cordova.PluginResult;
2432
import org.json.JSONArray;
2533
import org.json.JSONObject;
@@ -41,10 +49,16 @@ public LocalAuthentication(Activity mainActivity) {
4149
this._context = mainActivity.getApplicationContext();
4250
try {
4351
this._sharedManager = OMAuthenticationManager.getInstance(mainActivity.getApplicationContext());
52+
OMAuthenticator defAuth = OMMobileSecurityService.getDefaultAuthenticator(_context);
53+
_defaultSecuredStore = new OMSecureStorageService(_context, defAuth.getKeyStore(), OMCredentialStore.DEFAULT_AUTHENTICATOR_NAME);
54+
4455
_init();
4556
} catch (OMAuthenticationManagerException e) {
4657
// Nothing we can do to recover here.
4758
throw new RuntimeException(e);
59+
} catch (OMKeyManagerException e) {
60+
// Nothing we can do to recover here.
61+
throw new RuntimeException(e);
4862
}
4963
}
5064

@@ -195,6 +209,91 @@ public void authenticatePin(JSONArray args, CallbackContext callbackContext) {
195209
_sendSuccess(callbackContext);
196210
}
197211

212+
/**
213+
* Fetches the [key,value] data stored in keystore
214+
* @param args
215+
* @param callbackContext
216+
*/
217+
public void getPreference(JSONArray args, CallbackContext callbackContext) {
218+
String id = args.optString(0);
219+
String key = args.optString(1);
220+
221+
try {
222+
OMAuthenticator pinAuthenticator = _getAuthenticator(id, LocalAuthType.PIN);
223+
224+
if (pinAuthenticator == null)
225+
throw new IllegalStateException("No enabled authenticators.");
226+
227+
OMSecureStorageService securedService = new OMSecureStorageService(_context,
228+
pinAuthenticator.getKeyStore(),
229+
LocalAuthType.PIN.getInstanceId(id));
230+
Serializable result = securedService.get(key);
231+
if (result == null)
232+
throw new IllegalStateException("No key found in PIN secured store, check in default.");
233+
234+
_sendSuccess(callbackContext, result.toString());
235+
} catch (Throwable t) {
236+
Log.w(TAG, "Error fetching key.", t);
237+
try {
238+
Serializable result = _defaultSecuredStore.get(key);
239+
_sendSuccess(callbackContext, result == null ? null : result.toString());
240+
} catch (OMSecureStorageException e) {
241+
Log.e(TAG, "Error while fetching key from default storage.", e);
242+
IdmAuthenticationPlugin.invokeCallbackError(callbackContext, PluginErrorCodes.GETTING_VALUE_FROM_DEFAULT_STORAGE_FAILED);
243+
}
244+
IdmAuthenticationPlugin.invokeCallbackError(callbackContext, PluginErrorCodes.GETTING_VALUE_FROM_SECURED_STORAGE_FAILED);
245+
}
246+
}
247+
248+
/**
249+
* Sets the [key,value] data in keystore
250+
* @param args
251+
* @param callbackContext
252+
*/
253+
public void setPreference(JSONArray args, CallbackContext callbackContext) {
254+
String id = args.optString(0);
255+
String key = args.optString(1);
256+
String value = args.optString(2);
257+
boolean secure = args.optBoolean(3);
258+
if (!secure) {
259+
String errorToThrow = PluginErrorCodes.SAVING_VALUE_TO_DEFAULT_STORAGE_FAILED;
260+
try {
261+
if (value == null)
262+
_defaultSecuredStore.delete(key);
263+
else
264+
_defaultSecuredStore.store(key, value);
265+
266+
_sendSuccess(callbackContext);
267+
} catch (Throwable e) {
268+
Log.e(TAG, "Error while storing in default storage.", e);
269+
IdmAuthenticationPlugin.invokeCallbackError(callbackContext, errorToThrow);
270+
}
271+
}
272+
String errorToThrow = PluginErrorCodes.SAVING_VALUE_TO_SECURED_STORAGE_FAILED;
273+
OMAuthenticator pinAuthenticator = _getAuthenticator(id, LocalAuthType.PIN);
274+
275+
try {
276+
if (pinAuthenticator == null) {
277+
errorToThrow = PluginErrorCodes.NO_LOCAL_AUTHENTICATORS_ENABLED;
278+
throw new IllegalStateException("No enabled authenticators.");
279+
}
280+
281+
OMSecureStorageService securedService = new OMSecureStorageService(_context,
282+
pinAuthenticator.getKeyStore(),
283+
LocalAuthType.PIN.getInstanceId(id));
284+
285+
if (value == null)
286+
securedService.delete(key);
287+
else
288+
securedService.store(key, value);
289+
_sendSuccess(callbackContext);
290+
291+
} catch (Throwable e) {
292+
Log.e(TAG, "Error while storing in secured storage.", e);
293+
IdmAuthenticationPlugin.invokeCallbackError(callbackContext, errorToThrow);
294+
}
295+
}
296+
198297
/**
199298
* This method tries to clean up the fingerprint authenticator, after user
200299
* has remove his fingerprint enrollment on device.
@@ -493,6 +592,7 @@ private enum Availability { Enrolled, NotEnrolled, NotAvailable };
493592
private final Context _context;
494593
private final OMAuthenticationManager _sharedManager;
495594
private boolean _clearFingerprintInstancesAfterAuthentication;
595+
private final OMSecureStorageService _defaultSecuredStore;
496596

497597
// Localized strings for fingerprint prompt
498598
private static final String PROMPT_MESSAGE = "promptMessage";

src/android/src/oracle/idm/auth/plugin/util/PluginErrorCodes.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,8 @@ public interface PluginErrorCodes {
3232
String BIOMETRIC_NOT_ENABLED = "P1019";
3333
String CHANGE_PIN_WHEN_PIN_NOT_ENABLED = "P1020";
3434
String GET_ENABLED_AUTHS_ERROR = "P1021";
35+
String SAVING_VALUE_TO_SECURED_STORAGE_FAILED = "P1022";
36+
String SAVING_VALUE_TO_DEFAULT_STORAGE_FAILED = "P1023";
37+
String GETTING_VALUE_FROM_SECURED_STORAGE_FAILED = "P1024";
38+
String GETTING_VALUE_FROM_DEFAULT_STORAGE_FAILED = "P1025";
3539
}

0 commit comments

Comments
 (0)