Skip to content

Commit

Permalink
la fonctionnalité de connexion
Browse files Browse the repository at this point in the history
  • Loading branch information
abirbenzaamia committed Jan 15, 2022
1 parent 43dbc89 commit 8eb66c3
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 0 deletions.
Binary file modified .gradle/7.1/executionHistory/executionHistory.bin
Binary file not shown.
Binary file modified .gradle/7.1/executionHistory/executionHistory.lock
Binary file not shown.
13 changes: 13 additions & 0 deletions WebContent/WEB-INF/jsps/denied.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
Access denied.

</body>
</html>
42 changes: 42 additions & 0 deletions WebContent/WEB-INF/jsps/login.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">


<html>
<head>
<title>Login Page</title>


</head>
<body onload='document.f.j_username.focus();'>
<h3>Login with Username and Password</h3>

<c:if test="${param.error != null}">

<p class="error">Login failed. Check that your username and password are correct.</p>

</c:if>


<form name='f' action='${pageContext.request.contextPath}/j_spring_security_check' method='POST'>
<table class="formtable">
<tr>
<td>User:</td>
<td><input type='text' name='j_username' value=''></td>
</tr>
<tr>
<td>Password:</td>
<td><input type='password' name='j_password' /></td>
</tr>
<tr>
<td colspan='2'><input name="submit" type="submit"
value="Login" /></td>
</tr>
</table>
</form>

</body>
</html>

55 changes: 55 additions & 0 deletions src/main/java/com/telly/config/security-context.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:security="http://www.springframework.org/schema/security"
xsi:schemaLocation="http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

<security:authentication-manager>
<security:authentication-provider>
<security:jdbc-user-service
data-source-ref="dataSource"
authorities-by-username-query='select username, authority from users where binary username = ?'
users-by-username-query='select username, password, enabled from users where binary username = ?'
id="jdbcUserService" />
<security:password-encoder ref="passwordEncoder"></security:password-encoder>
</security:authentication-provider>
</security:authentication-manager>


<security:http use-expressions="true">
<security:intercept-url pattern="/testcreate"
access="isAuthenticated()" />
<security:intercept-url pattern="/reservebook"
access="isAuthenticated()" />
<security:intercept-url pattern="/getreservations"
access="isAuthenticated()" />
<security:intercept-url pattern="/" access="permitAll" />
<security:intercept-url pattern="/reservebus"
access="permitAll" />

<security:intercept-url pattern="/createaccount"
access="permitAll" />
<security:intercept-url pattern="/results"
access="permitAll" />
<security:intercept-url pattern="/reservetrip"
access="permitAll" />
<security:intercept-url pattern="/home" access="permitAll" />
<security:intercept-url pattern="/login"
access="permitAll" />
<security:form-login login-page="/login"
authentication-failure-url="/login?error=true" />
<security:logout logout-success-url="/loggedout" />
<security:access-denied-handler
error-page="/denied" />
</security:http>

<security:global-method-security
secured-annotations="enabled"></security:global-method-security>

<bean id="passwordEncoder"
class="org.springframework.security.crypto.password.StandardPasswordEncoder">
</bean>



</beans>
12 changes: 12 additions & 0 deletions src/main/java/com/telly/controllers/UserController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.telly.controllers;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class UserController {
@RequestMapping("/login")
public String showLogin() {
return "login";
}
}

0 comments on commit 8eb66c3

Please sign in to comment.