All Downloads are FREE. Search and download functionalities are using the official Maven repository.

foundation.cmo.api.mls.graphql.security.dto.MUserDetails Maven / Gradle / Ivy

There is a newer version: 1.0.21
Show newest version
package foundation.cmo.api.mls.graphql.security.dto;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import lombok.AllArgsConstructor;
import lombok.Data;

@Data
@AllArgsConstructor(staticName = "to")
public class MUserDetails implements UserDetails {

	private static final long serialVersionUID = 1L;

	private final String ROLE_PREFIX = "ROLE_";

	private MUser user;

	@Override
	public Collection getAuthorities() {
		List list = new ArrayList();
		list.add(new SimpleGrantedAuthority(ROLE_PREFIX + user.getRole()));
		return list;
	}

	@Override
	public String getPassword() {
		return user.getPassword();
	}

	@Override
	public String getUsername() {
		return user.getUsername();
	}

	@Override
	public boolean isAccountNonExpired() {
		return user.isExpired();
	}

	@Override
	public boolean isAccountNonLocked() {
		return user.isLocked();
	}

	@Override
	public boolean isCredentialsNonExpired() {
		return user.isCredentialExpired();
	}

	@Override
	public boolean isEnabled() {
		return user.isEnabled();
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy