package org.openslx.dozmod.authentication; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.thrift.TException; import org.openslx.bwlp.thrift.iface.ClientSessionData; import org.openslx.bwlp.thrift.iface.TAuthorizationException; import org.openslx.dozmod.authentication.ShibbolethEcp.ReturnCode; import org.openslx.thrifthelper.ThriftManager; /** * @author Jonathan Bauer * */ public class TestAccountAuthenticator implements Authenticator { /** * Logger instance for this class */ private final static Logger LOGGER = LogManager.getLogger(TestAccountAuthenticator.class); @Override public void login(String username, String password, AuthenticatorCallback callback) throws TAuthorizationException, TException { ClientSessionData authResult = null; authResult = ThriftManager.getMasterClient().localAccountLogin(username, password); // handle answer from server if (authResult != null && authResult.authToken != null) { LOGGER.info(authResult); AuthenticationData data = new AuthenticationData(authResult.authToken, authResult.sessionId, authResult.satellites); callback.postLogin(ReturnCode.NO_ERROR, data, null); } else { // it should then show a corresponding error message! callback.postLogin(ReturnCode.GENERIC_ERROR, null, null); } } }