What I did was to make the changes from https://jira.jboss.org/jira/browse/JBAS-7037 into application server source code. After that I rebuilt the server and used the new jar files. Also you should know that there is new option that will make security contexts to work like in JBoss 4.x
Add this line to run.conf.bat
set "JAVA_OPTS=%JAVA_OPTS% -Dorg.jboss.security.context.ThreadLocal=true"
In case you are working in a multi user environment this will guaranteee that your code is executed in the proper security context when you have mutiple active threads.