jboss6.x - JBoss EAP 6.x - PolicyContext.getContext remains null -


i'm using jboss eap 6.4 enterprise app , i'm little stuck when attempt retrieve active subject.

of course, user need authenticate, goes through following code snippet

logincontext logincontext = new logincontext("contextname", callbackhandler); logincontext.login(); return logincontext.getsubject(); 

that works fine (and subject filled in), problem lies when try retrieve subject @ later point in execution ...

final subject subject = (subject)policycontext.getcontext("javax.security.auth.subject.container");

... subject remains null!

what missing??

any appreciated.

solved!

thanks following article on how introduce security manager on jboss eap 6.4.

the problem security manager had configured in jboss. need open standalone.conf (or standalone.conf.bat), uncomment , add following:

rem # uncomment run security manager enabled set "secmgr=true"  rem # using == when setting -djava.security.policy specifies security manager  rem # use specified policy file. using = specifies security  rem # manager use specified policy combined policy set in policy.url  rem # section of java_home/lib/security/java.security. set "java_opts=%java_opts% -djava.security.policy==%jboss_home%\bin\server.policy" 

that enable security manager , make point custom server.policy, have sample of below:

grant {   permission java.security.allpermission; }; 

that give permissions modules operate. of course, you'll need edit policy file if want tighten security.

retrieving subject easy:

subject.getsubject(accesscontroller.getcontext()); 

that's it! hope it'll work guys well.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -