summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src/main/java/org/openslx/dozmod/authentication/Authenticator.java
blob: c654ed8b7cd6f8be9c0ae9a323fae645eb061661 (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
package org.openslx.dozmod.authentication;

import java.util.List;

import org.openslx.bwlp.thrift.iface.Satellite;
import org.openslx.dozmod.authentication.ShibbolethEcp.ReturnCode;

/**
 * @author Jonathan Bauer
 * 
 */
public interface Authenticator {

	/**
	 * Callback interface to the login to be called after a login
	 * Note that this will be called after every login, independent
	 * of the success of the operation. This way the GUI can show a
	 * corresponding message to the user.
	 */
	interface AuthenticatorCallback {
		void postLogin(ReturnCode returnCode, AuthenticationData data, Throwable t);
	}

	public class AuthenticationData {
		public final String satelliteToken;
		public final String masterToken;
		public final List<Satellite> satellites;

		public AuthenticationData(String satToken, String masterToken, List<Satellite> sats) {
			this.satelliteToken = satToken;
			this.masterToken = masterToken;
			this.satellites = sats;
		}
	}

	/**
	 * Definition of the generic login method.
	 * 
	 * @param username The username as String
	 * @param password The password as String
	 * @param callback The callback function to be called after the login
	 * @throws Exception
	 */
	void login(String username, String password, AuthenticatorCallback callback) throws Exception;
	
	/**
	 * Cancel any running login attempt.
	 */
	void cancel();
}