3 Replies Latest reply on Jan 3, 2018 3:53 AM by Martin Choma

    Set Security Credentials for @Singleton @Startup

    Paul Carroll Newbie



      I am using Wildfly 11.0.0 with Java 9.0.1 on Windows platform.  I am also using the Elytron security module.


      I have multiple @Singleton @Startup classes that call secure EJB's.  I am trying to avoid using the @RunAsPrincipal annotation to set the security context for the class because the user may be different for each deployment.


      I was able to accomplish this using the following code in JBoss 5.1.0.


      private void setupCredentials()
        String username = "secureUser";
        String password = "secureUserPassword";
        SecurityAssociation.setPrincipal( new SimplePrincipal( username ) );
        SecurityAssociation.setCredential( password.toCharArray() );


      Is there a way to do this in Wildfly 11 using Elytron security?