content: /**
   *    Copyright 2016 Sven Loesekann
  
     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at
  
         http://www.apache.org/licenses/LICENSE-2.0
  
     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
   */
  package ch.xxx.trader.domain.model.entity;
  
  import java.util.Arrays;
  import java.util.Collection;
  import java.util.Date;
  
  import jakarta.validation.constraints.NotBlank;
  import jakarta.validation.constraints.NotNull;
  import jakarta.validation.constraints.Size;
  
  import org.bson.types.ObjectId;
  import org.springframework.data.annotation.Id;
  import org.springframework.data.mongodb.core.mapping.Document;
  import org.springframework.security.core.GrantedAuthority;
  import org.springframework.security.core.authority.SimpleGrantedAuthority;
  import org.springframework.security.core.userdetails.UserDetails;
  
  import com.fasterxml.jackson.annotation.JsonIgnore;
  import com.fasterxml.jackson.annotation.JsonProperty;
  
  @Document
  public class MyUser implements UserDetails {
  
  	private static final long serialVersionUID = 4579343827343522647L;
  
  	@Id
  	private ObjectId _id;
  	@NotNull
  	@JsonProperty
  	private Date createdAt = new Date();
  	@NotBlank
  	@Size(min = 4)
  	@JsonProperty
  	private String userId;
  	@NotBlank
  	@Size(min = 4)
  	@JsonProperty
  	private String password;
  	@JsonProperty
  	private String salt;
  	@JsonProperty
  	private String email;	
  	@JsonProperty
  	private String token;
  	@JsonProperty
  	private boolean accountNonExpired = true;
  	@JsonProperty
  	private boolean accountNonLocked = true;
  	@JsonProperty
  	private boolean credentialsNonExpired = true;
  	@JsonProperty
  	private boolean enabled = true;
  	
  	public ObjectId get_id() {
  		return _id;
  	}
  	public void set_id(ObjectId _id) {
  		this._id = _id;
  	}
  	public String getUserId() {
  		return userId;
  	}
  	public void setUserId(String userId) {
  		this.userId = userId;
  	}
  	public String getPassword() {
  		return password;
  	}
  	public void setPassword(String password) {
  		this.password = password;
  	}	
  	public String getEmail() {
  		return email;
  	}
  	public void setEmail(String email) {
  		this.email = email;
  	}
  	public String getSalt() {
  		return salt;
  	}
  	public void setSalt(String salt) {
  		this.salt = salt;
  	}
  	@JsonIgnore
  	@Override
  	public Collection<? extends GrantedAuthority> getAuthorities() {
  		GrantedAuthority auth = new SimpleGrantedAuthority("USERS"); 					
  		return Arrays.asList(auth);
  	}
  	@JsonIgnore
  	@Override
  	public String getUsername() {
  		return this.userId;
  	}
  	@Override
  	public boolean isAccountNonExpired() {
  		return this.accountNonExpired;
  	}
  	@Override
  	public boolean isAccountNonLocked() {
  		return this.accountNonLocked;
  	}
  	@Override
  	public boolean isCredentialsNonExpired() {
  		return this.credentialsNonExpired;
  	}
  	@Override
  	public boolean isEnabled() {
  		return this.enabled;
  	}
  	public Date getCreatedAt() {
  		return createdAt;
  	}
  	public void setCreatedAt(Date createdAt) {
  		this.createdAt = createdAt;
  	}
  	public String getToken() {
  		return token;
  	}
  	public void setToken(String token) {
  		this.token = token;
  	}
  	public void setAccountNonExpired(boolean accountNonExpired) {
  		this.accountNonExpired = accountNonExpired;
  	}
  	public void setAccountNonLocked(boolean accountNonLocked) {
  		this.accountNonLocked = accountNonLocked;
  	}
  	public void setCredentialsNonExpired(boolean credentialsNonExpired) {
  		this.credentialsNonExpired = credentialsNonExpired;
  	}
  	public void setEnabled(boolean enabled) {
  		this.enabled = enabled;
  	}
  	
  	@Override
  	public String toString() {
  		return "MyUser [_id=" + _id + ", createdAt=" + createdAt + ", userId=" + userId + ", password=" + password
  				+ ", salt=" + salt + ", email=" + email + ", token=" + token + ", accountNonExpired="
  				+ accountNonExpired + ", accountNonLocked=" + accountNonLocked + ", credentialsNonExpired="
  				+ credentialsNonExpired + ", enabled=" + enabled + "]";
  	}
  }
  