Advertisement
Guest User

Untitled

a guest
Jul 11th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.12 KB | None | 0 0
  1. <?xml version="1.0"?>
  2.  
  3. <web-app xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/j2ee" version="2.4" id="WebApp_ID">
  4. <display-name>Spring MVC</display-name>
  5.  
  6. <welcome-file-list>
  7. <welcome-file>/WEB-INF/pages/hello.jsp</welcome-file>
  8. </welcome-file-list>
  9. <servlet>
  10. <servlet-name>mvc-dispatcher</servlet-name>
  11. <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  12. <load-on-startup>1</load-on-startup>
  13. </servlet>
  14. <servlet-mapping>
  15. <servlet-name>mvc-dispatcher</servlet-name>
  16. <url-pattern>/</url-pattern>
  17. </servlet-mapping>
  18.  
  19. <listener>
  20. <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  21. </listener>
  22. <context-param>
  23. <param-name>contextConfigLocation</param-name>
  24. <param-value>
  25. /WEB-INF/mvc-dispatcher-servlet.xml,
  26. /WEB-INF/spring-security.xml
  27. </param-value>
  28. </context-param>
  29. <filter>
  30. <filter-name>springSecurityFilterChain</filter-name>
  31. <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
  32. </filter>
  33. <filter-mapping>
  34. <filter-name>springSecurityFilterChain</filter-name>
  35. <url-pattern>/*</url-pattern>
  36. </filter-mapping>
  37. </web-app>
  38.  
  39. <beans:beans xmlns="http://www.springframework.org/schema/security"
  40. xmlns:beans="http://www.springframework.org/schema/beans"
  41. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  42. xsi:schemaLocation="http://www.springframework.org/schema/beans
  43. http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
  44. http://www.springframework.org/schema/security
  45. http://www.springframework.org/schema/security/spring-security-3.2.xsd">
  46. <http auto-config="true">
  47. <intercept-url pattern="/welcome*" access="ROLE_USER" />
  48. <http-basic />
  49. </http>
  50.  
  51. <authentication-manager>
  52. <authentication-provider>
  53. <user-service>
  54. <user name="rahul" password="123" authorities="ROLE_USER" />
  55. </user-service>
  56. </authentication-provider>
  57. </authentication-manager>
  58. </beans:beans>
  59.  
  60. <?xml version="1.0"?>
  61. <beans xsi:schemaLocation=" http://www.springframework.org/schema/beans
  62. http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
  63. http://www.springframework.org/schema/context
  64. http://www.springframework.org/schema/context/spring-context-3.0.xsd"
  65. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  66. xmlns:context="http://www.springframework.org/schema/context"
  67. xmlns="http://www.springframework.org/schema/beans">
  68. <context:component-scan base-package="test"/>
  69. <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
  70. <property name="prefix">
  71. <value>/WEB-INF/pages/</value>
  72. </property>
  73. <property name="suffix">
  74. <value>.jsp</value>
  75. </property>
  76. </bean>
  77.  
  78. <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
  79. <property name="basenames">
  80. <list>
  81. <value>mymessages</value>
  82. </list>
  83. </property>
  84. </bean>
  85. </beans>
  86.  
  87. <%@ taglib prefix="c" uri="/WEB-INF/tld/c.tld"%>
  88. <html>
  89. <head>
  90. <title>Login Page</title>
  91. <style>
  92. .errorblock {
  93. color: #ff0000;
  94. background-color: #ffEEEE;
  95. border: 3px solid #ff0000;
  96. padding: 8px;
  97. margin: 16px;
  98. }
  99. </style>
  100. </head>
  101. <body onload='document.f.j_username.focus();'>
  102. <h3>Login with Username and Password (Custom Page)</h3>
  103.  
  104. <c:if test="${SPRING_SECURITY_LAST_EXCEPTION !=null}"><!-- ${not empty error} -->
  105. <div class="errorblock">
  106. Your login attempt was not successful, try again.<br /> Caused :
  107. ${sessionScope["SPRING_SECURITY_LAST_EXCEPTION"].message}
  108. </div>
  109. </c:if>
  110.  
  111. <form name='f' action="<c:url value='j_spring_security_check' />"
  112. method='POST'>
  113.  
  114. <table>
  115. <tr>
  116. <td>User:</td>
  117. <td><input type='text' name='j_username' value=''>
  118. </td>
  119. </tr>
  120. <tr>
  121. <td>Password:</td>
  122. <td><input type='password' name='j_password' />
  123. </td>
  124. </tr>
  125. <tr>
  126. <td colspan='2'><input name="submit" type="submit"
  127. value="submit" />
  128. </td>
  129. </tr>
  130. <tr>
  131. <td colspan='2'><input name="reset" type="reset" />
  132. </td>
  133. </tr>
  134. </table>
  135. </form>
  136. </body>
  137. </html>
  138.  
  139. <%@ taglib prefix="c" uri="/WEB-INF/tld/c.tld" %>
  140. <html>
  141. <body>
  142. <h3>message : ${message}</h3>
  143. <h3>User name : ${username}</h3>
  144. <a href = "<c:url value="/j_spring_security_logout" />">LogOut</a>
  145. </body>
  146. </html>
  147.  
  148. <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
  149. pageEncoding="ISO-8859-1"%>
  150. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  151. <html>
  152. <head>
  153. <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  154. <title>Insert title here</title>
  155. </head>
  156. <body>
  157. <h3>Welcome to spring security</h3>
  158. <a href="/SpringSecurity1-FORM/welcome"><b>Click here to logon</b></a>
  159. </body>
  160. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement