Advertisement
Guest User

Untitled

a guest
Mar 15th, 2016
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.82 KB | None | 0 0
  1. <beans:beans xmlns="http://www.springframework.org/schema/security"
  2. xmlns:beans="http://www.springframework.org/schema/beans"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-4.0.xsd">
  5.  
  6.  
  7. <beans:bean id="serviceProperties" class="org.springframework.security.cas.ServiceProperties">
  8. <beans:property name="service" value="https://localhost:4444/welcome.html"/>
  9. <beans:property name="sendRenew" value="false"/>
  10. </beans:bean>
  11. <http entry-point-ref="casEntryPoint">
  12. <intercept-url pattern="/admin**" access="hasRole('ADMIN')"/>
  13. <custom-filter position="CAS_FILTER" ref="casFilter"/>
  14. </http>
  15.  
  16. <beans:bean id="casFilter" class="org.springframework.security.cas.web.CasAuthenticationFilter">
  17. <beans:property name="authenticationManager" ref="authenticationManager"/>
  18. </beans:bean>
  19.  
  20. <beans:bean id="casEntryPoint" class="org.springframework.security.cas.web.CasAuthenticationEntryPoint">
  21. <beans:property name="loginUrl" value="https://localhost:8443/login/cas"/>
  22. <beans:property name="serviceProperties" ref="serviceProperties"/>
  23. </beans:bean>
  24. <authentication-manager alias="authenticationManager">
  25. <authentication-provider ref="casAuthenticationProvider"/>
  26. </authentication-manager>
  27.  
  28. <beans:bean id="casAuthenticationProvider" class="org.springframework.security.cas.authentication.CasAuthenticationProvider">
  29. <beans:property name="userDetailsService" ref="userService"/>
  30. <beans:property name="authenticationUserDetailsService" ref="authenticationUserDetailsService"/>
  31. <beans:property name="serviceProperties" ref="serviceProperties"/>
  32. <beans:property name="ticketValidator">
  33. <beans:bean class="org.jasig.cas.client.validation.Cas20ServiceTicketValidator">
  34. <beans:constructor-arg index="0" value="https://localhost:9443/cas"/>
  35. </beans:bean>
  36. </beans:property>
  37. <beans:property name="key" value="an_id_for_this_auth_provider_only"/>
  38. </beans:bean>
  39.  
  40. <user-service id="userService">
  41. <user name="joe" password="joe" authorities="ROLE_USER"/>
  42. <user name="casuser" password="Mellon" authorities="ROLE_USER"/>
  43. </user-service>
  44.  
  45. <beans:bean id="authenticationUserDetailsService" class="org.springframework.security.cas.userdetails.GrantedAuthorityFromAssertionAttributesUserDetailsService">
  46. <beans:constructor-arg>
  47. <beans:array>
  48. <beans:value>uid</beans:value>
  49. <beans:value>id</beans:value>
  50. <beans:value>ROLE_</beans:value>
  51. </beans:array>
  52. </beans:constructor-arg>
  53. </beans:bean>
  54.  
  55.  
  56. </beans:beans>
  57.  
  58. <?xml version="1.0" encoding="UTF-8"?>
  59. <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
  60. xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
  61. version="3.0">
  62. <display-name>CrunchifySpringMVCTutorial</display-name>
  63. <welcome-file-list>
  64. <welcome-file>index.jsp</welcome-file>
  65. </welcome-file-list>
  66.  
  67. <servlet>
  68. <servlet-name>test</servlet-name>
  69. <servlet-class>
  70. org.springframework.web.servlet.DispatcherServlet
  71. </servlet-class>
  72. <load-on-startup>1</load-on-startup>
  73. </servlet>
  74. <servlet-mapping>
  75. <servlet-name>test</servlet-name>
  76. <url-pattern>/welcome.jsp</url-pattern>
  77. <url-pattern>/welcome.html</url-pattern>
  78. <url-pattern>*.html</url-pattern>
  79. </servlet-mapping>
  80.  
  81. <listener>
  82. <listener-class>org.springframework.web.context.ContextLoaderListener
  83. </listener-class>
  84. </listener>
  85.  
  86. <!-- Loads Spring Security config file -->
  87. <context-param>
  88. <param-name>contextConfigLocation</param-name>
  89. <param-value>
  90. /WEB-INF/spring-security.xml
  91. </param-value>
  92. </context-param>
  93.  
  94. <!-- Spring Security -->
  95. <filter>
  96. <filter-name>springSecurityFilterChain</filter-name>
  97. <filter-class>org.springframework.web.filter.DelegatingFilterProxy
  98. </filter-class>
  99. </filter>
  100.  
  101. <filter-mapping>
  102. <filter-name>springSecurityFilterChain</filter-name>
  103. <url-pattern>/*</url-pattern>
  104. </filter-mapping>
  105.  
  106. @Controller
  107. public class SimpleController {
  108.  
  109. @RequestMapping("/welcome")
  110. public ModelAndView helloWorld(HttpServletRequest request) {
  111. Principal activeUser = request.getUserPrincipal();
  112. Object currentClerk = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
  113. String message = "<br><div style='text-align:center;'>"
  114. + "<h3>********** Hello World, Spring MVC Tutorial</h3> **********</div><br><br>";
  115. return new ModelAndView("welcome", "message", message);
  116. }
  117.  
  118. @RequestMapping("/admin")
  119. public ModelAndView admin() {
  120. String message = "<br><div style='text-align:center;'>"
  121. + "<h3>********** Hello World, Spring MVC Tutorial</h3> **********</div><br><br>";
  122. return new ModelAndView("welcome", "message", message);
  123. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement