summaryrefslogblamecommitdiffstats
path: root/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/Session.java
blob: 33612746284a3e13abbc3f30a67695bb5e7905df (plain) (tree)
1
2
3
4
                                  

                                                       
                                                                 










































                                                                                                                  
package org.openslx.dozmod.thrift;

import org.openslx.bwlp.thrift.iface.ClientSessionData;
import org.openslx.dozmod.authentication.ServiceProviderResponse;

public class Session {
	
	private static String firstName = null;
	
	private static String lastName = null;
	
	private static String eMail = null;
	
	private static String userId = null;
	
	private static String satelliteToken = null;
	
	private static String masterToken = null;
	
	public static void fromClientSessionData(ClientSessionData session) {
		if (userId != null && !userId.equals(session.userInfo.userId))
			throw new IllegalArgumentException("Cannot set new session data with different user id!");
		firstName = session.userInfo.firstName;
		lastName = session.userInfo.lastName;
		eMail = session.userInfo.eMail;
		userId = session.userInfo.userId;
		masterToken = session.sessionId;
		satelliteToken = session.authToken;
	}
	
	public static void fromEcpLogin(ServiceProviderResponse response) {
		// TODO
		//if (userId != null && !userId.equals(response.userId))
		//	throw new IllegalArgumentException("Cannot set new session data with different user id!");
		firstName = response.firstName;
		lastName = response.lastName;
		eMail = response.mail;
		//userId = response.userId; TODO
		masterToken = response.token;
		satelliteToken = response.sessionId;
	}
	
	public static String getSatelliteToken() {
		return satelliteToken;
	}

}