use of io.jans.ca.rs.protect.resteasy.Key in project jans by JanssenProject.
the class RsProtectOperation method persist.
private void persist(ResourceRegistrar registrar, Rp rp) throws IOException {
Map<Key, RsResource> resourceMapCopy = registrar.getResourceMapCopy();
for (Map.Entry<Key, String> entry : registrar.getIdMapCopy().entrySet()) {
UmaResource resource = new UmaResource();
resource.setId(entry.getValue());
resource.setPath(entry.getKey().getPath());
resource.setHttpMethods(entry.getKey().getHttpMethods());
Set<String> scopes = Sets.newHashSet();
Set<String> scopesForTicket = Sets.newHashSet();
Set<String> scopeExpressions = Sets.newHashSet();
RsResource rsResource = resourceMapCopy.get(entry.getKey());
for (String httpMethod : entry.getKey().getHttpMethods()) {
List<String> rsScopes = rsResource.scopes(httpMethod);
if (rsScopes != null) {
scopes.addAll(rsScopes);
}
scopesForTicket.addAll(rsResource.getScopesForTicket(httpMethod));
JsonNode scopeExpression = rsResource.getScopeExpression(httpMethod);
if (scopeExpression != null) {
scopeExpressions.add(scopeExpression.toString());
}
}
resource.setScopes(Lists.newArrayList(scopes));
resource.setTicketScopes(Lists.newArrayList(scopesForTicket));
resource.setScopeExpressions(Lists.newArrayList(scopeExpressions));
if (rsResource.getIat() != null && rsResource.getIat() > 0) {
resource.setIat(rsResource.getIat());
}
if (rsResource.getExp() != null && rsResource.getExp() > 0) {
resource.setExp(rsResource.getExp());
}
rp.getUmaProtectedResources().add(resource);
}
getRpService().update(rp);
}
Aggregations