Page 1 of 1

loginUserFromVault with JavaScript

Posted: Wed Nov 29, 2017 9:28 pm
by dan7777777
Has anybody been able to achieve this?
I would like to use this for a doAsUser method, but I'm not able to get the subject object. Whenever I try to use the method, I get this error on my browser console:
Failed to load resource: the server responded with a status of 500 (Internal Server Error)

This is my code:

Code: Select all

var subject = securityService.loginUserFromVault("vaultKey", "test");
var JavaPackage = new JavaImporter(java.security.PrivilegedAction);
with(JavaPackage){securityService.doAsUser(subject , new PrivilegedAction(){
            run: function() {
                 try{
                    securityService.addContextRoleToUser(userId, role, contextId);
                 }catch(e){
                 }
                }
             });
}


Any information would be amazing!

Re: loginUserFromVault with JavaScript

Posted: Thu Nov 30, 2017 2:17 pm
by dan7777777
Edit:
After adding try-catch blocks I get a more specific error:
java.lang.ArrayIndexOutOfBoundsException

Why would this be occurring?