BAEL-509 (#2114)
* BAEL-509: Initial Commit - working but needs a few fixes to REST API, etc. * Fixed Authentication Failure - added subscription handlers - sufficient for Websocket Authentication/Authorization - still some issues to resolve with subscriptions and REST API * Final version * CSRF token controller - cleanup of chat wrapper
This commit is contained in:
committed by
KevinGilmore
parent
70ae331cd7
commit
db2bb252de
+51
@@ -0,0 +1,51 @@
|
||||
package com.baeldung.springsecuredsockets.domain;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Set;
|
||||
|
||||
@Entity
|
||||
@Table(name = "role")
|
||||
public class Role {
|
||||
|
||||
@Id
|
||||
//Slight increase in performance over GenerationType.IDENTITY
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
@Column(name = "role_id", updatable = false, nullable = false)
|
||||
private long role_id;
|
||||
|
||||
@Column(name = "role", nullable = false)
|
||||
private String role;
|
||||
|
||||
/**
|
||||
* Many to Many Example - see Role.
|
||||
* <p>
|
||||
* One User many have many Roles.
|
||||
* Each Role may be assigned to many Users.
|
||||
*/
|
||||
@ManyToMany(mappedBy = "roles", fetch = FetchType.EAGER)
|
||||
private Set<User> users;
|
||||
|
||||
public long getRole_id() {
|
||||
return role_id;
|
||||
}
|
||||
|
||||
public void setRole_id(long role_id) {
|
||||
this.role_id = role_id;
|
||||
}
|
||||
|
||||
public String getRole() {
|
||||
return role;
|
||||
}
|
||||
|
||||
public void setRole(String role) {
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
public Set<User> getUsers() {
|
||||
return users;
|
||||
}
|
||||
|
||||
public void setUsers(Set<User> users) {
|
||||
this.users = users;
|
||||
}
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
package com.baeldung.springsecuredsockets.domain;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Set;
|
||||
|
||||
//Custom User Model
|
||||
|
||||
@Entity
|
||||
@Table(name = "user")
|
||||
public class User {
|
||||
|
||||
@Id
|
||||
//Slight increase in performance over GenerationType.IDENTITY
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
@Column(name = "user_id", updatable = false, nullable = false)
|
||||
private long user_id;
|
||||
|
||||
@Column(name = "username", nullable = false)
|
||||
private String username;
|
||||
|
||||
@Column(name = "password", nullable = false)
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* Many to Many Example - see Role.
|
||||
* <p>
|
||||
* One User many have many Roles.
|
||||
* Each Role may be assigned to many Users.
|
||||
*/
|
||||
@ManyToMany(fetch = FetchType.EAGER)
|
||||
@JoinTable(name = "user_role", joinColumns = @JoinColumn(name = "user_id"), inverseJoinColumns = @JoinColumn(name = "role_id"))
|
||||
private Set<Role> roles;
|
||||
|
||||
public long getUser_id() {
|
||||
return user_id;
|
||||
}
|
||||
|
||||
public void setUser_id(long user_id) {
|
||||
this.user_id = user_id;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public Set<Role> getRoles() {
|
||||
return roles;
|
||||
}
|
||||
|
||||
public void setRoles(Set<Role> roles) {
|
||||
this.roles = roles;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user