当前位置: 首页>>代码示例>>Java>>正文


Java AuthorizationResult类代码示例

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


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

示例1: checkPermission

import org.uberfire.security.authz.AuthorizationResult; //导入依赖的package包/类
@Override
public AuthorizationResult checkPermission(Permission permission,
                                           User user,
                                           VotingStrategy votingStrategy) {

    if (authorizationPolicy == null || permission == null) {
        return ACCESS_ABSTAIN;
    }
    AuthorizationResult result = cache.get(user,
                                           permission);
    if (result == null) {
        result = _checkPermission(permission,
                                  user,
                                  votingStrategy == null ? defaultVotingStrategy : votingStrategy);
        cache.put(user,
                  permission,
                  result);
    }
    return result;
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:21,代码来源:DefaultPermissionManager.java

示例2: _checkPermission

import org.uberfire.security.authz.AuthorizationResult; //导入依赖的package包/类
protected AuthorizationResult _checkPermission(Permission permission,
                                               User user,
                                               VotingStrategy votingStrategy) {

    if (VotingStrategy.PRIORITY.equals(votingStrategy)) {
        PermissionCollection userPermissions = resolvePermissions(user,
                                                                  VotingStrategy.PRIORITY);
        return _checkPermission(permission,
                                userPermissions);
    } else {
        List<AuthorizationResult> permList = _checkRoleAndGroupPermissions(permission,
                                                                           user);
        VotingAlgorithm votingAlgorithm = votingAlgorithmMap.get(votingStrategy);
        return votingAlgorithm.vote(permList);
    }
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:17,代码来源:DefaultPermissionManager.java

示例3: testCacheHits

import org.uberfire.security.authz.AuthorizationResult; //导入依赖的package包/类
@Test
public void testCacheHits() {
    User user = createUserMock("viewAll");
    permissionManager.checkPermission(viewAll,
                                      user);
    permissionManager.checkPermission(viewAll,
                                      user);
    permissionManager.checkPermission(viewAll,
                                      user);
    permissionManager.checkPermission(viewAll,
                                      user);
    verify(permissionManager,
           times(1)).resolvePermissions(user,
                                        VotingStrategy.PRIORITY);
    verify(authzResultCache,
           times(1)).put(user,
                         viewAll,
                         AuthorizationResult.ACCESS_GRANTED);
    verify(authzResultCache,
           times(4)).get(user,
                         viewAll);
    assertEquals(authzResultCache.size(user),
                 1);
    assertEquals(authzResultCache.size(createUserMock()),
                 0);
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:27,代码来源:PermissionManagerTest.java

示例4: testResolvePermissionsCustomDeniedOverDefaultGranted

import org.uberfire.security.authz.AuthorizationResult; //导入依赖的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

示例5: testResolvePermissionsCustomGrantedOverDefaultDenied

import org.uberfire.security.authz.AuthorizationResult; //导入依赖的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

示例6: testMergeNoConflict

import org.uberfire.security.authz.AuthorizationResult; //导入依赖的package包/类
@Test
public void testMergeNoConflict() {
    PermissionCollection pc1 = new DefaultPermissionCollection();
    pc1.add(new DotNamedPermission("resource.read",
                                   true));
    pc1.add(new DotNamedPermission("resource.read.id1",
                                   false));

    PermissionCollection pc2 = new DefaultPermissionCollection();
    pc2.add(new DotNamedPermission("resource.read.id2",
                                   false));

    PermissionCollection result = pc1.merge(pc2,
                                            0);
    assertEquals(result.collection().size(),
                 2);
    assertEquals(result.get("resource.read").getResult(),
                 AuthorizationResult.ACCESS_GRANTED);
    assertEquals(result.get("resource.read.id1").getResult(),
                 AuthorizationResult.ACCESS_DENIED);
    assertNull(result.get("resource.read.id2"));
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:23,代码来源:PermissionCollectionTest.java

示例7: testMergeGrantWinsByDefault

import org.uberfire.security.authz.AuthorizationResult; //导入依赖的package包/类
@Test
public void testMergeGrantWinsByDefault() {
    PermissionCollection pc1 = new DefaultPermissionCollection();
    pc1.add(new DotNamedPermission("resource.read",
                                   true));
    pc1.add(new DotNamedPermission("resource.read.id1",
                                   false));

    PermissionCollection pc2 = new DefaultPermissionCollection();
    pc2.add(new DotNamedPermission("resource.read",
                                   true));

    PermissionCollection result = pc1.merge(pc2,
                                            0);
    assertEquals(result.collection().size(),
                 1);
    assertEquals(result.get("resource.read").getResult(),
                 AuthorizationResult.ACCESS_GRANTED);
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:20,代码来源:PermissionCollectionTest.java

示例8: testMergeGrantedWins

import org.uberfire.security.authz.AuthorizationResult; //导入依赖的package包/类
@Test
public void testMergeGrantedWins() {
    PermissionCollection pc1 = new DefaultPermissionCollection();
    pc1.add(new DotNamedPermission("resource.read.id1",
                                   false));

    PermissionCollection pc2 = new DefaultPermissionCollection();
    pc2.add(new DotNamedPermission("resource.read.id1",
                                   true));

    PermissionCollection result = pc1.merge(pc2,
                                            0);
    assertEquals(result.collection().size(),
                 1);
    assertEquals(result.get("resource.read.id1").getResult(),
                 AuthorizationResult.ACCESS_GRANTED);
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:18,代码来源:PermissionCollectionTest.java

示例9: testMergeThisWins

import org.uberfire.security.authz.AuthorizationResult; //导入依赖的package包/类
@Test
public void testMergeThisWins() {
    PermissionCollection pc1 = new DefaultPermissionCollection();
    pc1.add(new DotNamedPermission("resource.read.id1",
                                   false));

    PermissionCollection pc2 = new DefaultPermissionCollection();
    pc2.add(new DotNamedPermission("resource.read.id1",
                                   true));

    PermissionCollection result = pc1.merge(pc2,
                                            -1);
    assertEquals(result.collection().size(),
                 1);
    assertEquals(result.get("resource.read.id1").getResult(),
                 AuthorizationResult.ACCESS_DENIED);
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:18,代码来源:PermissionCollectionTest.java

示例10: testMergeOtherWins

import org.uberfire.security.authz.AuthorizationResult; //导入依赖的package包/类
@Test
public void testMergeOtherWins() {
    PermissionCollection pc1 = new DefaultPermissionCollection();
    pc1.add(new DotNamedPermission("resource.read.id1",
                                   true));

    PermissionCollection pc2 = new DefaultPermissionCollection();
    pc2.add(new DotNamedPermission("resource.read.id1",
                                   false));

    PermissionCollection result = pc1.merge(pc2,
                                            1);
    assertEquals(result.collection().size(),
                 1);
    assertEquals(result.get("resource.read.id1").getResult(),
                 AuthorizationResult.ACCESS_DENIED);
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:18,代码来源:PermissionCollectionTest.java

示例11: testOverwriteExisting

import org.uberfire.security.authz.AuthorizationResult; //导入依赖的package包/类
@Test
public void testOverwriteExisting() {
    PermissionCollection pc = new DefaultPermissionCollection();
    pc.add(new DotNamedPermission("resource.read",
                                  true));
    assertEquals(pc.collection().size(),
                 1);
    assertEquals(pc.get("resource.read").getResult(),
                 AuthorizationResult.ACCESS_GRANTED);

    pc.add(new DotNamedPermission("resource.read",
                                  false));
    assertEquals(pc.collection().size(),
                 1);
    assertEquals(pc.get("resource.read").getResult(),
                 AuthorizationResult.ACCESS_DENIED);
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:18,代码来源:PermissionCollectionTest.java

示例12: testInheritPermissionValue

import org.uberfire.security.authz.AuthorizationResult; //导入依赖的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

示例13: show

import org.uberfire.security.authz.AuthorizationResult; //导入依赖的package包/类
@Override
public void show(PermissionNode node) {
    permissionNode = node;

    String name = node.getNodeName();
    String fullName = node.getNodeFullName();

    view.setNodeName(name);
    if (fullName != null && !fullName.equals(name)) {
        view.setNodeFullName(fullName);
    }

    for (Permission permission : permissionNode.getPermissionList()) {

        if (AuthorizationResult.ACCESS_GRANTED.equals(permission.getResult())) {
            String granted = node.getPermissionGrantName(permission).toLowerCase();
            view.permissionGranted(granted);
        } else {
            String denied = node.getPermissionDenyName(permission).toLowerCase();
            view.permissionDenied(denied);
        }
    }
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:24,代码来源:LeafPermissionNodeViewer.java

示例14: processPermissionDependencies

import org.uberfire.security.authz.AuthorizationResult; //导入依赖的package包/类
/**
 * Updates any permission switch which has a dependency with the given permission.
 * @param permission The permission which dependencies needs to be revisited.
 */
protected void processPermissionDependencies(Permission permission) {
    List<Permission> dependencyList = this.getPermissionNode().getDependencies(permission);
    if (dependencyList != null) {
        PermissionSwitchToogle permissionSwitch = permissionSwitchMap.get(permission);
        for (Permission dep : dependencyList) {
            PermissionSwitchToogle depSwitch = permissionSwitchMap.get(dep);

            if (!permissionSwitch.isOn()) {
                dep.setResult(AuthorizationResult.ACCESS_DENIED);
                depSwitch.setOn(false);
                depSwitch.setEnabled(false);

                // Notify the dependant switch change
                this.notifyPermissionChange(dep,
                                            false);
            } else {
                depSwitch.setEnabled(true);
            }
        }
    }
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:26,代码来源:BasePermissionNodeEditor.java

示例15: isPerspectiveReadDenied

import org.uberfire.security.authz.AuthorizationResult; //导入依赖的package包/类
protected boolean isPerspectiveReadDenied(PerspectiveActivity perspectiveActivity) {
    if (perspectiveActivity == null) {
        return false;
    }
    PermissionCollection permissionCollection = groupEditor.permissions();
    if (permissionCollection == null) {
        return false;
    }
    Permission p = permissionManager.createPermission(perspectiveActivity,
                                                      PerspectiveAction.READ,
                                                      false);
    Permission existing = permissionCollection.get(p.getName());
    if (existing != null) {
        return existing.getResult().equals(AuthorizationResult.ACCESS_DENIED);
    }
    return permissionCollection.implies(p);
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:18,代码来源:GroupEditorWorkflow.java


注:本文中的org.uberfire.security.authz.AuthorizationResult类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。