use of io.jans.ca.rs.protect.RsResourceList in project jans by JanssenProject.
the class ApiProtectionService method verifyResources.
public void verifyResources(String apiProtectionType, String clientId) throws IOException {
log.debug("ApiProtectionService::verifyResources() - apiProtectionType:{}, clientId:{}, configurationFactory:{} ", apiProtectionType, clientId, configurationFactory);
// Load the resource json
ClassLoader loader = Thread.currentThread().getContextClassLoader();
InputStream inputStream = loader.getResourceAsStream(PROTECTION_CONFIGURATION_FILE_NAME);
RsResourceList resourceList = Jackson.createJsonMapper().readValue(inputStream, RsResourceList.class);
this.rsResourceList = resourceList.getResources();
log.debug("verifyResources() - rsResourceList{} ", rsResourceList);
Preconditions.checkNotNull(rsResourceList, "Config Api Resource list cannot be null !!!");
createScopeIfNeeded(apiProtectionType);
log.trace("ApiProtectionService:::verifyResources() - allScopes:{}, allResources:{} ", ApiProtectionCache.getAllScopes(), ApiProtectionCache.getAllResources());
updateScopeForClientIfNeeded(clientId);
}
use of io.jans.ca.rs.protect.RsResourceList in project jans by JanssenProject.
the class OpClientFactoryMockImpl method getIdMap.
private static Map<Key, String> getIdMap(String rsProtect) {
Map<Key, String> rsIdMap = new HashMap<>();
try {
rsProtect = StringUtils.replace(rsProtect, "'", "\"");
RsResourceList rsResourceList = Jackson2.createJsonMapper().readValue(rsProtect, RsResourceList.class);
for (RsResource rsResource : rsResourceList.getResources()) {
for (Condition condition : rsResource.getConditions()) {
Key key = new Key();
key.setHttpMethods(condition.getHttpMethods());
key.setPath(rsResource.getPath());
rsIdMap.put(key, UUID.randomUUID().toString());
}
}
} catch (Exception e) {
LOG.error("Failed to parse uma-rs-protect resource json .", e);
}
return rsIdMap;
}
use of io.jans.ca.rs.protect.RsResourceList in project jans by JanssenProject.
the class OpClientFactoryMockImpl method getResourceMap.
private static Map<Key, RsResource> getResourceMap(String rsProtect) {
Map<Key, RsResource> rsResourceMap = new HashMap<>();
try {
rsProtect = StringUtils.replace(rsProtect, "'", "\"");
RsResourceList rsResourceList = Jackson2.createJsonMapper().readValue(rsProtect, RsResourceList.class);
for (RsResource rsResource : rsResourceList.getResources()) {
for (Condition condition : rsResource.getConditions()) {
Key key = new Key();
key.setHttpMethods(condition.getHttpMethods());
key.setPath(rsResource.getPath());
rsResourceMap.put(key, rsResource);
}
}
} catch (Exception e) {
LOG.error("Failed to parse uma-rs-protect resource json .", e);
}
return rsResourceMap;
}
Aggregations