jboss-app.xml
bereitgestellt
Code: Select all
FooDomain
In standalone.xml habe ich
Code: Select all
...
Code: Select all
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);
sehe, wenn ich falsche Anmeldeinformationen eingebe
Code: Select all
javax.security.sasl.SaslException: Authentication failed: all available authentication mechanisms failed
Serverprotokolle (nicht wichtige Teile herausgeschnitten):
Code: Select all
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
Konfiguration
Code: Select all
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;
}
}
Code: Select all
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();
}
hinzuzufügen
Code: Select all
System.setProperty("java.naming.provider.url", "remote://10.10.1.18:4447");
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)
Mobile version