07/09/2010, 07:30
|
| | Fecha de Ingreso: junio-2006
Mensajes: 10
Antigüedad: 18 años, 6 meses Puntos: 0 | |
Respuesta: request.getRemoteUserN() devuelve nulo en inscripcionController
public ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response,
Object command, BindException errors)
throws Exception {
if (log.isDebugEnabled()) {
log.debug("entering 'onSubmit' method...");
}
Inscripciones inscripcion = (Inscripciones) command;
Locale locale = request.getLocale();
inscripcion.setIp(request.getRemoteAddr());
inscripcion.setFecha(new Date());
//System.out.println(request.getRemoteUser());
User user = this.userManager.getUserByUsername(request.getRemo teUser());
Long idUser = user.getId();
inscripcion.setIdUsuario(idUser.intValue());
Session sesion=inscripcionDAO.getSessionFactory().openSess ion();
Transaction trx = sesion.beginTransaction();
//Trabajos t = trabajosDAO.findByTitulo(fileUpload.getNombreTraba jo()).get(0);
//saveMessage(request, getText("fileUpload.deleted", fileUpload.getNombreTrabajo(), locale));
try {
this.getInscripcionDAO().save(inscripcion);
trx.commit();
//this.getInscripcionDAO().save(inscripcion);
//this.getInscripcionManager().saveInscripciones(ins cripcion);
} catch (AccessDeniedException ade) {
// thrown by UserSecurityAdvice configured in aop:advisor userManagerSecurity
log.warn(ade.getMessage());
trx.rollback();
response.sendError(HttpServletResponse.SC_FORBIDDE N);
return null;
} catch (Exception e) {
errors.rejectValue("inscripcion", "errors.creating.inscripcion",
new Object[]{inscripcion.getEMail()}, "inscripcion fallida");
trx.rollback();
// redisplay the unencrypted passwords
return showForm(request, response, errors);
} finally{
sesion.close();
//sesionAutor.close();
}
saveMessage(request, getText("inscripcion.registered", inscripcion.getEMail(), locale));
request.getSession().setAttribute(Constants.REGIST ERED, Boolean.TRUE);
// Send user an e-mail
if (log.isDebugEnabled()) {
log.debug("Sending user '" + inscripcion.getNombre() + "' an account information e-mail");
}
request.setAttribute("nombre", inscripcion.getNombre());
request.setAttribute("apellidos", inscripcion.getApellidos());
request.setAttribute("email", inscripcion.getEMail());
request.setAttribute("empresa", inscripcion.getEmpresa());
request.setAttribute("idInscripcion", inscripcion.getId());
// Send an account information e-mail
try {
//sendInscripcionDao(inscripcion, getText("signup.email.message", locale), RequestUtil.getAppURL(request));
} catch (MailException me) {
saveError(request, me.getMostSpecificCause().getMessage());
}
return new ModelAndView(getSuccessView());
}
El security.xml.
<http auto-config='true' lowercase-comparisons="false">
<intercept-url pattern="/images/*" filters="none"/>
<intercept-url pattern="/styles/*" filters="none"/>
<intercept-url pattern="/scripts/*" filters="none"/>
<intercept-url pattern="/admin/*" access="ROLE_ADMIN"/>
<intercept-url pattern="/passwordHint.html*" access="ROLE_ANONYMOUS,ROLE_ADMIN,ROLE_USER"/>
<intercept-url pattern="/signup.html*" access="ROLE_ANONYMOUS,ROLE_ADMIN,ROLE_USER"/>
<intercept-url pattern="/inscripcion.html*" access="ROLE_ANONYMOUS"/>
<intercept-url pattern="/resultadoInscripcion.html*" access="ROLE_ANONYMOUS,ROLE_ADMIN,ROLE_USER"/>
<intercept-url pattern="/**/*.html*" access="ROLE_ADMIN,ROLE_USER"/>
<form-login login-page="/login.jsp" authentication-failure-url="/login.jsp?error=true" login-processing-url="/j_security_check"/>
<!--<remember-me user-service-ref="userDao" key="e37f4b31-0c45-11dd-bd0b-0800200c9a66"/>
--></http>
<authentication-provider user-service-ref="userDao">
<!--<password-encoder ref="passwordEncoder"/>
--></authentication-provider><!--
Override the default password-encoder (SHA) by uncommenting the following and changing the class
--><!--<beans:bean id="passwordEncoder" class="org.springframework.security.providers.enco ding.ShaPasswordEncoder"/>
--><global-method-security>
<protect-pointcut expression="execution(* *..service.UserManager.getUsers(..))" access="ROLE_ADMIN"/>
<protect-pointcut expression="execution(* *..service.UserManager.removeUser(..))" access="ROLE_ADMIN"/>
</global-method-security><!--
Si me podeis ayudar gracias. |