Java 类org.springframework.security.core.authority.mapping.GrantedAuthoritiesMapper 实例源码

项目:smartling-keycloak-extras    文件:KeycloakSpringAdapterUtils.java   
/**
 * Creates a {@link GrantedAuthority} collection from the given {@link KeycloakSecurityContext}.
 *
 * @param context the current <code>RefreshableKeycloakSecurityContext</code> (required)
 * @param mapper an optional {@link GrantedAuthoritiesMapper} to convert the
 * authorities loaded the given <code>context</code> which will be used in the
 * {@code Authentication} object
 *
 * @return a {@link GrantedAuthority} collection if any; an empty list otherwise
 */
public static Collection<? extends GrantedAuthority> createGrantedAuthorities(RefreshableKeycloakSecurityContext context, GrantedAuthoritiesMapper mapper) {
    Assert.notNull(context, "RefreshableKeycloakSecurityContext cannot be null");
    List<KeycloakRole> grantedAuthorities = new ArrayList<>();

    for (String role : AdapterUtils.getRolesFromSecurityContext(context)) {
        grantedAuthorities.add(new KeycloakRole(role));
    }

    return mapper != null ? mapper.mapAuthorities(grantedAuthorities) : Collections.unmodifiableList(grantedAuthorities);
}
项目:find    文件:ReverseProxyIdolSecurityCustomizer.java   
@Autowired
public ReverseProxyIdolSecurityCustomizer(
        final UserService userService,
        final GrantedAuthoritiesMapper grantedAuthoritiesMapper,
        @Value("${find.reverse-proxy.pre-authenticated-roles}") final String preAuthenticatedRoles
) {

    this.userService = userService;
    this.grantedAuthoritiesMapper = grantedAuthoritiesMapper;
    this.preAuthenticatedRoles = preAuthenticatedRoles;
}
项目:find    文件:UserConfiguration.java   
@Bean
public GrantedAuthoritiesMapper grantedAuthoritiesMapper() {
    final Map<String, String> rolesMap = new CaseInsensitiveMap<>();

    rolesMap.put(FindCommunityRole.USER.value(), FindRole.USER.toString());
    rolesMap.put(FindCommunityRole.ADMIN.value(), FindRole.ADMIN.toString());

    if (enableBi) {
        rolesMap.put(FindCommunityRole.BI.value(), FindRole.BI.toString());
    }

    return new OneToOneOrZeroSimpleAuthorityMapper(Collections.unmodifiableMap(rolesMap));
}
项目:molgenis    文件:UserDetailsServiceTest.java   
@BeforeMethod
public void setUp()
{
    DataService dataService = mock(DataService.class);
    User adminUser = when(mock(User.class).isSuperuser()).thenReturn(Boolean.TRUE).getMock();
    when(adminUser.getUsername()).thenReturn("admin");
    when(adminUser.getPassword()).thenReturn("password");
    User userUser = when(mock(User.class).isSuperuser()).thenReturn(Boolean.FALSE).getMock();
    when(userUser.getUsername()).thenReturn("user");
    when(userUser.getPassword()).thenReturn("password");
    Query<User> qAdmin = new QueryImpl<User>().eq(UserMetaData.USERNAME, "admin");
    when(dataService.findOne(USER, qAdmin, User.class)).thenReturn(adminUser);
    Query<User> qUser = new QueryImpl<User>().eq(UserMetaData.USERNAME, "user");
    when(dataService.findOne(USER, qUser, User.class)).thenReturn(userUser);
    GrantedAuthoritiesMapper authoritiesMapper = authorities -> authorities;
    when(dataService.findAll(USER_AUTHORITY,
            new QueryImpl<UserAuthority>().eq(UserAuthorityMetaData.USER, userUser),
            UserAuthority.class)).thenAnswer(invocation -> Stream.empty());
    when(dataService.findAll(USER_AUTHORITY,
            new QueryImpl<UserAuthority>().eq(UserAuthorityMetaData.USER, adminUser),
            UserAuthority.class)).thenAnswer(invocation -> Stream.empty());
    when(dataService.findAll(GroupMemberMetaData.GROUP_MEMBER,
            new QueryImpl<GroupMember>().eq(GroupMemberMetaData.USER, userUser), GroupMember.class)).thenAnswer(
            invocation -> Stream.empty());
    when(dataService.findAll(GroupMemberMetaData.GROUP_MEMBER,
            new QueryImpl<GroupMember>().eq(GroupMemberMetaData.USER, adminUser), GroupMember.class)).thenAnswer(
            invocation -> Stream.empty());
    userDetailsService = new UserDetailsService(dataService, authoritiesMapper);
}
项目:molgenis    文件:ImportWizardController.java   
@Autowired
public ImportWizardController(UploadWizardPage uploadWizardPage, OptionsWizardPage optionsWizardPage,
        PackageWizardPage packageWizardPage, ValidationResultWizardPage validationResultWizardPage,
        ImportResultsWizardPage importResultsWizardPage, DataService dataService,
        GrantedAuthoritiesMapper grantedAuthoritiesMapper, UserAccountService userAccountService,
        ImportServiceFactory importServiceFactory, FileStore fileStore,
        FileRepositoryCollectionFactory fileRepositoryCollectionFactory, ImportRunService importRunService,
        GroupAuthorityFactory groupAuthorityFactory)
{
    super(URI, "importWizard");
    if (uploadWizardPage == null) throw new IllegalArgumentException("UploadWizardPage is null");
    if (optionsWizardPage == null) throw new IllegalArgumentException("OptionsWizardPage is null");
    if (validationResultWizardPage == null)
    {
        throw new IllegalArgumentException("ValidationResultWizardPage is null");
    }
    if (importResultsWizardPage == null) throw new IllegalArgumentException("ImportResultsWizardPage is null");
    this.uploadWizardPage = uploadWizardPage;
    this.optionsWizardPage = optionsWizardPage;
    this.validationResultWizardPage = validationResultWizardPage;
    this.importResultsWizardPage = importResultsWizardPage;
    this.packageWizardPage = packageWizardPage;
    this.userAccountService = userAccountService;
    this.dataService = dataService;
    this.grantedAuthoritiesMapper = grantedAuthoritiesMapper;
    this.importServiceFactory = importServiceFactory;
    this.fileStore = fileStore;
    this.fileRepositoryCollectionFactory = fileRepositoryCollectionFactory;
    this.importRunService = importRunService;
    this.groupAuthorityFactory = requireNonNull(groupAuthorityFactory);
    this.dataService = dataService;
    this.asyncImportJobs = Executors.newSingleThreadExecutor();
}
项目:molgenis    文件:ImportWizardController.java   
public ImportWizardController(UploadWizardPage uploadWizardPage, OptionsWizardPage optionsWizardPage,
        PackageWizardPage packageWizardPage, ValidationResultWizardPage validationResultWizardPage,
        ImportResultsWizardPage importResultsWizardPage, DataService dataService,
        GrantedAuthoritiesMapper grantedAuthoritiesMapper, UserAccountService userAccountService,
        ImportServiceFactory importServiceFactory, FileStore fileStore,
        FileRepositoryCollectionFactory fileRepositoryCollectionFactory, ImportRunService importRunService,
        ExecutorService executorService, GroupAuthorityFactory groupAuthorityFactory)
{
    super(URI, "importWizard");
    if (uploadWizardPage == null) throw new IllegalArgumentException("UploadWizardPage is null");
    if (optionsWizardPage == null) throw new IllegalArgumentException("OptionsWizardPage is null");
    if (validationResultWizardPage == null)
        throw new IllegalArgumentException("ValidationResultWizardPage is null");
    if (importResultsWizardPage == null) throw new IllegalArgumentException("ImportResultsWizardPage is null");
    this.uploadWizardPage = uploadWizardPage;
    this.optionsWizardPage = optionsWizardPage;
    this.validationResultWizardPage = validationResultWizardPage;
    this.importResultsWizardPage = importResultsWizardPage;
    this.packageWizardPage = packageWizardPage;
    this.userAccountService = userAccountService;
    this.dataService = dataService;
    this.grantedAuthoritiesMapper = grantedAuthoritiesMapper;
    this.importServiceFactory = importServiceFactory;
    this.fileStore = fileStore;
    this.fileRepositoryCollectionFactory = fileRepositoryCollectionFactory;
    this.importRunService = importRunService;
    this.dataService = dataService;
    this.asyncImportJobs = executorService;
    this.groupAuthorityFactory = groupAuthorityFactory;
}
项目:cfsummiteu2017    文件:UaaRelyingPartyAuthenticationProvider.java   
public void setAuthoritiesMapper(GrantedAuthoritiesMapper authoritiesMapper) {
    this.authoritiesMapper = authoritiesMapper;
}
项目:IdentityRegistry    文件:MCKeycloakAuthenticationProvider.java   
@Override
public void setGrantedAuthoritiesMapper(GrantedAuthoritiesMapper grantedAuthoritiesMapper) {
    this.grantedAuthoritiesMapper = grantedAuthoritiesMapper;
}
项目:molgenis    文件:PermissionManagerServiceImpl.java   
public PermissionManagerServiceImpl(DataService dataService, GrantedAuthoritiesMapper grantedAuthoritiesMapper)
{
    this.dataService = requireNonNull(dataService);
    this.grantedAuthoritiesMapper = requireNonNull(grantedAuthoritiesMapper);
}
项目:molgenis    文件:UserDetailsService.java   
public UserDetailsService(DataService dataService, GrantedAuthoritiesMapper grantedAuthoritiesMapper)
{
    this.dataService = requireNonNull(dataService, "DataService is null");
    this.grantedAuthoritiesMapper = requireNonNull(grantedAuthoritiesMapper, "Granted authorities mapper is null");
}
项目:molgenis    文件:MolgenisWebAppSecurityConfig.java   
@Bean
public GrantedAuthoritiesMapper roleHierarchyAuthoritiesMapper()
{
    return new RoleHierarchyAuthoritiesMapper(roleHierarchy());
}
项目:molgenis    文件:PermissionManagerServiceImplTest.java   
@Bean
public GrantedAuthoritiesMapper grantedAuthoritiesMapper()
{
    return mock(GrantedAuthoritiesMapper.class);
}
项目:molgenis    文件:ImportWizardControllerTest.java   
@Bean
public GrantedAuthoritiesMapper grantedAuthoritiesMapper()
{
    return mock(GrantedAuthoritiesMapper.class);
}
项目:smartling-keycloak-extras    文件:DirectAccessGrantAuthenticationProvider.java   
/**
 * Set the optional {@link GrantedAuthoritiesMapper} for this {@link AuthenticationProvider}.
 *
 * @param grantedAuthoritiesMapper the <code>GrantedAuthoritiesMapper</code> to use
 */
public void setGrantedAuthoritiesMapper(GrantedAuthoritiesMapper grantedAuthoritiesMapper) {
    this.grantedAuthoritiesMapper = grantedAuthoritiesMapper;
}