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

ca.gc.aafc.dina.config.DevSettings Maven / Gradle / Ivy

There is a newer version: 0.132
Show newest version
package ca.gc.aafc.dina.config;

import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import lombok.Getter;
import lombok.Setter;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import ca.gc.aafc.dina.security.DinaRole;

/**
 * Settings only for devs in dev mode
 */
@Component
@ConfigurationProperties(prefix = "dev-user")
@Getter
@Setter
public class DevSettings {

  private Map> groupRole;

  public Map> getRolesPerGroup() {

    if (groupRole == null || groupRole.isEmpty()) {
      return Map.of();
    }

    Map> groupDinaRole = new HashMap<>(groupRole.size());

    for (var entry : groupRole.entrySet()) {
      groupDinaRole.put(entry.getKey(), entry.getValue().stream()
        .map(DinaRole::fromString)
        .map(Optional::orElseThrow).collect(
        Collectors.toSet()));
    }

    return groupDinaRole;
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy