public class AdfmfJavaUtilities
extends Object
Modifier and Type | Field and Description |
---|---|
static String |
AES128
Database password prefix to denote AES128 database encryption should be used.
|
static String |
AES256
Database password prefix to denote AES256 database encryption should be used.
|
static int |
ApplicationDirectory
Constant to be used to determine which directory path to obtain.
|
static int |
DatabaseAES128Encryption
Constant returned by encryptDatabase(..) to denote what encryption algorithm
will be used for the database.
|
static int |
DatabaseAES256Encryption
Constant returned by encryptDatabase(..) to denote what encryption algorithm
will be used for the database.
|
static int |
DatabaseDefaultEncryption
Default database encryption algorithm
|
static int |
DatabaseNoEncryption
Constant returned by encryptDatabase(..) to denote what encryption algorithm
will be used for the database.
|
static int |
DatabaseRC4Encryption
Constant returned by encryptDatabase(..) to denote what encryption algorithm
will be used for the database.
|
static int |
DeviceOnlyDirectory
Constant to be used to determine which directory path to obtain.
|
static int |
DownloadDirectory
Constant to be used to determine which directory path to obtain.
|
static String |
RC4
Database password prefix to denote RC4 database encryption should be used.
|
static int |
TemporaryDirectory
Constant to be used to determine which directory path to obtain.
|
Constructor and Description |
---|
AdfmfJavaUtilities() |
Modifier and Type | Method and Description |
---|---|
static int |
addDataControlProviders(String dcName,
String providerKey,
String keyAttribute,
Object providers,
boolean moreDataAvailable)
Adds Objects as new data providers (i.e.
|
static int |
addDataControlProviders(String dcName,
String providerKey,
String keyAttribute,
Object providers,
boolean moreDataAvailable,
boolean isWrappedResponse)
Overload for
(String dcName, String providerKey, String keyAttribute, Object providers, boolean moreDataAvailable)
which adds a param to indicate the providers object is or is not a wrapped
web service response object. |
static void |
addWhiteListEntries(String fid,
String[] entries)
Add additional white list entries for the feature.
|
static void |
addWhiteListEntry(String fid,
String entry)
Add additional white list entry for the feature.
|
static void |
addWhiteListEntry(String fid,
String entry,
boolean updateApplicationInfo)
Add additional white list entry for the feature.
|
static void |
clearPasswordCredential(String adfCredentialStoreKey,
String username)
Clear a password credential for the key from the credential store
|
static void |
clearSecurityConfigOverrides(String key)
Clear the security configuration overrides associated with the given key.
|
static void |
decryptDatabase(java.sql.Connection db)
Permanently decrypt a previously-encrypted database
|
static int |
encryptDatabase(java.sql.Connection db,
String newPassword)
Encrypt the database with the specified password.
|
static Object |
evaluateELExpression(String elExpression)
Evaluates the expression and returns the resulting value.
|
static void |
flushDataChangeEvent()
Flush any pending data change events
NOTE: Can only be called from a background thread.
|
static String |
getActiveContextId()
Get the active EL context name.
|
static AdfELContext |
getAdfELContext()
Get the ADF EL context.
|
static DataControl |
getDataControlById(String dcName)
Returns the DataControl instance for the specified data control name.
|
static Object |
getDataControlProvider(String dcName)
Used to to get the root provider instance from a DataControl.
|
static String |
getDirectoryPathRoot(int typeOfPath)
Gets the path to certain writable directory on the device
|
static Object |
getELValue(String elExpression)
Gets a property resolved by an EL Expression to a value
|
static oracle.adfmf.framework.FeatureContext |
getFeatureContext()
Get current FeatureContext instance.
|
static String |
getFeatureId()
Get current feature id.
|
static String |
getFeatureName()
Get current feature name.
|
static MethodExpression |
getMethodExpression(String expression,
Class expectedReturnType,
Class[] expectedParamTypes)
Use this method for expressions that refer to methods.
|
static ValueExpression |
getValueExpression(String expression,
Class expectedType)
Use this method for expressions that refer to values.
|
static void |
invokeACS(String key,
String optionalExtraPayload,
boolean refreshApplicationState)
Invokes ACS programmatically and updates feature context
|
static Object |
invokeDataControlMethod(String dcName,
String instanceName,
String methodName,
java.util.List parameterNames,
java.util.List parameters,
java.util.List parameterTypes)
Invoke a DC operation.
|
static boolean |
isBackgroundThread()
Use it to test if the current thread is a background thread or not.
|
static boolean |
isEvaluationExpression(String elExpression)
Checks if the passed in expression string is an evaluation expression.
|
static boolean |
isPrimaryRequestThread()
Use it to test if the current thread is a primary thread or not.
|
static void |
loadXliffResourceBundle(String baseName,
String varNameUsed)
Used to load the resource bundle and store it as a map in the request
scope.
|
static void |
logout()
Logout the current authentication server
|
static void |
logoutFeature(String key)
Logout the authentication server associated with key
|
static void |
overrideConnectionProperty(String connectionId,
String node,
String property,
Object value)
Overrides a connection reference property value with a new value.
|
static void |
purgeSyncCache()
Deletes all sync cached resources when Synchronizer is enabled.
|
static void |
setELValue(String elExpression,
Object value)
Sets a property resolved by an EL Expression to a value
|
static void |
updateApplicationInformation(boolean gotoDefaultFeature)
Update the current application information based off the current environment
and feature definitions.
|
static String |
updateSecurityConfigWithURLParameters(String configUrlParam,
String key,
String message,
boolean showConfirmation)
Update security configuration from URL parameters
|
public static final int TemporaryDirectory
public static final int ApplicationDirectory
public static final int DeviceOnlyDirectory
public static final int DownloadDirectory
public static final int DatabaseNoEncryption
public static final int DatabaseAES128Encryption
public static final int DatabaseAES256Encryption
public static final int DatabaseRC4Encryption
public static final int DatabaseDefaultEncryption
public static final String AES128
public static final String AES256
public static final String RC4
public static void addWhiteListEntry(String fid, String entry)
fid
- Feature identry
- White list entrypublic static void addWhiteListEntry(String fid, String entry, boolean updateApplicationInfo)
fid
- Feature identry
- White list entryupdateApplicationInfo
- If set to true, calls updateApplicationInfo.public static void addWhiteListEntries(String fid, String[] entries)
fid
- Feature identries
- An array of white list entriespublic static String getDirectoryPathRoot(int typeOfPath)
typeOfPath
- the type of pathTemporaryDirectory
ApplicationDirectory
DeviceOnlyDirectory
DownloadDirectory
TemporaryDirectory
,
ApplicationDirectory
,
DeviceOnlyDirectory
,
DownloadDirectory
public static oracle.adfmf.framework.FeatureContext getFeatureContext()
public static String getFeatureId() throws AdfException
AdfException
public static String getFeatureName() throws AdfException
AdfException
public static AdfELContext getAdfELContext()
public static String getActiveContextId()
public static ValueExpression getValueExpression(String expression, Class expectedType)
expression
- The expression to parseexpectedType
- The type the result of the expression will be coerced to after
evaluation.ELException
- Thrown if there are syntactical errors in the provided
expression.NullPointerException
- if paramTypes is null.getAdfELContext()
,
evaluateELExpression(String)
,
setELValue(String, Object)
public static MethodExpression getMethodExpression(String expression, Class expectedReturnType, Class[] expectedParamTypes)
expression
- The expression to parseexpectedReturnType
- The expected return type for the method to be found. After
evaluating the expression, the MethodExpression must check that
the return type of the actual method matches this type. Passing in
a value of null indicates the caller does not care what the return
type is, and the check is disabled.expectedParamTypes
- The expected parameter types for the method to be found. Must be
an array with no elements if there are no parameters expected. It
is illegal to pass null, unless the method is specified with
arguments in the EL expression.ELException
- Thrown if there are syntactical errors in the provided
expression.NullPointerException
- if paramTypes is null.getAdfELContext()
public static Object evaluateELExpression(String elExpression) throws AdfException
elExpression
- The expression to be evaluated.NullPointerException
- if context is null.PropertyNotFoundException
- if one of the property resolutions failed because a specified
variable or property does not exist or is not readable.ELException
- if an exception was thrown while performing property or variable
resolution. The thrown exception must be included as the cause
property of this exception, if available.AdfException
getAdfELContext()
,
getValueExpression(String, Class)
,
setELValue(String, Object)
public static void setELValue(String elExpression, Object value)
elExpression
- The expression that resolves to the property on which to set the
value.value
- The value to set the resolved expression to.NullPointerException
- if context is null.PropertyNotFoundException
- if one of the property resolutions failed because a specified
variable or property does not exist or is not readable.ELException
- if an exception was thrown while performing property or variable
resolution. The thrown exception must be included as the cause
property of this exception, if available.getAdfELContext()
,
evaluateELExpression(String)
,
getValueExpression(String, Class)
public static Object getELValue(String elExpression)
elExpression
- The expression that resolves to the property on which to get the
value.NullPointerException
- if context is null.PropertyNotFoundException
- if one of the property resolutions failed because a specified
variable or property does not exist or is not readable.ELException
- if an exception was thrown while performing property or variable
resolution. The thrown exception must be included as the cause
property of this exception, if available.getAdfELContext()
,
evaluateELExpression(String)
,
getValueExpression(String, Class)
public static boolean isEvaluationExpression(String elExpression)
elExpression
- public static void flushDataChangeEvent()
public static Object invokeDataControlMethod(String dcName, String instanceName, String methodName, java.util.List parameterNames, java.util.List parameters, java.util.List parameterTypes) throws AdfInvocationException
Examples of usage:
public void changePlayerName(ActionEvent evt) { // call a method that takes an int as a parameter List pnames = new ArrayList(); List params = new ArrayList(); List ptypes = new ArrayList(); pnames.add("name"); ptypes.add(String.class); params.add("Bill"); pnames.add("index"); ptypes.add(int.class); // the class must be the primitive version for // reflection to find the proper method params.add(new Integer(0)); // the value must be the object version here, // reflection will auto unbox the value when // passing try { AdfmfJavaUtilities.invokeDataControlMethod("TeamBean", null, "changePlayerName", pnames, params, ptypes); } catch (AdfInvocationException ex) { // If the web service is not available throw a nice exception if (AdfInvocationException.CATEGORY_WEBSERVICE.compareTo(ex.getErrorCategory()) == 0) { throw new RuntimeException("Error with the server. Please try later."); } } } public void addNewPlayerAsObject(ActionEvent evt) { // call a method that takes a bean instance PlayerBean player = new PlayerBean(); // Application Bean List pnames = new ArrayList(); List params = new ArrayList(); List ptypes = new ArrayList(); player.setName("Morris"); player.setNumber("53"); player.setPosition("RD"); pnames.add("player"); ptypes.add(PlayerBean.class); params.add(player); try { AdfmfJavaUtilities.invokeDataControlMethod("TeamBean", null, "addPlayer", pnames, params, ptypes); } catch (AdfInvocationException ex) { // If the web service is not available throw a nice exception if (AdfInvocationException.CATEGORY_WEBSERVICE.compareTo(ex.getErrorCategory()) == 0) { throw new RuntimeException("Error with the server. Please try later."); } } } public void addNewPlayerAsGT(ActionEvent evt) { // call a method that takes a GenericType representation of a bean as a // parameter // use the GenericType serialization helper class to convert PlayerBean player = new PlayerBean(); // Application Bean GenericType gt = null; GenericType result = null; List pnames = new ArrayList(); List params = new ArrayList(); List ptypes = new ArrayList(); player.setName("Morris"); player.setNumber("53"); player.setPosition("RD"); gt = GenericTypeBeanSerializationHelper.toGenericType("test.mobile.PlayerBean", player); pnames.add("player"); ptypes.add(gt.getClass()); params.add(gt); try { result = (GenericType) AdfmfJavaUtilities.invokeDataControlMethod("TeamBean", null, "addPlayerAsGT", pnames, params, ptypes); Object provider = AdfmfJavaUtilities.getDataControlprovider("TeamBean"); GenericTypeBeanSerializationHelper.fromGenericType(provider, result); } catch (AdfInvocationException ex) { // If the web service is not available throw a nice exception if (AdfInvocationException.CATEGORY_WEBSERVICE.compareTo(ex.getErrorCategory()) == 0) { throw new RuntimeException("Error with the server. Please try later."); } } }
dcName
- The name of the DataControl on which the method (or the nested
object that declares the method) is declared.instanceName
- The name of the nested object on the DataControl that declares the
method (can be null if the method is on the root DC).methodName
- The name of the method to invoke.parameterNames
- The names of any named parameters. Required, elements must be of
type java.lang.String.parameters
- The parameter values. Elements can be of any type.parameterTypes
- The parameter types. Elements must be of type java.lang.Class. Can
be null if the data control implementation does not require
parameter types for invocation.AdfInvocationException
- on invocation errorspublic static int addDataControlProviders(String dcName, String providerKey, String keyAttribute, Object providers, boolean moreDataAvailable)
An example implementation of rangeChange shows how this method s used -
public void rangeChange(RangeChangeEvent rangeChangeEvent) { if (rangeChangeEvent.isDataExhausted()) { List parameterNames = new ArrayList(); List parameters = new ArrayList(); List parameterTypes = new ArrayList(); // populate params... // invoke the method that gets new data Object result = AdfmfJavaUtilities.invokeDataControlMethod("MyWebServiceDC", null, "fetchMoreRowsOfSomeType", parameterNames, parameters, parameterTypes); boolean moreDataAvailable = // whatever the server uses to determine if more // data is available // add the new data to the DataControl AdfmfJavaUtilities.addDataControlProviders("MyWebServiceDC", rangeChangeEvent.getProviderKey(), rangeChangeEvent.getKeyAttribute(), result, moreDataAvailable); } }
dcName
- The name of the DataControlproviderKey
- The name the framework uses to locate the DataControl node on
which to add the providers, which is a dot delimited string of
accessor names, starting at the root DC (i.e.
"root.products.categories"). This is passed in the
RangeChangeEvent object in a rangeChange event.keyAttribute
- The name of the provider attribute that acts as the key, if one is
defined. Can be null. This is passed in the RangeChangeEvent
object in a rangeChange event.providers
- The actual providers to add. This can be a List or an array of
provider Objects, or a GenericType that contains a list of
providers (typical form of a web service response).moreDataAvailable
- flag to determine if more data is available from the service
provider that has not already been loaded in to the data control
hierarchy. The framework will use this value to determine whether
or not to render links to load more rows on the view components
associated with the indicated datacontrol. This should be set to
false if the caller can determine there is no more available data
to load from the service provider, otherwise should be set to trueRangeChangeListener
,
RangeChangeEvent
,
invokeDataControlMethod(String, String, String, List, List, List)
public static int addDataControlProviders(String dcName, String providerKey, String keyAttribute, Object providers, boolean moreDataAvailable, boolean isWrappedResponse)
(String dcName, String providerKey, String keyAttribute, Object providers, boolean moreDataAvailable)
which adds a param to indicate the providers object is or is not a wrapped
web service response object.dcName
- The name of the DataControlproviderKey
- The name the framework uses to locate the DataControl node on
which to add the providers, which is a dot delimited string of
accessor names, starting at the root DC (i.e.
"root.products.categories"). This is passed in the
RangeChangeEvent object in a rangeChange event.keyAttribute
- The name of the provider attribute that acts as the key, if one is
defined. Can be null. This is passed in the RangeChangeEvent
object in a rangeChange event.providers
- The actual providers to add. This can be a List or an array of
provider Objects, or a GenericType that contains a list of
providers (typical form of a web service response).moreDataAvailable
- flag to determine if more data is available from the service
provider that has not already been loaded in to the data control
hierarchy. The framework will use this value to determine whether
or not to render links to load more rows on the view components
associated with the indicated datacontrol. This should be set to
false if the caller can determine there is no more available data
to load from the service provider, otherwise should be set to trueisWrappedResponse
- defaults to true. If the response is not a List or an array, this
indicates to the framework that the providers Object is a wrapped
response. Can be set to false if the caller wishes to pass a
single GenericType that does not have a 'result' attribute which
defines the actual collection of data.RangeChangeListener
,
RangeChangeEvent
,
invokeDataControlMethod(String, String, String, List, List, List)
public static void clearPasswordCredential(String adfCredentialStoreKey, String username) throws AdfException
adfCredentialStoreKey
- attribute associated with the login server reference that appears
in the connections.xml file.username
- who's credentials will be removed.AdfException
public static void logoutFeature(String key) throws AdfException
key
- Credential store keyAdfException
public static void logout() throws AdfException
AdfException
public static void clearSecurityConfigOverrides(String key) throws AdfException
Use this API to clear and remove any persisted connection configuration overrides that have been previously set using either overrideConnectionProperty or updateSecurityConfigWithURLParameters. This also clears the connections previously loaded from connections.xml and automatically persisted by framework. It is recommended to call this API in the application lifecycle listener's start method after the new connections.xml is installed. Since the connection overrides are persisted and take precedence over connections.xml it is important to clear the security config overrides prior to use.
key
- adfCredentialStoreKey string attribute of the configuration
to delete.AdfException
public static String updateSecurityConfigWithURLParameters(String configUrlParam, String key, String message, boolean showConfirmation) throws AdfException
NOTE:
Do not call this API from within feature lifecycle listener.
Use application life cycle listener instead.
configUrlParam
- URL encoded configuration parameter string. The string before
encoding should have format below:
<scheme>://[host][:port]/?<parameter1>::=<value1> ;&< parameter2>::=<value2>&...&<parameterN>::=< ;valueN>
Note that the query string has to be of format shown below (parameter and
value shall be separated using string "::="). All URL parameters
have to be URL encoded using UTF8 Encoding. If URLs are not
encoded, query parameters will not be parsed correctly.
Property Name | Valid Values | Mandatory/Optional |
---|---|---|
AuthServerType | FederatedAuthentication HTTPBasicAuthentication OAMMSAuthentication | Mandatory |
ApplicationName | Mandatory | |
LoginURL | Mandatory (valid for Fed & HTTP Basic Auth only) | |
LogoutURL | Mandatory (valid for Fed & HTTP Basic Auth only) | |
LoginSuccessURL | Mandatory (valid for Fed Auth only) | |
LoginFailureURL | Mandatory (valid for Fed Auth only) | |
BrowserMode | Embedded | Optional (valid for Fed Auth only) |
OfflineAuthAllowed | true/false | Optional (valid for HTTP Basic & OAMMS Auth only) |
AuthKey | Any valid string using which credentials will be stored | Optional |
CryptoScheme | PlainText SHA-1 SHA-224 SHA-256 SHA-384 SHA-512 SaltedSHA-1 SaltedSHA-224 SaltedSHA-256 SaltedSHA-384 SaltedSHA-512 AES | Optional (valid for HTTP Basic & OAMMS Auth only) This crypto scheme will be used for encrypting/hashing credentials |
SessionTimeOutValue | value in seconds | Optional (valid for HTTP Basic & OAMMS Auth only) |
IdleTimeOutValue | value in seconds | Optional (valid for HTTP Basic only) |
RequiredTokens | <Comma separated list of tokens> | Optional (valid for Fed & HTTP Basic Auth only) |
OAMMSURL | Mandatory for OAMMS authentication only | |
OAMMSServiceDomain | Mandatory for OAMMS authentication only |
key
- adfCredentialStoreKey string attribute of the configuration. This
key should be used in all reference to the configuration, such as
subsequent updates, feature credential key, etc..message
- Additional message to be shown in the confirmation dialog box.showConfirmation
- A boolean flag that defines the confirmation behavior of the API.
If set true, a confirmation dialog box is shown and user is asked
to accept the configuration change if the configuration for the
key already exists in the system. If set false, the new
configuration will update the existing configuration for the key
unconditionally.AdfException
public static boolean isPrimaryRequestThread()
public static boolean isBackgroundThread()
public static int encryptDatabase(java.sql.Connection db, String newPassword)
NOTE:
For customers who would like to enforce a specific database encryption
algorithm, they should programmatically prepend the proper database
encryption prefix to the database driver's encrypt and getConnection calls.
i.e.
public String getDatabaseEncryptedAlgorithmPassword(String userPassword) { return (AdfmfJavaUtilities.AES256 + ":" + userPassword); } ... public void setDatabasePassword(String userPassword) { AdfmfJavaUtilties.encrypteDatabase(getDatabaseEncryptedAlgorithmPassword(userPassword)); } ... public Connection openApplicationDatabaseConnection(String dataSource, String userPassword) { return new SQLite.JDBCDataSource(dataSource).getConnection(null, getDatabaseEncryptedAlgorithmPassword(userPassword)); }
db
- A previously-opened database connection. If the database is
already encrypted, it must also have been opened with the correct
password.newPassword
- New password to use when encrypting the database. A particular
encryption algorithm may be selected by prefixing one of:
'aes128:', 'aes256:', or 'rc4:' to the password. Note that the
entire password, including prefix, must subsequently be specified
when opening this now-encrypted database. The default encryption
mode AES128 is used when no prefix (or an invalid one) is
specified. If no password is specified, the database is
permanently decrypted, i.e. no password will be required to
subsequently open the database.DatabaseNoEncryption
,
DatabaseAES128Encryption
,
DatabaseAES256Encryption
,
DatabaseRC4Encryption
,
DatabaseDefaultEncryption
,
decryptDatabase(Connection)
public static void decryptDatabase(java.sql.Connection db)
db
- A previously-opened database connection. If the database is
already encrypted, it must also have been opened with the correct
password.encryptDatabase(Connection, String)
public static void loadXliffResourceBundle(String baseName, String varNameUsed) throws AdfException
baseName
- Base name where the bundle is present (relative to the project)
eg. If ViewControllerBundle.xlf is located in
varNameUsed
- Name by which the we will refer this bundle. eg.
viewcontrollerBundleAdfException
public static DataControl getDataControlById(String dcName) throws AdfException
dcName
- The name of the DataControlAdfException
- Thrown if cannot not find DataControl by name in the Binding
Context.public static Object getDataControlProvider(String dcName) throws AdfException
dcName
- The name of the DataControlAdfException
- Thrown if cannot not find DataControl by name in the Binding Context.invokeDataControlMethod(String, String, String, List, List, List)
public static void overrideConnectionProperty(String connectionId, String node, String property, Object value)
Examples of usage:
Suppose connections.xml defines the following connection: <Reference name="rest_server" className="oracle.adf.model.connection.url.HttpURLConnection" credentialStoreKey="rest_server" xmlns="" adfCredentialStoreKey="login_server"> <Factory className="oracle.adf.model.connection.url.URLConnectionFactory"/> <RefAddresses> <XmlRefAddr addrType="rest_server"> <Contents> <urlconnection name="rest_server" url="http://slc03gce.us.oracle.com:7101"> <authentication style="challange"> <type>basic</type> <realm>jazn.com</realm> </authentication> </urlconnection> </Contents> </XmlRefAddr> <SecureRefAddr addrType="username"/> <SecureRefAddr addrType="password"/> </RefAddresses> </Reference> Execute: AdfmfJavaUtilities.overrideConnectionProperty( "rest_server", // name of the connection reference "urlconnection", // node name "url", // attribute name "https://slc05zpo.us.oracle.com:7001" // new value ); The resulting connection endpoint URL defined in connections.xml ("http://slc03gce.us.oracle.com:7101) will be overridden with "https://slc05zpo.us.oracle.com:7001".
connectionId
- The name of the connection reference to be updated.node
- name for the node of the overridden property.property
- name for the overridden property.value
- value for the overridden property.updateSecurityConfigWithURLParameters(String, String, String, boolean)
public static void updateApplicationInformation(boolean gotoDefaultFeature)
gotoDefaultFeature
- set to true if container should go to default featurepublic static void invokeACS(String key, String optionalExtraPayload, boolean refreshApplicationState)
key
- Credential store keyoptionalExtraPayload
- Not used (for future use)refreshApplicationState
- When true, re-evaluate access rights (roles and privileges)public static void purgeSyncCache()