@Override public Authorizer getAuthorizer(String name) { return (authenticationResult, resource, action) -> new Access(true); } };
@Override public Access authorize(AuthenticationResult authenticationResult1, Resource resource, Action action) { return new Access(authCheckResult); }
@Override public Access authorize(AuthenticationResult authenticationResult, Resource resource, Action action) { if (authenticationResult == null) { throw new IAE("WTF? authenticationResult should never be null."); } Map<String, BasicAuthorizerUser> userMap = cacheManager.getUserMap(name); if (userMap == null) { throw new IAE("Could not load userMap for authorizer [%s]", name); } Map<String, BasicAuthorizerRole> roleMap = cacheManager.getRoleMap(name); if (roleMap == null) { throw new IAE("Could not load roleMap for authorizer [%s]", name); } BasicAuthorizerUser user = userMap.get(authenticationResult.getIdentity()); if (user == null) { return new Access(false); } for (String roleName : user.getRoles()) { BasicAuthorizerRole role = roleMap.get(roleName); for (BasicAuthorizerPermission permission : role.getPermissions()) { if (permissionCheck(resource, action, permission)) { return new Access(true); } } } return new Access(false); }
@Override public Authorizer getAuthorizer(String name) { return (authenticationResult, resource, action) -> { if (authenticationResult.getIdentity().equals("druid")) { return Access.OK; } else { if (resource.getName().equals("datasource2")) { return new Access(false, "not authorized."); } else { return Access.OK; } } }; } }
@Override public Authorizer getAuthorizer(String name) { return (authenticationResult, resource, action) -> { if (authenticationResult.getIdentity().equals(TEST_SUPERUSER_NAME)) { return Access.OK; } if (resource.getType() == ResourceType.DATASOURCE && resource.getName().equals(FORBIDDEN_DATASOURCE)) { return new Access(false); } else { return Access.OK; } }; } };
@Override public Access authorize( AuthenticationResult authenticationResult, Resource resource, Action action ) { if (authenticationResult == null) { throw new IAE("WTF? authenticationResult should never be null."); } Map<String, BasicAuthorizerUser> userMap = cacheManager.getUserMap(name); if (userMap == null) { throw new IAE("Could not load userMap for authorizer [%s]", name); } Map<String, BasicAuthorizerRole> roleMap = cacheManager.getRoleMap(name); if (roleMap == null) { throw new IAE("Could not load roleMap for authorizer [%s]", name); } BasicAuthorizerUser user = userMap.get(authenticationResult.getIdentity()); if (user == null) { return new Access(false); } for (String roleName : user.getRoles()) { BasicAuthorizerRole role = roleMap.get(roleName); for (BasicAuthorizerPermission permission : role.getPermissions()) { if (permissionCheck(resource, action, permission)) { return new Access(true); } } } return new Access(false); }