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;
}
}