Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
396 ashish 1
package in.shop2020.serving.controllers;
2
 
3
import org.apache.struts2.rest.DefaultHttpHeaders;
4
import org.apache.struts2.rest.HttpHeaders;
5
import org.apache.thrift.TException;
6
 
7
import in.shop2020.model.v1.user.AuthenticationException;
8
import in.shop2020.model.v1.user.UserContextService.Client;
9
import in.shop2020.thrift.clients.UserContextServiceClient;
10
import in.shop2020.thrift.clients.UserProfileClient;
11
 
12
import com.opensymphony.xwork2.ModelDriven;
13
 
14
public class AuthController implements ModelDriven<Object>{
15
 
16
	private Auth auth = new Auth();
17
 
18
	private UserContextServiceClient client = null;
19
 
20
	private int errorCode = 0;
21
	private String errorMessage;
22
 
398 ashish 23
	private String id;
24
 
396 ashish 25
	public AuthController(){
26
		try {
408 ashish 27
		//	client = new UserContextServiceClient();
396 ashish 28
		} catch (Exception e) {
29
			e.printStackTrace();
30
		}
31
	}
32
 
33
	@Override
34
	public Object getModel() {
399 rajveer 35
		return this.auth;
396 ashish 36
	}
37
 
38
	public HttpHeaders create(){
398 ashish 39
		System.out.println(auth);
40
		return new DefaultHttpHeaders("lsuccess");
396 ashish 41
		//AUTH service to be invoked from here
399 rajveer 42
		/*
396 ashish 43
		Client c = client.getClient();
44
		try {
398 ashish 45
 
396 ashish 46
			if (c.authenticateUser(auth.getUserName(), auth.getPassword(), true)){
47
				return new DefaultHttpHeaders("lsuccess");
48
			}
49
		} catch (AuthenticationException e) {
50
 
51
			errorCode = e.getErrorCode();
52
			errorMessage = e.getMessage();
53
 
54
		} catch (TException e) {
55
			// TODO Auto-generated catch block
56
			errorCode = -1;
57
			e.printStackTrace();
58
		}
59
		return new DefaultHttpHeaders("lfail");
399 rajveer 60
		*/
396 ashish 61
	}
62
 
63
	public int getErrorCode() {
64
		return errorCode;
65
	}
66
 
67
	public String getErrorMessage() {
68
		return errorMessage;
69
	}
398 ashish 70
 
71
	public String getId(){
72
		return id;
73
	}
74
 
399 rajveer 75
	public void setId(String id){
398 ashish 76
		this.id = id;
77
	}
401 ashish 78
 
79
	public Auth getAuth() {
80
		return auth;
81
	}
82
 
83
	public void setAuth(Auth auth) {
84
		this.auth = auth;
85
	}
396 ashish 86
}