Programmatically Modify Credential In Worklight Adapter
I looking for a way to programmatically set the credential of an HTTP adapter? Is somebody has an example? Is it possible to modify the adapter implementation js to overwrite the c
Solution 1:
Firstly, you should use "Authorization" and not "Authentication" as described here: http://en.wikipedia.org/wiki/Basic_access_authentication
In addition, you should do the following:
Create a Java class, something like this (you'll need to clean and adjust it of course):
publicclassIdan {
publicStringbasicHash(String user, String password) {
BASE64Encoder base64Encoder = newBASE64Encoder();
String authorization = user + ":" + password;
return base64Encoder.encode(authorization.getBytes());
}
// to test:publicstaticvoidmain(String[] args) {
Idan i = newIdan();
System.out.println(i.basicHash("idan", "somepassword"));
}
}
In the adapter's .js file, declare globally:
var idan = new org.Idan();
And the procedure:
functiontest(){
WL.Logger.debug(idan.basicHash("username_test", "secret_password"));
}
Post a Comment for "Programmatically Modify Credential In Worklight Adapter"