use of com.mendmix.security.model.ApiPermission in project jeesuite-libs by vakinge.
the class SecurityResourceManager method loadApiPermissions.
public synchronized boolean loadApiPermissions() {
List<ApiPermission> permissions = decisionProvider.getAllApiPermissions();
if (permissions == null)
return false;
List<String> _authzUris = new ArrayList<>();
List<Pattern> _authzPatterns = new ArrayList<>();
List<String> _anonUris = new ArrayList<>();
List<Pattern> _anonUriPatterns = new ArrayList<>();
// 所有无通配符uri
List<String> _nonWildcardUris = new ArrayList<>();
boolean withWildcard;
String permissionKey;
Pattern pattern;
for (ApiPermission permission : permissions) {
withWildcard = permission.getUri().contains(ApiPermssionCheckHelper.WILDCARD_START);
permissionKey = ApiPermssionCheckHelper.buildPermissionKey(permission.getHttpMethod(), permission.getUri());
if (!withWildcard) {
_nonWildcardUris.add(permissionKey);
}
if (PermissionLevel.PermissionRequired.name().equals(permission.getGrantType())) {
if (withWildcard) {
pattern = Pattern.compile(ApiPermssionCheckHelper.pathVariableToPattern(permissionKey));
_authzPatterns.add(pattern);
} else {
_authzUris.add(permissionKey);
}
} else if (PermissionLevel.Anonymous.name().equals(permission.getGrantType())) {
if (withWildcard) {
pattern = Pattern.compile(ApiPermssionCheckHelper.pathVariableToPattern(permissionKey));
_anonUriPatterns.add(pattern);
} else {
_anonUris.add(permissionKey);
}
}
}
nonWildcardUris.set(_nonWildcardUris);
anonUris.set(_anonUris);
anonUriPatterns.set(_anonUriPatterns);
authzUris.set(_authzUris);
authzPatterns.set(_authzPatterns);
if (logging) {
log.info("nonWildcardUris: {}", getNonWildcardUris());
log.info("anonUris: {}", getAnonUris());
log.info("anonUriPatterns: {}", getAnonUriPatterns());
log.info("authzUris: {}", getAuthzUris());
log.info("authzPatterns: {}", getAuthzPatterns());
logging = false;
}
return true;
}
use of com.mendmix.security.model.ApiPermission in project jeesuite-libs by vakinge.
the class GatewaySecurityDecisionProvider method getAllApiPermissions.
@Override
public List<ApiPermission> getAllApiPermissions() {
Collection<BizSystemModule> modules = CurrentSystemHolder.getModules();
List<ApiPermission> result = new ArrayList<>();
Collection<ApiInfo> apis;
ApiPermission apiPermission;
for (BizSystemModule module : modules) {
if (module.getApiInfos() == null)
continue;
apis = module.getApiInfos().values();
for (ApiInfo apiInfo : apis) {
apiPermission = new ApiPermission();
apiPermission.setGrantType(apiInfo.getPermissionType().name());
apiPermission.setHttpMethod(apiInfo.getMethod());
apiPermission.setUri(apiInfo.getUrl());
result.add(apiPermission);
}
}
return result;
}
Aggregations