forked from apache/atlas
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3612 from atlanhq/plt-2622-upgrade-zk
PLT-2622 : Upgrade zookepeer to 3.5.5 from 3.4.6 to fix zookeper-jute unavailable during build
- Loading branch information
Showing
8 changed files
with
124 additions
and
14 deletions.
There are no files selected for viewing
76 changes: 76 additions & 0 deletions
76
...ents-common/src/main/java/org/apache/atlas/plugin/conditionevaluator/AtlanHasAnyRole.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.apache.atlas.plugin.conditionevaluator; | ||
|
||
import org.apache.atlas.plugin.policyengine.RangerAccessRequest; | ||
import org.apache.commons.collections.CollectionUtils; | ||
import org.apache.commons.logging.Log; | ||
import org.apache.commons.logging.LogFactory; | ||
|
||
import java.util.HashSet; | ||
import java.util.Objects; | ||
import java.util.Set; | ||
|
||
public class AtlanHasAnyRole extends RangerAbstractConditionEvaluator { | ||
private static final Log LOG = LogFactory.getLog(AtlanHasAnyRole.class); | ||
|
||
protected Set<String> excludedRoles = new HashSet<>(); | ||
|
||
@Override | ||
public void init() { | ||
if (LOG.isDebugEnabled()) { | ||
LOG.debug("==> AtlanHasAnyRole.init(" + condition + ")"); | ||
} | ||
|
||
super.init(); | ||
|
||
if (condition != null ) { | ||
for (String value : condition.getValues()) { | ||
excludedRoles.add(value.trim()); | ||
} | ||
} | ||
|
||
if (LOG.isDebugEnabled()) { | ||
LOG.debug("<== AtlanHasAnyRole.init(" + condition + ")"); | ||
} | ||
} | ||
|
||
@Override | ||
public boolean isMatched(RangerAccessRequest request) { | ||
if (LOG.isDebugEnabled()) { | ||
LOG.debug("==> AtlanHasAnyRole.isMatched(" + condition + ")"); | ||
} | ||
|
||
boolean ret = false; | ||
|
||
RangerAccessRequest readOnlyRequest = request.getReadOnlyCopy(); | ||
Set<String> currentRoles = ((Set<String>) readOnlyRequest.getContext().get("token:ROLES")); | ||
|
||
if (CollectionUtils.isNotEmpty(currentRoles)) { | ||
ret = !excludedRoles.stream().anyMatch(excludedRole -> currentRoles.stream().anyMatch(x -> Objects.equals(x, excludedRole))); | ||
} | ||
|
||
if (LOG.isDebugEnabled()) { | ||
LOG.debug("<== AtlanHasAnyRole.isMatched(" + condition + "): " + ret); | ||
} | ||
|
||
return ret; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters