• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java RoleImpl类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中org.jboss.errai.security.shared.api.RoleImpl的典型用法代码示例。如果您正苦于以下问题:Java RoleImpl类的具体用法?Java RoleImpl怎么用?Java RoleImpl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

RoleImpl类属于org.jboss.errai.security.shared.api包,在下文中一共展示了RoleImpl类的31个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testResolvePermissionsCustomDeniedOverDefaultGranted

点赞 3

import org.jboss.errai.security.shared.api.RoleImpl; //导入依赖的package包/类
@Test
public void testResolvePermissionsCustomDeniedOverDefaultGranted() {

    final VotingStrategy priority = VotingStrategy.PRIORITY;
    final Role businessUserRole = new RoleImpl("business-user");
    final Group directorGroup = new GroupImpl("director");

    // Users have a group with their names by default
    final User user = makeUser("director", directorGroup, businessUserRole);

    mockDefaultPermissions(authorizationPolicy,
                           makeGrantedPermissionCollection());
    mockRolePermissions(authorizationPolicy,
                        makeDeniedPermissionCollection(),
                        businessUserRole,
                        0);
    mockDefaultGroupPermissions(authorizationPolicy,
                                makeGrantedPermissionCollection(),
                                directorGroup);

    final PermissionCollection resolvedPermission = defaultPermissionManager.resolvePermissions(user, priority);
    final Permission permission = resolvedPermission.get(PERMISSION_NAME);

    assertEquals(AuthorizationResult.ACCESS_DENIED, permission.getResult());
}
 

开发者ID:kiegroup,
项目名称:appformer,
代码行数:26,
代码来源:DefaultPermissionManagerTest.java

示例2: testResolvePermissionsCustomGrantedOverDefaultDenied

点赞 3

import org.jboss.errai.security.shared.api.RoleImpl; //导入依赖的package包/类
@Test
public void testResolvePermissionsCustomGrantedOverDefaultDenied() {

    final VotingStrategy priority = VotingStrategy.PRIORITY;
    final Role businessUserRole = new RoleImpl("business-user");
    final Group directorGroup = new GroupImpl("director");

    // Users have a group with their names by default
    final User user = makeUser("director", directorGroup, businessUserRole);

    mockDefaultPermissions(authorizationPolicy,
                           makeDeniedPermissionCollection());
    mockRolePermissions(authorizationPolicy,
                        makeGrantedPermissionCollection(),
                        businessUserRole,
                        0);
    mockDefaultGroupPermissions(authorizationPolicy,
                                makeDeniedPermissionCollection(),
                                directorGroup);

    final PermissionCollection resolvedPermission = defaultPermissionManager.resolvePermissions(user, priority);
    final Permission permission = resolvedPermission.get(PERMISSION_NAME);

    assertEquals(AuthorizationResult.ACCESS_GRANTED, permission.getResult());
}
 

开发者ID:kiegroup,
项目名称:appformer,
代码行数:26,
代码来源:DefaultPermissionManagerTest.java

示例3: testInheritPermissionValue

点赞 3

import org.jboss.errai.security.shared.api.RoleImpl; //导入依赖的package包/类
@Test
public void testInheritPermissionValue() {
    PermissionTree tree = permissionTreeFactory.createPermissionTree(new RoleImpl("admin"));
    PermissionTreeVisitor visitor = mock(PermissionTreeVisitor.class);
    tree.accept(visitor);

    ArgumentCaptor<PermissionNode> argumentCaptor = ArgumentCaptor.forClass(PermissionNode.class);
    verify(visitor,
           times(15)).visit(argumentCaptor.capture());

    for (PermissionNode node : argumentCaptor.getAllValues()) {

        // setting8 must be initialized to false according to its parent
        if (node.getNodeName().equals("Setting 8")) {
            assertEquals(node.getPermissionList().size(),
                         1);
            Permission p = node.getPermissionList().get(0);
            assertEquals(p.getResult(),
                         AuthorizationResult.ACCESS_DENIED);
        }
    }
}
 

开发者ID:kiegroup,
项目名称:appformer,
代码行数:23,
代码来源:PermissionTreeTest.java

示例4: testDefaultValues

点赞 3

import org.jboss.errai.security.shared.api.RoleImpl; //导入依赖的package包/类
@Test
public void testDefaultValues() {
    reset(view);

    permissionManager.setAuthorizationPolicy(permissionManager.newAuthorizationPolicy().build());
    presenter = new ACLSettings(view,
                                permissionManager,
                                homePerspectiveDropDown,
                                perspectiveTreeProvider,
                                priorityDropDown,
                                homePerspectiveChangedEvent,
                                priorityChangedEvent);

    presenter.show(new RoleImpl("admin"));

    verify(view).setHomePerspectiveSelectorEnabled(false);
    verify(view).setPrioritySelectorEnabled(false);
    verify(view).setHomePerspectiveSelector(any());
    verify(view).setPrioritySelector(any());
    verify(view).setHomePerspectiveName("DefaultPerspective");
    verify(view).setHomePerspectiveTitle("DefaultPerspective");
    verify(view).setPriorityName("Very Low");
}
 

开发者ID:kiegroup,
项目名称:appformer,
代码行数:24,
代码来源:ACLSettingsTest.java

示例5: testOnOnUserRolesUpdatedEvent

点赞 3

import org.jboss.errai.security.shared.api.RoleImpl; //导入依赖的package包/类
@Test
public void testOnOnUserRolesUpdatedEvent() {
    OnUpdateUserRolesEvent onUpdateUserRolesEvent = mock(OnUpdateUserRolesEvent.class);
    when(onUpdateUserRolesEvent.getContext()).thenReturn(userAssignedRolesEditor);
    final Set<Role> explorerRoles = new HashSet<Role>();
    when(userAssignedRolesExplorer.getValue()).thenReturn(explorerRoles);
    final Set<Role> roles = new HashSet<Role>();
    roles.add(new RoleImpl("role1"));
    when(userAssignedRolesEditor.getValue()).thenReturn(roles);
    presenter.onOnUserRolesUpdatedEvent(onUpdateUserRolesEvent);
    assertEquals(roles,
                 userAssignedRolesExplorer.getValue());
    verify(userAssignedRolesEditor,
           times(1)).flush();
    verify(userAssignedRolesExplorer,
           times(1)).doShow();
    assertNoViewCalls();
}
 

开发者ID:kiegroup,
项目名称:appformer,
代码行数:19,
代码来源:UserEditorTest.java

示例6: setUp

点赞 3

import org.jboss.errai.security.shared.api.RoleImpl; //导入依赖的package包/类
@Before
public void setUp() {
    when(user.getRoles()).thenReturn(Collections.singleton(new RoleImpl("admin")));

    menus = newTopLevelMenu("Group1")
            .withPermission("group1")
            .withItems(Arrays.asList(
                    newSimpleItem("Perspective 1").perspective("perspective1").endMenu().build().getItems().get(0),
                    newSimpleItem("Perspective 2").perspective("perspective2").endMenu().build().getItems().get(0)
            ))
            .endMenu().build();

    permissionManager = new DefaultPermissionManager();
    authorizationManager = new DefaultAuthorizationManager(permissionManager);
    authzVisitor = spy(new AuthFilterMenuVisitor(authorizationManager,
                                                 user,
                                                 menuVisitor));
}
 

开发者ID:kiegroup,
项目名称:appformer,
代码行数:19,
代码来源:MenuBuilderAuthzTest.java

示例7: gwtSetUp

点赞 3

import org.jboss.errai.security.shared.api.RoleImpl; //导入依赖的package包/类
@Override
protected void gwtSetUp() throws Exception {
    MarshallerFramework.initializeDefaultSessionProvider();

    // because UberFire uses @Inject User, the only way we can set the current user is by putting this
    // cookie in place before the GWT modules get bootstrapped (so before super.gwtSetUp())
    Collection<? extends Role> roles = Arrays.asList(new RoleImpl("admin"));
    admin = new UserImpl("admin",
                         roles);
    Cookies.setCookie(UserCookieEncoder.USER_COOKIE_NAME,
                      UserCookieEncoder.toCookieValue(admin));

    super.gwtSetUp();
    placeManager = IOC.getBeanManager().lookupBean(PlaceManager.class).getInstance();
    securityContext = IOC.getBeanManager().lookupBean(SecurityContext.class).getInstance();
}
 

开发者ID:kiegroup,
项目名称:appformer,
代码行数:17,
代码来源:MenuAuthorizationTest.java

示例8: testSetContent_Administrator

点赞 3

import org.jboss.errai.security.shared.api.RoleImpl; //导入依赖的package包/类
@Test
public void testSetContent_Administrator() {
    final GAV gav = mock(GAV.class);
    final Command command = mock(Command.class);

    final Set<MavenRepositoryMetadata> metadata = new HashSet<MavenRepositoryMetadata>();
    final Set<Role> roles = new HashSet<Role>() {{
        add(new RoleImpl(AppRoles.ADMIN.getName()));
    }};
    when(user.getRoles()).thenReturn(roles);

    presenter.setContent(gav,
                         metadata,
                         command);

    verify(view,
           times(1)).clear();
    verify(view,
           times(1)).setContent(eq(gav),
                                eq(metadata));
    verify(view,
           times(1)).addOKButton();
    verify(view,
           times(1)).addOverrideButton(any(Command.class));
}
 

开发者ID:kiegroup,
项目名称:appformer,
代码行数:26,
代码来源:ConflictingRepositoriesPopupTest.java

示例9: getUser

点赞 2

import org.jboss.errai.security.shared.api.RoleImpl; //导入依赖的package包/类
private User getUser(Authentication auth) {
    Collection<? extends GrantedAuthority> authorities = auth.getAuthorities();
    ArrayList<RoleImpl> erraiRoles = new ArrayList<RoleImpl>(authorities.size());
    for (GrantedAuthority grantedAuthority : authorities) {
        erraiRoles.add(new RoleImpl(grantedAuthority.getAuthority().replace("ROLE_", "")));
    }
    User user = new UserImpl(auth.getName(), erraiRoles);
    return user;
}
 

开发者ID:expansel,
项目名称:errai-spring-server,
代码行数:10,
代码来源:SpringSecurityAuthenticationService.java

示例10: createUserMock

点赞 2

import org.jboss.errai.security.shared.api.RoleImpl; //导入依赖的package包/类
protected User createUserMock(String... roles) {
    User user = mock(User.class);
    Set<Role> roleSet = Stream.of(roles).map(RoleImpl::new).collect(Collectors.toSet());
    when(user.getIdentifier()).thenReturn(Integer.toString(user.hashCode()));
    when(user.getRoles()).thenReturn(roleSet);
    when(user.getGroups()).thenReturn(null);
    return user;
}
 

开发者ID:kiegroup,
项目名称:appformer,
代码行数:9,
代码来源:PermissionManagerTest.java

示例11: testResolvePermissionsTwoCustomRolesGranted

点赞 2

import org.jboss.errai.security.shared.api.RoleImpl; //导入依赖的package包/类
@Test
public void testResolvePermissionsTwoCustomRolesGranted() {

    final VotingStrategy priority = VotingStrategy.PRIORITY;
    final Role businessUserRole = new RoleImpl("business-user");
    final Role managerRole = new RoleImpl("manager");
    final Group directorGroup = new GroupImpl("director");

    // Users have a group with their names by default
    final User user = makeUser("director", directorGroup, businessUserRole, managerRole);

    mockDefaultPermissions(authorizationPolicy,
                           makeDeniedPermissionCollection());
    mockRolePermissions(authorizationPolicy,
                        makeDeniedPermissionCollection(),
                        businessUserRole,
                        0);
    mockRolePermissions(authorizationPolicy,
                        makeGrantedPermissionCollection(),
                        managerRole,
                        1);
    mockDefaultGroupPermissions(authorizationPolicy,
                                makeDeniedPermissionCollection(),
                                directorGroup);

    final PermissionCollection resolvedPermission = defaultPermissionManager.resolvePermissions(user, priority);
    final Permission permission = resolvedPermission.get(PERMISSION_NAME);

    assertEquals(AuthorizationResult.ACCESS_GRANTED, permission.getResult());
}
 

开发者ID:kiegroup,
项目名称:appformer,
代码行数:31,
代码来源:DefaultPermissionManagerTest.java

示例12: testResolvePermissionsTwoCustomRolesDenied

点赞 2

import org.jboss.errai.security.shared.api.RoleImpl; //导入依赖的package包/类
@Test
public void testResolvePermissionsTwoCustomRolesDenied() {

    final VotingStrategy priority = VotingStrategy.PRIORITY;
    final Role businessUserRole = new RoleImpl("business-user");
    final Role managerRole = new RoleImpl("manager");
    final Group directorGroup = new GroupImpl("director");

    // Users have a group with their names by default
    final User user = makeUser("director", directorGroup, businessUserRole, managerRole);

    mockDefaultPermissions(authorizationPolicy,
                           makeDeniedPermissionCollection());
    mockRolePermissions(authorizationPolicy,
                        makeDeniedPermissionCollection(),
                        businessUserRole,
                        1);
    mockRolePermissions(authorizationPolicy,
                        makeGrantedPermissionCollection(),
                        managerRole,
                        0);
    mockDefaultGroupPermissions(authorizationPolicy,
                                makeDeniedPermissionCollection(),
                                directorGroup);

    final PermissionCollection resolvedPermission = defaultPermissionManager.resolvePermissions(user, priority);
    final Permission permission = resolvedPermission.get(PERMISSION_NAME);

    assertEquals(AuthorizationResult.ACCESS_DENIED, permission.getResult());
}
 

开发者ID:kiegroup,
项目名称:appformer,
代码行数:31,
代码来源:DefaultPermissionManagerTest.java

示例13: testResolvePermissionsTwoCustomRolesSamePriority

点赞 2

import org.jboss.errai.security.shared.api.RoleImpl; //导入依赖的package包/类
@Test
public void testResolvePermissionsTwoCustomRolesSamePriority() {

    final VotingStrategy priority = VotingStrategy.PRIORITY;
    final Role businessUserRole = new RoleImpl("business-user");
    final Role managerRole = new RoleImpl("manager");
    final Group directorGroup = new GroupImpl("director");

    // Users have a group with their names by default
    final User user = makeUser("director", directorGroup, businessUserRole, managerRole);

    mockDefaultPermissions(authorizationPolicy,
                           makeDeniedPermissionCollection());
    mockRolePermissions(authorizationPolicy,
                        makeDeniedPermissionCollection(),
                        businessUserRole,
                        0);
    mockRolePermissions(authorizationPolicy,
                        makeGrantedPermissionCollection(),
                        managerRole,
                        0);
    mockDefaultGroupPermissions(authorizationPolicy,
                                makeDeniedPermissionCollection(),
                                directorGroup);

    final PermissionCollection resolvedPermission = defaultPermissionManager.resolvePermissions(user, priority);
    final Permission permission = resolvedPermission.get(PERMISSION_NAME);

    assertEquals(AuthorizationResult.ACCESS_GRANTED, permission.getResult());
}
 

开发者ID:kiegroup,
项目名称:appformer,
代码行数:31,
代码来源:DefaultPermissionManagerTest.java

示例14: createUserMock

点赞 2

import org.jboss.errai.security.shared.api.RoleImpl; //导入依赖的package包/类
protected User createUserMock(String... roles) {
    User user = mock(User.class);
    Set<Role> roleSet = Stream.of(roles).map(RoleImpl::new).collect(Collectors.toSet());
    when(user.getRoles()).thenReturn(roleSet);
    when(user.getGroups()).thenReturn(null);
    return user;
}
 

开发者ID:kiegroup,
项目名称:appformer,
代码行数:8,
代码来源:HomePerspectiveTest.java

示例15: testProjectsLoading

点赞 2

import org.jboss.errai.security.shared.api.RoleImpl; //导入依赖的package包/类
@Test
public void testProjectsLoading() {
    PermissionTree tree = permissionTreeFactory.createPermissionTree(new RoleImpl("admin"));
    PermissionNode rootNode = tree.getRootNodes().get(1);
    assertEquals(rootNode.getPermissionList().get(0).getResult(),
                 AuthorizationResult.ACCESS_GRANTED);
    assertEquals(rootNode.getPermissionList().get(1).getResult(),
                 AuthorizationResult.ACCESS_DENIED);
    assertEquals(rootNode.getPermissionList().get(2).getResult(),
                 AuthorizationResult.ACCESS_GRANTED);
    assertEquals(rootNode.getPermissionList().get(3).getResult(),
                 AuthorizationResult.ACCESS_GRANTED);

    rootNode.expand(children -> {
        assertEquals(children.size(),
                     1);
        PermissionNode projectNode = children.get(0);
        assertEquals(projectNode.getNodeName(),
                     "p1");
        assertEquals(projectNode.getPermissionList().size(),
                     3);
        assertEquals(projectNode.getPermissionList().get(0).getName(),
                     "project.read.p1");
        assertEquals(projectNode.getPermissionList().get(1).getName(),
                     "project.edit.p1");
        assertEquals(projectNode.getPermissionList().get(2).getName(),
                     "project.delete.p1");
        assertEquals(projectNode.getPermissionList().get(0).getResult(),
                     AuthorizationResult.ACCESS_GRANTED);
        assertEquals(projectNode.getPermissionList().get(1).getResult(),
                     AuthorizationResult.ACCESS_DENIED);
        assertEquals(projectNode.getPermissionList().get(2).getResult(),
                     AuthorizationResult.ACCESS_DENIED);
    });
}
 

开发者ID:kiegroup,
项目名称:appformer,
代码行数:36,
代码来源:PermissionTreeTest.java

示例16: testGetRegisteredRoles

点赞 2

import org.jboss.errai.security.shared.api.RoleImpl; //导入依赖的package包/类
@Test
public void testGetRegisteredRoles() {
    RoleRegistry.get().registerRole("role1");
    RoleRegistry.get().registerRole("role2");
    final Set<Role> roles = SecurityManagementUtils.getRegisteredRoles();
    assertNotNull(roles);
    assertTrue(roles.size() == 2);
    assertFalse(roles.contains(new RoleImpl("admin")));
}
 

开发者ID:kiegroup,
项目名称:appformer,
代码行数:10,
代码来源:SecurityManagementUtilsTest.java

示例17: testShowRole

点赞 2

import org.jboss.errai.security.shared.api.RoleImpl; //导入依赖的package包/类
@Test
public void testShowRole() {
    presenter.show(new RoleImpl("admin"));

    verify(view).setHomePerspectiveSelectorEnabled(false);
    verify(view).setPrioritySelectorEnabled(false);
    verify(view).setHomePerspectiveSelector(any());
    verify(view).setPrioritySelector(any());
    verify(view).setHomePerspectiveName("HomeAdmin");
    verify(view).setHomePerspectiveTitle("HomeAdmin");
    verify(view).setPriorityName("High");
}
 

开发者ID:kiegroup,
项目名称:appformer,
代码行数:13,
代码来源:ACLSettingsTest.java

示例18: testEditRole

点赞 2

import org.jboss.errai.security.shared.api.RoleImpl; //导入依赖的package包/类
@Test
public void testEditRole() {
    presenter.edit(new RoleImpl("admin"));

    verify(view).setHomePerspectiveSelectorEnabled(true);
    verify(view).setPrioritySelectorEnabled(true);
    verify(view).setHomePerspectiveSelector(any());
    verify(view).setPrioritySelector(any());
    verify(homePerspectiveDropDown).setSelectedPerspective("HomeAdmin");
    verify(priorityDropDown).setSelectedPriority(10);
}
 

开发者ID:kiegroup,
项目名称:appformer,
代码行数:12,
代码来源:ACLSettingsTest.java

示例19: getUser

点赞 2

import org.jboss.errai.security.shared.api.RoleImpl; //导入依赖的package包/类
private User getUser() {
    try {
        return authenticationService.getUser();
    } catch (final IllegalStateException ex) {
        return new UserImpl("system",
                            asList(new RoleImpl("admin")));
    }
}
 

开发者ID:kiegroup,
项目名称:appformer,
代码行数:9,
代码来源:IOSecurityService.java

示例20: testLogin

点赞 2

import org.jboss.errai.security.shared.api.RoleImpl; //导入依赖的package包/类
@Test
public void testLogin() throws Exception {

    RoleRegistry.get().registerRole("admin");
    RoleRegistry.get().registerRole("role1");
    Set<Principal> principals = mockPrincipals("admin",
                                               "role1",
                                               "group1",
                                               null);
    Subject subject = new Subject();
    subject.getPrincipals().addAll(principals);
    doReturn(subject).when(tested).getSubjectFromPolicyContext();

    User user = tested.login(USERNAME,
                             PASSWORD);

    assertNotNull(user);
    assertEquals(USERNAME,
                 user.getIdentifier());
    assertEquals(2,
                 user.getRoles().size());
    assertTrue(user.getRoles().contains(new RoleImpl("admin")));
    assertTrue(user.getRoles().contains(new RoleImpl("role1")));
    assertEquals(1,
                 user.getGroups().size());
    assertTrue(user.getGroups().contains(new GroupImpl("group1")));
}
 

开发者ID:kiegroup,
项目名称:appformer,
代码行数:28,
代码来源:ServletSecurityAuthenticationServiceTest.java

示例21: testLoginSubjectGroups

点赞 2

import org.jboss.errai.security.shared.api.RoleImpl; //导入依赖的package包/类
@Test
public void testLoginSubjectGroups() throws Exception {
    String username = "user1";
    String password = "password1";
    RoleRegistry.get().registerRole("admin");
    RoleRegistry.get().registerRole("role1");
    Set<Principal> principals = mockPrincipals("admin",
                                               "role1",
                                               "group1");
    Group aclGroup = mock(Group.class);
    doReturn(ServletSecurityAuthenticationService.DEFAULT_ROLE_PRINCIPLE_NAME).when(aclGroup).getName();
    Set<Principal> aclGroups = mockPrincipals("g1",
                                              "g2");
    Enumeration<? extends Principal> aclGroupsEnum = Collections.enumeration(aclGroups);
    doReturn(aclGroupsEnum).when(aclGroup).members();
    Subject subject = new Subject();
    subject.getPrincipals().addAll(principals);
    subject.getPrincipals().add(aclGroup);
    doReturn(subject).when(tested).getSubjectFromPolicyContext();

    User user = tested.login(username,
                             password);

    assertNotNull(user);
    assertEquals(username,
                 user.getIdentifier());
    assertEquals(2,
                 user.getRoles().size());
    assertTrue(user.getRoles().contains(new RoleImpl("admin")));
    assertTrue(user.getRoles().contains(new RoleImpl("role1")));
    assertEquals(3,
                 user.getGroups().size());
    assertTrue(user.getGroups().contains(new GroupImpl("group1")));
    assertTrue(user.getGroups().contains(new GroupImpl("g1")));
    assertTrue(user.getGroups().contains(new GroupImpl("g2")));
}
 

开发者ID:kiegroup,
项目名称:appformer,
代码行数:37,
代码来源:ServletSecurityAuthenticationServiceTest.java

示例22: testLogin

点赞 2

import org.jboss.errai.security.shared.api.RoleImpl; //导入依赖的package包/类
@Test
public void testLogin() throws Exception {
    String username = "user1";
    String password = "password1";

    Set<Principal> principals = mockPrincipals( "admin",
                                                "role1",
                                                "group1" );
    Subject subject = new Subject();
    subject.getPrincipals().addAll( principals );
    LoginContext loginContext = mock( LoginContext.class );
    when( loginContext.getSubject() ).thenReturn( subject );
    doReturn( loginContext ).when( tested ).createLoginContext( anyString(),
                                                                anyString() );

    User user = tested.login( username,
                              password );

    assertNotNull( user );
    assertEquals( username,
                  user.getIdentifier() );
    assertEquals( 2,
                  user.getRoles().size() );
    assertTrue( user.getRoles().contains( new RoleImpl( "admin" ) ) );
    assertTrue( user.getRoles().contains( new RoleImpl( "role1" ) ) );
    assertEquals( 1,
                  user.getGroups().size() );
    assertTrue( user.getGroups().contains( new GroupImpl( "group1" ) ) );
}
 

开发者ID:kiegroup,
项目名称:appformer,
代码行数:30,
代码来源:JAASAuthenticationServiceTest.java

示例23: testLoginSubjectGroups

点赞 2

import org.jboss.errai.security.shared.api.RoleImpl; //导入依赖的package包/类
@Test
public void testLoginSubjectGroups() throws Exception {
    String username = "user1";
    String password = "password1";

    Set<Principal> principals = mockPrincipals( "admin",
                                                "role1",
                                                "group1" );
    Group aclGroup = mock( Group.class );
    doReturn( JAASAuthenticationService.DEFAULT_ROLE_PRINCIPLE_NAME ).when( aclGroup ).getName();
    Set<Principal> aclGroups = mockPrincipals( "g1",
                                               "g2" );
    Enumeration<? extends Principal> aclGroupsEnum = Collections.enumeration( aclGroups );
    doReturn( aclGroupsEnum ).when( aclGroup ).members();
    Subject subject = new Subject();
    subject.getPrincipals().addAll( principals );
    subject.getPrincipals().add( aclGroup );
    LoginContext loginContext = mock( LoginContext.class );
    when( loginContext.getSubject() ).thenReturn( subject );
    doReturn( loginContext ).when( tested ).createLoginContext( anyString(),
                                                                anyString() );

    User user = tested.login( username,
                              password );

    assertNotNull( user );
    assertEquals( username,
                  user.getIdentifier() );
    assertEquals( 2,
                  user.getRoles().size() );
    assertTrue( user.getRoles().contains( new RoleImpl( "admin" ) ) );
    assertTrue( user.getRoles().contains( new RoleImpl( "role1" ) ) );
    assertEquals( 3,
                  user.getGroups().size() );
    assertTrue( user.getGroups().contains( new GroupImpl( "group1" ) ) );
    assertTrue( user.getGroups().contains( new GroupImpl( "g1" ) ) );
    assertTrue( user.getGroups().contains( new GroupImpl( "g2" ) ) );
}
 

开发者ID:kiegroup,
项目名称:appformer,
代码行数:39,
代码来源:JAASAuthenticationServiceTest.java

示例24: makeTestUser

点赞 2

import org.jboss.errai.security.shared.api.RoleImpl; //导入依赖的package包/类
private User makeTestUser() {
    Collection<Role> roles = new ArrayList<Role>();
    roles.add(new RoleImpl("role-1"));

    Collection<Group> groups = new ArrayList<Group>();
    groups.add(new GroupImpl("group"));

    User user = new UserImpl("testing-user",
                             roles,
                             groups);
    return user;
}
 

开发者ID:kiegroup,
项目名称:appformer,
代码行数:13,
代码来源:UserCookieTest.java

示例25: testSetContent_Reuse

点赞 2

import org.jboss.errai.security.shared.api.RoleImpl; //导入依赖的package包/类
@Test
public void testSetContent_Reuse() {
    final GAV gav = mock(GAV.class);
    final Command command = mock(Command.class);

    final Set<MavenRepositoryMetadata> metadata = new HashSet<MavenRepositoryMetadata>();
    final Set<Role> roles = new HashSet<Role>() {{
        add(new RoleImpl(AppRoles.ADMIN.getName()));
    }};
    when(user.getRoles()).thenReturn(roles);

    presenter.setContent(gav,
                         metadata,
                         command);

    verify(view,
           times(1)).clear();
    verify(view,
           times(1)).setContent(eq(gav),
                                eq(metadata));
    verify(view,
           times(1)).addOKButton();
    verify(view,
           times(1)).addOverrideButton(any(Command.class));

    //Re-use
    presenter.setContent(gav,
                         metadata,
                         command);
    verify(view,
           times(2)).clear();
    verify(view,
           times(2)).setContent(eq(gav),
                                eq(metadata));
    verify(view,
           times(2)).addOKButton();
    verify(view,
           times(2)).addOverrideButton(any(Command.class));
}
 

开发者ID:kiegroup,
项目名称:appformer,
代码行数:40,
代码来源:ConflictingRepositoriesPopupTest.java

示例26: testAdminPermissions

点赞 2

import org.jboss.errai.security.shared.api.RoleImpl; //导入依赖的package包/类
@Test
public void testAdminPermissions() {
    testPermissions(new RoleImpl("admin"),
                    null,
                    HOME_PERSPECTIVE,
                    ACCESS_GRANTED,
                    null);
}
 

开发者ID:kiegroup,
项目名称:kie-wb-distributions,
代码行数:9,
代码来源:WorkbenchACLTest.java

示例27: testAnalystPermissions

点赞 2

import org.jboss.errai.security.shared.api.RoleImpl; //导入依赖的package包/类
@Test
public void testAnalystPermissions() {
    testPermissions(new RoleImpl("analyst"),
                    ANALYST_DENIED,
                    HOME_PERSPECTIVE,
                    ACCESS_GRANTED,
                    ACCESS_DENIED);
}
 

开发者ID:kiegroup,
项目名称:kie-wb-distributions,
代码行数:9,
代码来源:WorkbenchACLTest.java

示例28: testDeveloperPermissions

点赞 2

import org.jboss.errai.security.shared.api.RoleImpl; //导入依赖的package包/类
@Test
public void testDeveloperPermissions() {
    testPermissions(new RoleImpl("developer"),
                    DEVELOPER_DENIED,
                    HOME_PERSPECTIVE,
                    ACCESS_GRANTED,
                    ACCESS_DENIED);
}
 

开发者ID:kiegroup,
项目名称:kie-wb-distributions,
代码行数:9,
代码来源:WorkbenchACLTest.java

示例29: testManagerPermissions

点赞 2

import org.jboss.errai.security.shared.api.RoleImpl; //导入依赖的package包/类
@Test
public void testManagerPermissions() {
    testPermissions(new RoleImpl("manager"),
                    MANAGER_GRANTED,
                    HOME_PERSPECTIVE,
                    ACCESS_DENIED,
                    ACCESS_GRANTED);
}
 

开发者ID:kiegroup,
项目名称:kie-wb-distributions,
代码行数:9,
代码来源:WorkbenchACLTest.java

示例30: testUserPermissions

点赞 2

import org.jboss.errai.security.shared.api.RoleImpl; //导入依赖的package包/类
@Test
public void testUserPermissions() {
    testPermissions(new RoleImpl("user"),
                    USER_GRANTED,
                    HOME_PERSPECTIVE,
                    ACCESS_DENIED,
                    ACCESS_GRANTED);
}
 

开发者ID:kiegroup,
项目名称:kie-wb-distributions,
代码行数:9,
代码来源:WorkbenchACLTest.java

示例31: testProcessAdminPermissions

点赞 2

import org.jboss.errai.security.shared.api.RoleImpl; //导入依赖的package包/类
@Test
public void testProcessAdminPermissions() {
    testPermissions(new RoleImpl("process-admin"),
                    PROCESS_ADMIN_GRANTED,
                    HOME_PERSPECTIVE,
                    ACCESS_DENIED,
                    ACCESS_GRANTED);
}
 

开发者ID:kiegroup,
项目名称:kie-wb-distributions,
代码行数:9,
代码来源:WorkbenchACLTest.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)