Mam takie coś z przypisaniem "na sztywno" loginu i hasła:
<security:http auto-config="true">
<security:intercept-url pattern="/add" access="ROLE_ADMIN" />
<security:form-login login-page="/login"
default-target-url="/products"
authentication-failure-url="/loginfailed"/>
<security:logout logout-success-url="/logout" />
</security:http>
<security:authentication-manager>
<security:authentication-provider>
<security:user-service>
<security:user name="Admin" password="Admin123" authorities="ROLE_ADMIN" />
</security:user-service>
</security:authentication-provider>
</security:authentication-manager>
login.jsp
<c:if test="${not empty error}">
<div class="alert alert-danger">
<spring:message code="AbstractUserDetailsAuthenticationProvider.badCredentials"/><br />
</div>
</c:if>
<form action="<c:url value="/j_spring_security_check"></c:url>" method="post">
<fieldset>
<div class="form-group">
<input class="form-control" placeholder="Nazwa użytkownika" name='j_username' type="text">
</div>
<div class="form-group">
<input class="form-control" placeholder="Hasło" name='j_password' type="password" value="">
</div>
<input class="btn btn-lg btn-success btn-block" type="submit" value="Zaloguj się">
</fieldset>
</form>
@RequestMapping(value="/login", method = RequestMethod.GET)
public String login() {
return "login";
}
@RequestMapping(value="/loginfailed", method = RequestMethod.GET)
public String loginerror(Model model) {
model.addAttribute("error", "true");
return "login";
}
@RequestMapping(value="/logout", method = RequestMethod.GET)
public String logout(Model model) {
return "login";
}
@Entity
@Table(name="Klient")
public class Klient {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
int idKlient;
@Column(unique=true)
String login;
String haslo;
....
I jak to zmienić, żeby j_username i j_password były pobierane z bazy na podstawie j_username dla danego Klienta ? Mam z tym kłopot właśnie.