AuthRequestHandler(EjbDaemon daemon) {
}
public void processRequest(ObjectInputStream in, ObjectOutputStream out) {
AuthenticationRequest req = new AuthenticationRequest();
AuthenticationResponse res = new AuthenticationResponse();
try {
req.readExternal(in);
String securityRealm = req.getRealm();
String username = req.getUsername();
String password = req.getCredentials();
SecurityService securityService = SystemInstance.get().getComponent(SecurityService.class);
Object token = securityService.login(securityRealm, username, password);
ClientMetaData client = new ClientMetaData();
client.setClientIdentity(token);
res.setIdentity(client);
res.setResponseCode(ResponseCodes.AUTH_GRANTED);
} catch (Throwable t) {
res.setResponseCode(ResponseCodes.AUTH_DENIED);
res.setDeniedCause(t);
} finally {
if (logger.isDebugEnabled()){
try {
logger.debug("AUTH REQUEST: "+req+" -- RESPONSE: " + res);
} catch (Exception justInCase) {}
}
try {
res.writeExternal(out);
} catch (java.io.IOException ie) {
logger.fatal("Couldn't write AuthenticationResponse to output stream", ie);
}
}
}