<%@ Page Language="C#"%>
<%@ Import Namespace = "System.Runtime.InteropServices" %>

<script runat=server>
[DllImport("GptwrAuthService.dll",   CharSet = CharSet.Ansi)]
	public static extern IntPtr auth(string ip, string port, string secret, string id, string pwd, string timeout);
[DllImport("GptwrAuthService.dll",   CharSet = CharSet.Ansi)]
	public static extern IntPtr info();


string userName ="";		// ユーザID
string pwd = "";		// OTP値
string serverIp = "192.168.1.2";		// 認証サーバ（中継サーバ）のIPアドレス
string serverPort = "1812";				// Radiusポート番号
string secret = "1AABAC6D068EEF6A7BAD3FDF50A05CC8";		// 共有秘密鍵 
string timeout = "3";					// タイムアウト（秒）
string result = "";
string sdkinfo = "";

string rCode = "";
string authFailCnt = "";
string rMsg = "";
string success = "";
		

public void Page_Load(Object s, EventArgs e)
{
	
	userName = Request.Form["name"];		// ユーザID
	pwd = Request.Form["password"];		// OTP値

	// 認証要請
	result = Marshal.PtrToStringAnsi( auth(serverIp, serverPort, secret, userName, pwd, timeout) );  
	sdkinfo = Marshal.PtrToStringAnsi(info());

	// 認証結果
	//Response.Write(result + "<br>");
	//Response.Write(sdkinfo);
	//txtResult.Text = result ;
	string[] tmp = result.Split('#');
	if (tmp.Length >= 3){
		rCode = tmp[0];
		authFailCnt = tmp[1];
		rMsg = tmp[2];		
	}

	if (rCode=="0"){
		success = "success";
	}else{
		success = "failed";
	}
}
</script>


<!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(ASP.NET)</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>


<body onload=>
	<!-- 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.aspx" name="login" class="search">
			   <h2>OTP Login Test <span>(ASP.NET)</span></h2>
			   <span>
                return code=<%=rCode%> <font color=red>(<%=success%>)</font><br>
				authFailCnt=<%=authFailCnt%><br>
                message=<%=rMsg%><br>
				<font color='steelblue'><%=sdkinfo%></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>
