<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

<%@ page import="com.ubintis.agt5.api.ApiAgentService" %>
<%@ page import="com.ubintis.agt5.common.util.JsonUtil" %>
<%@ page import="com.ubintis.agt5.common.util.StrUtil" %>

<%@ page import="java.util.HashMap" %>

<%
	String errorCode = "";
	String sso_code = "";

	String pni_token = StrUtil.NVL( session.getAttribute( "pni_token" ) );
	
	if( !"".equals( pni_token ) ) {
		String user_ip = request.getRemoteAddr();
		String user_agent = request.getHeader( "User-Agent" );
		
		ApiAgentService apiAgentService = new ApiAgentService();
		sso_code = apiAgentService.getSsoCode( pni_token, user_ip, user_agent );
		
		if( sso_code == null || "".equals( sso_code ) ) {
			errorCode = apiAgentService.getErrorCode();
		}
		
	} else {
		errorCode = "E001";
	}
	
	HashMap<String, String> rtnMap = new HashMap<String, String>();
	rtnMap.put( "errorCode", errorCode );
	rtnMap.put( "sso_code", sso_code );
	
	out.println( JsonUtil.toString( rtnMap ) );
%>