<%@page import="com.dreammirae.gt.radius.client.GptwrAuthService"%>
<%

	String serverIp = "192.168.1.2";   
	String port = "1812";
	String sharedSecret = "1AABAC6D068EEF6A7BAD3FDF50A05CC8";
	String timeout = "3";
	String success = "";
	
	String result = null; //応答文字列
	String rCode = ""; //応答コード
	int authFailCnt = 0; //連続認証失敗件数
	String rMsg = ""; //応答メッセージ
	String info = null;

	//OTP認証要請
   	result = GptwrAuthService.auth(serverIp, port, sharedSecret, request.getParameter("name"), request.getParameter("password"), timeout);

	//処理結果は、"応答コード#連続認証失敗件数#応答メッセージ" 形式でリターン
	String[] tmp = result.split("#");  

	//処理結果のParsing
	if ( tmp.length >= 3)
	{
		rCode = tmp[0];  
		authFailCnt = Integer.parseInt(tmp[1]);
		rMsg  = tmp[2];
	}

	if ( "0".equals(rCode) ){
		success = "success";
	}else{
		success = "failed";
	}
	info = GptwrAuthService.info();
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Mirae-Tech Grippin Tower login test(JSP)</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>

<body>
<!-- top navigation start -->
<!-- top navigation end -->
<!-- body start -->
<div id="body">
		<!-- top shadow start -->
		<div id="topShadow"></div>
		<!-- top shadow end -->
		<!-- body pannel start -->
		<div id="bodyPannel">
			<!-- login form start-->
			<form method="get" action="index.jsp" name="login" class="search">
			   <h2>OTP Login Test <span>(jsp)</span></h2>
			   <span>
                return code=<%=rCode%> <font color='red'>(<%=success%>)</font><br>
				authFailCnt=<%=authFailCnt%><br>
                message=<%=rMsg%><br>
				<font color='steelblue'><%=info%></font>
               </span>
				<br>
				<input name="login" type="submit" id="back" value="back" title="back" class="submit" />
			</form>
			<p>
			  <!-- login form end-->
			  <br class="spacer" />
		    </p>
			<p>&nbsp;</p>
			<p>&nbsp;</p>
			<p>&nbsp;</p>
			<p>&nbsp;</p>
			<p>&nbsp;</p>
        </div>
		<!-- body pannel end -->
		<!-- top shadow start -->		
		<div id="bottomShadow"></div>
		<div id="bottomShadowCopy">Copyright MiraeTechnology.Co.Ltd. </div>
		<br class="spacer" />
		<!-- bottom shadow end -->
	</div>
	<!-- body end -->
	<!-- footer start -->
<!-- footer end -->	
</body>
</html>
