It is very good tutorial nice explained.
i'm using oracle DB, in oracle bit datatype is not there, so use char and i modify the user class.
i'm getting response like this
{
"error": "unauthorized",
"error_description": "User is disabled"
}
please help me out.
@Column(name = "account_locked")
private String accountNonLocked;
@Column(name = "account_expired")
private String accountNonExpired;
@Column(name = "credentials_expired")
private String credentialsNonExpired;
@ManyToMany(fetch = FetchType.EAGER)
@JoinTable(name = "role_user", joinColumns = {
@JoinColumn(name = "user_id", referencedColumnName = "id") }, inverseJoinColumns = {
@JoinColumn(name = "role_id", referencedColumnName = "id") })
private List<Role> roles;
@Override
public boolean isEnabled() {
return Boolean.valueOf(enabled);
}
@Override
public boolean isAccountNonExpired() {
return !Boolean.valueOf(accountNonExpired);
}
@Override
public boolean isCredentialsNonExpired() {
return !Boolean.valueOf(credentialsNonExpired);
}
@Override
public boolean isAccountNonLocked() {
return !Boolean.valueOf(accountNonLocked);
}
/*
* Get roles and permissions and add them as a Set of GrantedAuthority
*/
@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
Set<GrantedAuthority> authorities = new HashSet<GrantedAuthority>();
roles.forEach(r -> {
authorities.add(new SimpleGrantedAuthority(r.getName()));
r.getPermissions().forEach(p -> {
authorities.add(new SimpleGrantedAuthority(p.getName()));
});
});
return authorities;
}
@Override
public String getPassword() {
return password;
}
@Override
public String getUsername() {
return username;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getEnabled() {
return enabled;
}
public void setEnabled(String enabled) {
this.enabled = enabled;
}
public String getAccountNonLocked() {
return accountNonLocked;
}
public void setAccountNonLocked(String accountNonLocked) {
this.accountNonLocked = accountNonLocked;
}
public String getAccountNonExpired() {
return accountNonExpired;
}
public void setAccountNonExpired(String accountNonExpired) {
this.accountNonExpired = accountNonExpired;
}
public String getCredentialsNonExpired() {
return credentialsNonExpired;
}
public void setCredentialsNonExpired(String credentialsNonExpired) {
this.credentialsNonExpired = credentialsNonExpired;
}