cas3 自定义页面

在使用cas3的时候,每每有这样的需求,但愿每一个应用有个独立的登陆页面javascript

这块cas 官方文档有一些说明php

https://wiki.jasig.org/display/CAS/Using+CAS+without+the+Login+Screencss


首先从官方的角度,不建议使用多个登陆页面,这样对安全会造成短板。可是html

用户需求之上,若是咱们要实现,有下面几种方式java

1.经过参数来判断css来改变布局甚至一些图片,典型cas里面的default-view中web

casLoginView.jsp 里面就有这样的描述,经过描述能够看出他经过不一样css来区分安全

weblogin和mobilelogin。app

好比片断jsp

<c:ifide

test="${not empty requestScope['isMobile'] and not empty mobileCss}">

<meta name="viewport"

content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" />

<meta name="apple-mobile-web-app-capable" content="yes" />

<meta name="apple-mobile-web-app-status-bar-style" content="black" />

<!--<link type="text/css" rel="stylesheet" media="screen" href="<c:url value="/css/fss-framework-1.1.2.css" />" />

            <link type="text/css" rel="stylesheet" href="<c:url value="/css/fss-mobile-${requestScope['browserType']}-layout.css" />" />

            <link type="text/css" rel="stylesheet" href="${mobileCss}" />-->

</c:if>


2.cas服务端(或者各类应用中)创建一个独立的form页面

参考:https://wiki.jasig.org/display/CAS/Using+CAS+from+external+link+or+custom+external+form

好比:

在cas(或者各类的应用页面) web-inf/ 页面添加testlogin.html

代码:

<html>

<head />

<body>

   <form method="GET" action="http://192.168.2.109:8080/cas/login">

       <p>Username : <input type="text" name="username" /></p>

       <p>Password : <input type="password" name="password" /></p>

       <p>Remember me : <input type="checkbox" name="rememberMe" value="true" /></p>

       <p><input type="submit" value="Login !" /></p>

       <input type="hidden" name="auto" value="true" />

       <input type="hidden" name="service" value="http://localhost/user/checklogintocas.php" />

   </form>

</body>

</html>


casLoginView.jsp

实现自动提交功能:

...

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

<%

String auto = request.getParameter("auto");

if (auto != null && auto.equals("true")) {

%>

<html>

   <head>

       <script language="javascript">

           function doAutoLogin() {

               document.forms[0].submit();

           }

       </script>

   </head>

   <body onload="doAutoLogin();">

       <form id="credentials" method="POST" action="<%= request.getContextPath() %>/login?service=<%= request.getParameter("service") %>">

           <input type="hidden" name="lt" value="${loginTicket}" />

           <input type="hidden" name="execution" value="${flowExecutionKey}" />

           <input type="hidden" name="_eventId" value="submit" />

           <input type="hidden" name="username" value="<%= request.getParameter("username") %>" />

           <input type="hidden" name="password" value="<%= request.getParameter("password") %>" />

           <% if ("true".equals(request.getParameter("rememberMe"))) {%>

               <input type="hidden" name="rememberMe" value="true" />

           <% } %>


           <input type="submit" value="Submit" style="visibility: hidden;" />

       </form>

   </body>

</html>

<%

} else {

%>

<jsp:directive.include file="includes/top.jsp" />

...

<jsp:directive.include file="includes/bottom.jsp" />

<%

}

%>




3.第三种方法 实际上是第二种方法的启发,直接把用if-else 把多个页面组合在一块儿,经过参数来判断显示。(最好能能够支持多套casLoginView.jsp 不过研究下来好像比较难,也许cas开发者也是为了怕再次开放的人用太多灵活的多套casLoginView.jsp 页面跳来跳去把项目搞混吧。)

相关文章
相关标签/搜索