Announcement Announcement Module
Collapse
No announcement yet.
My app carry me to the path "j_spring_security_check" and I don't know the reason Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • My app carry me to the path "j_spring_security_check" and I don't know the reason

    Hi,
    I'm using spring-security for my app but I have a problem when user try access to my app and he is not authenticate correctly. If user doesn't introduce well the data or he lets it in white, that is, he doesn't introduce any value then the app shows a message of error and it goes to the specified path in file spring-security and if user back introduces the wrong data or he lets without fill in a field then app goes to path "j_spring_security_check" and I don't know the reason
    The code:
    LogginController.java
    Code:
    ...
    @RequestMapping(value = "/err/errLogin", method = RequestMethod.GET)
    	public String processErrLoggin(ModelMap model){
    		
    		logger.info("processErrLoggin --> Ha entrado en el mtodo GET y vamos a insertar en el modelo que se ha producido un error");
    		
    		Usuario usuario = new Usuario();
    		
    		model.addAttribute("usuario", usuario);
    		model.addAttribute("error", "true");
    		
    		logger.info("processErrLoggin --> Despu�s de insertar el error en el modelMap");
    		
    		return "index";
    	}
    	
    	@RequestMapping(value = "/err/errLogin", method = RequestMethod.POST)
    	public String processErrLogginPost(ModelMap model){
    		
    		logger.info("processErrLoggin --> Ha entrado en el m�todo POST y vamos a insertar en el modelo que se ha producido un error");
    		
    		Usuario usuario = new Usuario();
    		
    		model.addAttribute("usuario", usuario);
    		model.addAttribute("error", "true");
    		
    		logger.info("processErrLoggin --> Despu�s de insertar el error en el modelMap");
    		
    		return "index";
    	}
    	
    	
    	@RequestMapping(value = "/err/j_spring_security_check", method = RequestMethod.GET)
    	public String procesarErrorLogin(ModelMap model){
    		
    		Usuario usuario = new Usuario();
    		
    		model.addAttribute("usuario", usuario);
    		model.addAttribute("error", "true");
    		
    		logger.info("processErrLoggin --> Despu�s de insertar el error en el modelMap");
    		
    		return "index";
    	}
    	
    	@RequestMapping(value = "/err/j_spring_security_check", method = RequestMethod.POST)
    	public String processErrLogginErr(@ModelAttribute("usuario") Usuario usuario, ModelMap model){
    		
    		logger.info("processErrLogginErr --> Ha entrado en el m�todo POST y vamos a insertar en el modelo que se ha producido un error");
    		
    		//Usuario usuario = new Usuario();
    		
    		/*model.addAttribute("usuario", usuario);
    		model.addAttribute("error", "true");*/
    		
    		logger.info("processErrLogginErr --> Despu�s de insertar el error en el modelMap");
    		
    		return "redirect:/principal/usuarios/form.htm";
    	}
    ...
    .jsp file
    Code:
    ...
    <body>
    	<div id="general">
    		<div id="cabecera">
    			<!--<img alt="logo" src="${pageContext.request.contextPath}/resources/images/logo.png">-->
    			<div id="marcador">
    				<form name="f" action="j_spring_security_check" method="post" >
    					<!--<c:if test="${not empty param.authfailed}">
    					    <span id="infomessage" >
    					    Login fallido debido a: <c:out value="${SPRING_SECURITY_LAST_EXCEPTION.message}"/>.
    					    </span>
    					</c:if>-->
    					<!--<div id="login-error">${error}</div>-->
    				    <table border="0" cellpadding="2" cellspacing="3">
    				        <tbody>
    				        	<tr>
    				        		<c:if test="${not empty error}">
    									<div id="errorblock">
    										${sessionScope["SPRING_SECURITY_LAST_EXCEPTION"].message}
    									</div>
    								</c:if>
    				        	</tr>
    				            <tr>
    				                <!--td><span id="letra">Usuario</span></td>-->
    				                <td><input type="text" name="j_username" id="fondo-gris" placeholder="Usuario"/></td>
    							</tr>
    				            <tr>
    				                <!--<td><span id="letra">Password</span></td>-->
    				                <td><input type="password" name="j_password" id="fondo-gris" placeholder="Password"/></td>
    				            </tr>
    				            <tr>   
    								<td colspan="3"><center><input id="botonInciar" type="submit" name="guardar" value="Iniciar Sesi�n"/></center></td>
    				                <!--<td><a href="<c:url value="/principal/usuarios/form.htm"/>">nuevo usuario</a></td>-->
    				            </tr>
    				        </tbody>
    				    </table>
    ...
    spring-security file (.xml)
    Code:
    ...
    <!-- A�ado la seguridad al formulario para que solamente los usuarios registrados sean los que puedan navegar -->
    	<security:http auto-config="true" use-expressions="true">
    		<security:intercept-url pattern="/index" access="permitAll"/>
    		<security:intercept-url method="POST" pattern="/index" access="hasRole('ROLE_ANONYMOUS')" />
    		<security:intercept-url pattern="/*" access="hasAnyRole('ROLE_USER','ROLE_ADMIN')"/>
    		<security:form-login login-page="/index"
    							 default-target-url="/principal/usuarios/form"
            					 always-use-default-target="true"
    							 authentication-failure-url="/err/errLogin"/>
    		
    	</security:http>
    ...
    I have had that I put in the "controller" file a path "j_spring_security_check" for that my app doesn't throw me an exception, but I don't find explication so that

    Thanks.
Working...
X