// Path: server/src/main/java/com/changeme/repository/UserProfile.java
// @Entity
// @Table(name = "user_profile")
// public class UserProfile {
// 
//     public static final PasswordEncoder PASSWORD_ENCODER = new BCryptPasswordEncoder();
// 
//     @Id
//     @Column(name = "id")
//     @GeneratedValue(strategy = GenerationType.IDENTITY)
//     private Long id;
//     @Column(name = "username")
//     private String username;
//     @JsonIgnore
//     @Column(name = "password")
//     private String password;
//     @Column(name = "authorities")
//     private String authorities;
// 
//     public UserProfile() {
//     }
// 
//     public UserProfile(String username, String password, String roles) {
//         this.setUsername(username);
//         this.setPassword(password);
//         this.setAuthorities(roles);
//     }
// 
//     public Long getId() {
//         return this.id;
//     }
// 
//     public void setId(Long id) {
//         this.id = id;
//     }
// 
//     public String getUsername() {
//         return this.username;
//     }
// 
//     public void setUsername(String username) {
//         this.username = username;
//     }
// 
//     public String getPassword() {
//         return this.password;
//     }
// 
//     public void setPassword(String password) {
//         this.password = PASSWORD_ENCODER.encode(password);
//     }
// 
//     public String getAuthorities() {
//         return this.authorities;
//     }
// 
//     public void setAuthorities(String authorities) {
//         this.authorities = authorities;
//     }
// 
// 
// }
// 
// Path: server/src/main/java/com/changeme/repository/UserProfileRepository.java
// @RepositoryRestResource(exported = false)
// public interface UserProfileRepository extends CrudRepository<UserProfile, Long> {
// 
//     UserProfile findByUsername(String username);
// 
// }


import com.changeme.repository.UserProfile;
import com.changeme.repository.UserProfileRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.security.Principal;
package com.changeme.controller;



@RestController
@RequestMapping(path = "/secure")
public class UserProfileController {

    @Autowired
    private UserProfileRepository userProfileRepository;

    @RequestMapping(method = RequestMethod.GET, value = "/user/profile")
    @PreAuthorize("hasAuthority('USER')")
    public ResponseEntity<?> authenticationRequest(HttpServletRequest request){
        Principal user = request.getUserPrincipal();
        if(user != null){
// Path: server/src/main/java/com/changeme/repository/UserProfile.java
// @Entity
// @Table(name = "user_profile")
// public class UserProfile {
// 
//     public static final PasswordEncoder PASSWORD_ENCODER = new BCryptPasswordEncoder();
// 
//     @Id
//     @Column(name = "id")
//     @GeneratedValue(strategy = GenerationType.IDENTITY)
//     private Long id;
//     @Column(name = "username")
//     private String username;
//     @JsonIgnore
//     @Column(name = "password")
//     private String password;
//     @Column(name = "authorities")
//     private String authorities;
// 
//     public UserProfile() {
//     }
// 
//     public UserProfile(String username, String password, String roles) {
//         this.setUsername(username);
//         this.setPassword(password);
//         this.setAuthorities(roles);
//     }
// 
//     public Long getId() {
//         return this.id;
//     }
// 
//     public void setId(Long id) {
//         this.id = id;
//     }
// 
//     public String getUsername() {
//         return this.username;
//     }
// 
//     public void setUsername(String username) {
//         this.username = username;
//     }
// 
//     public String getPassword() {
//         return this.password;
//     }
// 
//     public void setPassword(String password) {
//         this.password = PASSWORD_ENCODER.encode(password);
//     }
// 
//     public String getAuthorities() {
//         return this.authorities;
//     }
// 
//     public void setAuthorities(String authorities) {
//         this.authorities = authorities;
//     }
// 
// 
// }
// 
// Path: server/src/main/java/com/changeme/repository/UserProfileRepository.java
// @RepositoryRestResource(exported = false)
// public interface UserProfileRepository extends CrudRepository<UserProfile, Long> {
// 
//     UserProfile findByUsername(String username);
// 
// }


// Path: server/src/main/java/com/changeme/controller/UserProfileController.java
import com.changeme.repository.UserProfile;
import com.changeme.repository.UserProfileRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.security.Principal;

package com.changeme.controller;



@RestController
@RequestMapping(path = "/secure")
public class UserProfileController {

    @Autowired
    private UserProfileRepository userProfileRepository;

    @RequestMapping(method = RequestMethod.GET, value = "/user/profile")
    @PreAuthorize("hasAuthority('USER')")
    public ResponseEntity<?> authenticationRequest(HttpServletRequest request){
        Principal user = request.getUserPrincipal();
        if(user != null){
            UserProfile userProfile = userProfileRepository.findByUsername(user.getName());