blob: 0c83ad0b67d0e8dd4e1ffdb57b9fda1ebca4ea7d (
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
package org.openslx.dozmod.authentication;
import org.apache.log4j.Logger;
import org.apache.thrift.TException;
import org.openslx.bwlp.thrift.iface.SessionData;
import org.openslx.bwlp.thrift.iface.TAuthenticationException;
import org.openslx.bwlp.thrift.iface.UserInfo;
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 = Logger.getLogger(TestAccountAuthenticator.class);
@Override
public void login(String username, String password, AuthenticatorCallback callback)
throws TAuthenticationException {
SessionData authResult = null;
// try to login user
try {
authResult = ThriftManager.getMasterClient().authenticate(username, password);
} catch (TException e) {
LOGGER.error("Thrift communication error: ", e);
// TODO authenticate has to return a TAuthenticationException!
callback.postLogin(ReturnCode.GENERIC_ERROR, null, e);
return;
}
// handle answer from server
if (authResult != null && authResult.authToken != null) {
// TODO: Session.fromClientSessionData(authResult);
UserInfo userInfo = null;
try {
userInfo = ThriftManager.getMasterClient().getUserFromToken(authResult.authToken);
} catch (TException e) {
LOGGER.error("Thrift communication error: ", e);
// TODO authenticate has to return a TAuthenticationException!
callback.postLogin(ReturnCode.GENERIC_ERROR, null, e);
return;
}
callback.postLogin(ReturnCode.NO_ERROR, userInfo, null);
} else {
// it should then show a corresponding error message!
callback.postLogin(ReturnCode.GENERIC_ERROR, null, null);
}
}
}
|