// Path: src/main/java/ch/rasc/eds/starter/config/security/MongoUserDetails.java
// public class MongoUserDetails implements UserDetails {
// 
// 	private static final long serialVersionUID = 1L;
// 
// 	private Collection<GrantedAuthority> authorities;
// 
// 	private final Collection<GrantedAuthority> userAuthorities;
// 
// 	private final String password;
// 
// 	private final String loginName;
// 
// 	private final boolean enabled;
// 
// 	private final String userDbId;
// 
// 	private final boolean locked;
// 
// 	private final Locale locale;
// 
// 	public MongoUserDetails(User user) {
// 		this.userDbId = user.getId();
// 
// 		this.password = user.getPasswordHash();
// 		this.loginName = user.getLoginName();
// 		this.enabled = user.isEnabled();
// 
// 		if (StringUtils.hasText(user.getLocale())) {
// 			this.locale = new Locale(user.getLocale());
// 		}
// 		else {
// 			this.locale = Locale.ENGLISH;
// 		}
// 
// 		this.locked = user.getLockedOutUntil() != null
// 				&& user.getLockedOutUntil().after(new Date());
// 
// 		if (user.getAuthorities() != null) {
// 			this.userAuthorities = createAuthorityList(user.getAuthorities());
// 		}
// 		else {
// 			this.userAuthorities = Collections.emptyList();
// 		}
// 
// 		if (StringUtils.hasText(user.getSecret())) {
// 			this.authorities = Collections.unmodifiableCollection(
// 					AuthorityUtils.createAuthorityList("PRE_AUTH"));
// 		}
// 		else {
// 			this.authorities = Collections.unmodifiableCollection(this.userAuthorities);
// 		}
// 	}
// 
// 	public boolean isPreAuth() {
// 		return hasAuthority("PRE_AUTH");
// 	}
// 
// 	public void grantAuthorities() {
// 		this.authorities = Collections.unmodifiableCollection(this.userAuthorities);
// 	}
// 
// 	@Override
// 	public Collection<GrantedAuthority> getAuthorities() {
// 		return this.authorities;
// 	}
// 
// 	@Override
// 	public String getPassword() {
// 		return this.password;
// 	}
// 
// 	@Override
// 	public String getUsername() {
// 		return this.loginName;
// 	}
// 
// 	public User getUser(MongoDb mongoDb) {
// 		return mongoDb.getCollection(User.class)
// 				.find(Filters.and(Filters.eq(CUser.id, getUserDbId()),
// 						Filters.eq(CUser.deleted, false)))
// 				.first();
// 	}
// 
// 	public String getUserDbId() {
// 		return this.userDbId;
// 	}
// 
// 	public Locale getLocale() {
// 		return this.locale;
// 	}
// 
// 	@Override
// 	public boolean isAccountNonExpired() {
// 		return true;
// 	}
// 
// 	@Override
// 	public boolean isAccountNonLocked() {
// 		return !this.locked;
// 	}
// 
// 	@Override
// 	public boolean isCredentialsNonExpired() {
// 		return true;
// 	}
// 
// 	@Override
// 	public boolean isEnabled() {
// 		return this.enabled;
// 	}
// 
// 	public boolean hasAuthority(String authority) {
// 		return getAuthorities().stream()
// 				.anyMatch(a -> authority.equals(a.getAuthority()));
// 	}
// 
// 	private static List<GrantedAuthority> createAuthorityList(
// 			Collection<String> stringAuthorities) {
// 		List<GrantedAuthority> authorities = new ArrayList<>(stringAuthorities.size());
// 
// 		for (String stringAuthority : stringAuthorities) {
// 			authorities.add(new SimpleGrantedAuthority(stringAuthority));
// 		}
// 
// 		return authorities;
// 	}
// 
// }
// 
// Path: src/main/java/ch/rasc/eds/starter/entity/Authority.java
// public enum Authority {
// 	ADMIN, USER
// }


import static ch.ralscha.extdirectspring.annotation.ExtDirectMethodType.TREE_LOAD;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
import java.util.stream.Collectors;
import org.springframework.context.MessageSource;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.stereotype.Service;
import ch.ralscha.extdirectspring.annotation.ExtDirectMethod;
import ch.rasc.eds.starter.config.security.MongoUserDetails;
import ch.rasc.eds.starter.dto.NavigationNode;
import ch.rasc.eds.starter.entity.Authority;
package ch.rasc.eds.starter.service;





@Service
public class NavigationService {

	private final MessageSource messageSource;

	private final List<NavigationNode> rootNodes = new ArrayList<>();

	public NavigationService(MessageSource messageSource) {
		this.messageSource = messageSource;

		this.rootNodes.add(new NavigationNode("user_users", "user.Container", true, null,
				"x-fa fa-users", "users", Authority.ADMIN));

		this.rootNodes.add(new NavigationNode("Blank", "main.BlankPage", true, null,
				"x-fa fa-clock-o", "blank", Authority.USER));
	}

	@ExtDirectMethod(TREE_LOAD)
// Path: src/main/java/ch/rasc/eds/starter/config/security/MongoUserDetails.java
// public class MongoUserDetails implements UserDetails {
// 
// 	private static final long serialVersionUID = 1L;
// 
// 	private Collection<GrantedAuthority> authorities;
// 
// 	private final Collection<GrantedAuthority> userAuthorities;
// 
// 	private final String password;
// 
// 	private final String loginName;
// 
// 	private final boolean enabled;
// 
// 	private final String userDbId;
// 
// 	private final boolean locked;
// 
// 	private final Locale locale;
// 
// 	public MongoUserDetails(User user) {
// 		this.userDbId = user.getId();
// 
// 		this.password = user.getPasswordHash();
// 		this.loginName = user.getLoginName();
// 		this.enabled = user.isEnabled();
// 
// 		if (StringUtils.hasText(user.getLocale())) {
// 			this.locale = new Locale(user.getLocale());
// 		}
// 		else {
// 			this.locale = Locale.ENGLISH;
// 		}
// 
// 		this.locked = user.getLockedOutUntil() != null
// 				&& user.getLockedOutUntil().after(new Date());
// 
// 		if (user.getAuthorities() != null) {
// 			this.userAuthorities = createAuthorityList(user.getAuthorities());
// 		}
// 		else {
// 			this.userAuthorities = Collections.emptyList();
// 		}
// 
// 		if (StringUtils.hasText(user.getSecret())) {
// 			this.authorities = Collections.unmodifiableCollection(
// 					AuthorityUtils.createAuthorityList("PRE_AUTH"));
// 		}
// 		else {
// 			this.authorities = Collections.unmodifiableCollection(this.userAuthorities);
// 		}
// 	}
// 
// 	public boolean isPreAuth() {
// 		return hasAuthority("PRE_AUTH");
// 	}
// 
// 	public void grantAuthorities() {
// 		this.authorities = Collections.unmodifiableCollection(this.userAuthorities);
// 	}
// 
// 	@Override
// 	public Collection<GrantedAuthority> getAuthorities() {
// 		return this.authorities;
// 	}
// 
// 	@Override
// 	public String getPassword() {
// 		return this.password;
// 	}
// 
// 	@Override
// 	public String getUsername() {
// 		return this.loginName;
// 	}
// 
// 	public User getUser(MongoDb mongoDb) {
// 		return mongoDb.getCollection(User.class)
// 				.find(Filters.and(Filters.eq(CUser.id, getUserDbId()),
// 						Filters.eq(CUser.deleted, false)))
// 				.first();
// 	}
// 
// 	public String getUserDbId() {
// 		return this.userDbId;
// 	}
// 
// 	public Locale getLocale() {
// 		return this.locale;
// 	}
// 
// 	@Override
// 	public boolean isAccountNonExpired() {
// 		return true;
// 	}
// 
// 	@Override
// 	public boolean isAccountNonLocked() {
// 		return !this.locked;
// 	}
// 
// 	@Override
// 	public boolean isCredentialsNonExpired() {
// 		return true;
// 	}
// 
// 	@Override
// 	public boolean isEnabled() {
// 		return this.enabled;
// 	}
// 
// 	public boolean hasAuthority(String authority) {
// 		return getAuthorities().stream()
// 				.anyMatch(a -> authority.equals(a.getAuthority()));
// 	}
// 
// 	private static List<GrantedAuthority> createAuthorityList(
// 			Collection<String> stringAuthorities) {
// 		List<GrantedAuthority> authorities = new ArrayList<>(stringAuthorities.size());
// 
// 		for (String stringAuthority : stringAuthorities) {
// 			authorities.add(new SimpleGrantedAuthority(stringAuthority));
// 		}
// 
// 		return authorities;
// 	}
// 
// }
// 
// Path: src/main/java/ch/rasc/eds/starter/entity/Authority.java
// public enum Authority {
// 	ADMIN, USER
// }


// Path: src/main/java/ch/rasc/eds/starter/service/NavigationService.java
import static ch.ralscha.extdirectspring.annotation.ExtDirectMethodType.TREE_LOAD;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
import java.util.stream.Collectors;
import org.springframework.context.MessageSource;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.stereotype.Service;
import ch.ralscha.extdirectspring.annotation.ExtDirectMethod;
import ch.rasc.eds.starter.config.security.MongoUserDetails;
import ch.rasc.eds.starter.dto.NavigationNode;
import ch.rasc.eds.starter.entity.Authority;

package ch.rasc.eds.starter.service;





@Service
public class NavigationService {

	private final MessageSource messageSource;

	private final List<NavigationNode> rootNodes = new ArrayList<>();

	public NavigationService(MessageSource messageSource) {
		this.messageSource = messageSource;

		this.rootNodes.add(new NavigationNode("user_users", "user.Container", true, null,
				"x-fa fa-users", "users", Authority.ADMIN));

		this.rootNodes.add(new NavigationNode("Blank", "main.BlankPage", true, null,
				"x-fa fa-clock-o", "blank", Authority.USER));
	}

	@ExtDirectMethod(TREE_LOAD)
	public List<NavigationNode> getNavigation(Locale locale,