|
@@ -17,12 +17,14 @@
|
|
|
|
|
|
package org.hswebframework.web.authorization;
|
|
|
|
|
|
+import lombok.NonNull;
|
|
|
import org.hswebframework.web.authorization.access.DataAccessConfig;
|
|
|
import org.hswebframework.web.authorization.access.FieldFilterDataAccessConfig;
|
|
|
import org.hswebframework.web.authorization.access.ScopeDataAccessConfig;
|
|
|
|
|
|
import java.io.Serializable;
|
|
|
import java.util.Collections;
|
|
|
+import java.util.Objects;
|
|
|
import java.util.Optional;
|
|
|
import java.util.Set;
|
|
|
import java.util.function.Predicate;
|
|
@@ -140,7 +142,7 @@ public interface Permission extends Serializable {
|
|
|
*/
|
|
|
default Set<String> findDenyFields(String action) {
|
|
|
return findFieldFilter(action)
|
|
|
- .filter(conf -> conf.getType().equals(DENY_FIELDS))
|
|
|
+ .filter(conf -> DENY_FIELDS.equals(conf.getType()))
|
|
|
.map(FieldFilterDataAccessConfig::getFields)
|
|
|
.orElseGet(Collections::emptySet);
|
|
|
}
|
|
@@ -173,11 +175,15 @@ public interface Permission extends Serializable {
|
|
|
* @return {@link DataAccessPredicate}
|
|
|
*/
|
|
|
static Permission.DataAccessPredicate<ScopeDataAccessConfig> scope(String action, String type, String scopeType) {
|
|
|
+ Objects.requireNonNull(action, "action can not be null");
|
|
|
+ Objects.requireNonNull(type, "type can not be null");
|
|
|
+ Objects.requireNonNull(scopeType, "scopeType can not be null");
|
|
|
+
|
|
|
return config ->
|
|
|
config instanceof ScopeDataAccessConfig
|
|
|
- && config.getAction().equals(action)
|
|
|
- && config.getType().equals(type)
|
|
|
- && ((ScopeDataAccessConfig) config).getScopeType().equals(scopeType);
|
|
|
+ && action.equals(config.getAction())
|
|
|
+ && type.equals(config.getType())
|
|
|
+ && scopeType.equals(((ScopeDataAccessConfig) config).getScopeType());
|
|
|
}
|
|
|
|
|
|
|