Ich habe einige Ohren auf JBoss AS7 mit
jboss-app.xml
bereitgestellt
FooDomain
In standalone.xml habe ich
...
Ich kann einen EJB vom Standalone-Client nachschlagen und die Authentifizierung ist erfolgreich, wenn ich Code wie diesen verwende:
final Hashtable p = new Hashtable();
p.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
p.put(Context.SECURITY_PRINCIPAL, username);
p.put(Context.SECURITY_CREDENTIALS, password);
p.put("jboss.naming.client.ejb.context", true);
p.put(Context.PROVIDER_URL, "remote://10.10.1.18:4447");
p.put("jboss.naming.client.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT", "false");
p.put(Context.INITIAL_CONTEXT_FACTORY, org.jboss.naming.remote.client.InitialContextFactory.class.getName());
context = new InitialContext(p);
Das Problem ist, dass ich in der Debug-Konsole
sehe, wenn ich falsche Anmeldeinformationen eingebejavax.security.sasl.SaslException: Authentication failed: all available authentication mechanisms failed
aber ich kann es nicht fangen.
Serverprotokolle (nicht wichtige Teile herausgeschnitten):
TRACE [DatabaseServerLoginModule] initialize
TRACE [DatabaseServerLoginModule] Security domain: FooDomain
TRACE [DatabaseServerLoginModule] DatabaseServerLoginModule, dsJndiName=java:/MyDS
TRACE [DatabaseServerLoginModule] principalsQuery=select password from users where user_id=?
TRACE [DatabaseServerLoginModule] rolesQuery=select role, 'Roles' from roles where user_id=?
TRACE [DatabaseServerLoginModule] suspendResume=true
TRACE [DatabaseServerLoginModule] login
TRACE [DatabaseServerLoginModule] suspendAnyTransaction
TRACE [DatabaseServerLoginModule] Excuting query: select password from users where user_id=?, with username: test
TRACE [DatabaseServerLoginModule] Obtained user password
TRACE [DatabaseServerLoginModule] resumeAnyTransaction
DEBUG [DatabaseServerLoginModule] Bad password for username=test
TRACE [DatabaseServerLoginModule] abort
Wenn ich versuche, LoginContext zu verwenden, passiert einfach nichts auf dem Server.
Konfiguration
public class DefaultJassConfiguration extends Configuration {
@Override
public AppConfigurationEntry[] getAppConfigurationEntry(String name) {
Map options = new HashMap();
options.put("debug", true);
AppConfigurationEntry[] entries = {
new AppConfigurationEntry("org.jboss.security.ClientLoginModule", AppConfigurationEntry.LoginModuleControlFlag.REQUIRED, options)
};
return entries;
}
}
Test
Configuration.setConfiguration(new DefaultJassConfiguration());
try {
LoginContext lc = new LoginContext("FooDomain", new UsernamePasswordHandler("test", "test".toCharArray()));
lc.login();
System.out.println(lc.getSubject());
} catch (LoginException e) {
e.printStackTrace();
}
Vielleicht kennt LoginContext die Serveradresse nicht? Ich versuche,
hinzuzufügenSystem.setProperty("java.naming.provider.url", "remote://10.10.1.18:4447");
aber ohne Wirkung.
Wie funktioniert LoginContext? Oder wie fängt man SaslException ab?
Ich überlege, ein Dummy-Bean zu erstellen, dessen Methode immer „true“ zurückgibt, und es nach der Anmeldung aufzurufen, aber es sieht hässlich aus.
P.S. Es tut mir leid für mein Englisch (es macht mich ein bisschen schüchtern)
JBoss AS 7 Remote-Standalone-Client-Authentifizierung ⇐ Java
-
- Similar Topics
- Replies
- Views
- Last post