summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src/main/java/org/openslx/dozmod/authentication/TestAccountAuthenticator.java
blob: bc08dc395eea08dfc13fd21427cd6a955fbb01f6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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);
		}
	}
}