[jboss-user] [EJB3] - Re: Konfiguratio of security domains in JBoss AS 6 with EJB 3.1

Süleyman Vurucu do-not-reply at jboss.com
Mon Nov 8 04:56:29 EST 2010


Süleyman Vurucu [http://community.jboss.org/people/suikast42] created the discussion

"Re: Konfiguratio of security domains in JBoss AS 6 with EJB 3.1"

To view the discussion, visit: http://community.jboss.org/message/570014#570014

--------------------------------------------------------------
Thanks jaikiran,
that was the solution. That's a little bit wiggy that there are so many annotations that called @SecurityDomain.

So I can do the authentification with the following  snippet. For stateless and statefull beans works this wonderfull. But for a singleton beans I get an Exception:
Exception in thread "main" java.lang.IllegalStateException: Local Call: Security Context is null
 




private <T> T getInterface( String pServerAddr, String pServerPort, String pAppName, Class<T> pClazz, String pServiceName, InterfaceType pType ) {
        String lookup = null;

        try {
            if (pJndiContext == null) {

                Properties p = new Properties();
                p.put( Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory" );
                p.put( Context.PROVIDER_URL, "jnp://" + pServerAddr + ":" + pServerPort );
                p.put( Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces" );
                p.put( "java.security.auth.login.config", "auth.conf" );

                for (Iterator<Object> key = p.keySet().iterator(); key.hasNext();) {
                    Object tmpKey = key.next();
                    System.getProperties().put( tmpKey, p.get( tmpKey ) );
                }

                SecurityAssociationHandler lSHandler = new SecurityAssociationHandler();
                SimplePrincipal pUser = new SimplePrincipal( "admin" );
                lSHandler.setSecurityInfo( pUser, "admin".toCharArray() );
                LoginContext login = new LoginContext( "ClientCtx", (CallbackHandler) lSHandler );
                login.login();

                pJndiContext = new InitialContext();
            }
            lookup = pAppName + "/" + pServiceName + "/" + pType.getEncName();
            return (T) pJndiContext.lookup( lookup );
        } catch (NamingException e) {
            e.printStackTrace();
            System.out.println( "[DEBUG]" + lookup + " for " + pClazz.getSimpleName() );
            printAllJndiNames();
            return null;
        } 
        catch (LoginException e) {
            e.printStackTrace();
            return null;
        }
    }
--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/570014#570014]

Start a new discussion in EJB3 at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2029]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20101108/2e898cfb/attachment-0001.html 


More information about the jboss-user mailing list