瀏覽代碼

Fixed up contacts sample: removed casfailed page, corrected debug.jsp errors and fixed incorrect bean reference in context files.

Luke Taylor 17 年之前
父節點
當前提交
78065ba47c

+ 1 - 1
samples/contacts/src/main/webapp/WEB-INF/applicationContext-security.xml

@@ -47,7 +47,7 @@
        <b:property name="targetUrl" value="/secure/index.htm"/>
     </b:bean>
 
-    <b:bean id="expressionhandler" class="org.springframework.security.expression.support.DefaultSecurityExpressionHandler">
+    <b:bean id="expressionHandler" class="org.springframework.security.expression.support.DefaultSecurityExpressionHandler">
         <b:property name="permissionEvaluator" ref="permissionEvaluator" />
     </b:bean>
 

+ 0 - 17
samples/contacts/src/main/webapp/casfailed.jsp

@@ -1,17 +0,0 @@
-<%@ page import="org.springframework.security.AuthenticationException" %>
-
-<html>
-  <head>
-    <title>Login to CAS failed!</title>
-  </head>
-
-  <body>
-    <h1>Login to CAS failed!</h1>
-
-      <font color="red">
-        Your CAS credentials were rejected.<BR><BR>
-        Reason: <%= ((AuthenticationException) session.getAttribute(org.springframework.security.ui.AbstractProcessingFilter.SPRING_SECURITY_LAST_EXCEPTION_KEY)).getMessage() %>
-      </font>
-
-  </body>
-</html>

+ 30 - 18
samples/contacts/src/main/webapp/secure/debug.jsp

@@ -1,28 +1,40 @@
 <%@ page import="org.springframework.security.context.SecurityContextHolder" %>
 <%@ page import="org.springframework.security.Authentication" %>
 <%@ page import="org.springframework.security.GrantedAuthority" %>
-<%@ page import="org.springframework.security.adapters.AuthByAdapter" %>
 
-<%
-		Authentication auth = SecurityContextHolder.getContext().getAuthentication();
-		if (auth != null) { %>
-			Authentication object is of type: <%= auth.getClass().getName() %><BR><BR>
-			Authentication object as a String: <%= auth.toString() %><BR><BR>
+<html>
+<head>
+<title>Security Debug Information</title>
+</head>
+<body>
 
-			Authentication object holds the following granted authorities:<BR><BR>
-<%			GrantedAuthority[] granted = auth.getAuthorities();
-			for (int i = 0; i < granted.length; i++) { %>
-				<%= granted[i].toString() %> (getAuthority(): <%= granted[i].getAuthority() %>)<BR>
-<%			}
+<h3>Security Debug Information</h3>
 
-			if (auth instanceof AuthByAdapter) { %>
-				<BR><B>SUCCESS! Your container adapter appears to be properly configured!</B><BR><BR>
-<%			} else { %>
-				<BR><B>SUCCESS! Your web filters appear to be properly configured!</B><BR>
+<%
+        Authentication auth = SecurityContextHolder.getContext().getAuthentication();
+        if (auth != null) { %>
+<p>
+            Authentication object is of type: <em><%= auth.getClass().getName() %></em>
+</p>
+<p>
+            Authentication object as a String: <br/><br/><%= auth.toString() %>
+</p>
+
+            Authentication object holds the following granted authorities:<br /><br />
+<%
+            for (GrantedAuthority authority : auth.getAuthorities()) { %>
+                <%= authority %> (<em>getAuthority()</em>: <%= authority.getAuthority() %>)<br />
 <%			}
+%>
 
-		} else { %>
-			Authentication object is null.<BR>
-			This is an error and your Acegi Security application will not operate properly until corrected.<BR><BR>
+                <p><b>Success! Your web filters appear to be properly configured!</b></p>
+<%
+        } else {
+%>
+            Authentication object is null.<br />
+            This is an error and your Spring Security application will not operate properly until corrected.<br /><br />
 <%		}
 %>
+
+</body>
+</html>

+ 2 - 2
samples/contacts/src/test/resources/applicationContext-contacts-test.xml

@@ -14,7 +14,7 @@
                         http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.5.xsd">
 
     <global-method-security expression-annotations="enabled">
-        <expression-handler ref="expressionhandler"/>
+        <expression-handler ref="expressionHandler"/>
     </global-method-security>
 
    <!-- ======================== AUTHENTICATION ======================= -->
@@ -24,7 +24,7 @@
         <jdbc-user-service data-source-ref="dataSource"/>
     </authentication-provider>
 
-    <b:bean id="expressionhandler" class="org.springframework.security.expression.support.DefaultSecurityExpressionHandler">
+    <b:bean id="expressionHandler" class="org.springframework.security.expression.support.DefaultSecurityExpressionHandler">
         <b:property name="permissionEvaluator" ref="permissionEvaluator" />
     </b:bean>