Skip to content

Commit

Permalink
Minor code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
rnavagamuwa committed Apr 4, 2019
1 parent 3c32ed7 commit 128423f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
6 changes: 2 additions & 4 deletions sample/src/main/resources/xacmlPolicy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@
<AttributeValue DataType="http:https://www.w3.org/2001/XMLSchema#string">read</AttributeValue>
<AttributeDesignator AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id"
Category="urn:oasis:names:tc:xacml:3.0:attribute-category:action"
DataType="http:https://www.w3.org/2001/XMLSchema#string" MustBePresent="true">
</AttributeDesignator>
DataType="http:https://www.w3.org/2001/XMLSchema#string" MustBePresent="true"/>
</Match>
</AllOf>
</AnyOf>
</Target>
<Rule Effect="Permit" RuleId="permit">
</Rule>
<Rule Effect="Permit" RuleId="permit"/>
</Policy>
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,12 @@ public boolean authorize(String authRequest) {
if (response.getStatusCode() != HttpStatus.OK) {
return false;
}

cachedResponse = response.getBody().toString();
this.authCache.putIfAbsent(authRequest, cachedResponse);
if (response.getStatusCode() == HttpStatus.OK) {
this.authCache.putIfAbsent(authRequest, cachedResponse);
}

}

JSONObject responseObj = new JSONObject(cachedResponse);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public XacmlAuthRequestBuilder() {
@Override
public String createAuthRequest(String policyName, String jsonKeyValuePairs) {

Map<String, Object> templateData = generateFreemakeTemplateData(jsonKeyValuePairs);
Map<String, Object> templateData = generateFreemakerTemplateData(jsonKeyValuePairs);

String key = Base64.getEncoder().encodeToString(policyName
.concat(jsonKeyValuePairs)
Expand Down Expand Up @@ -82,7 +82,7 @@ public String createAuthRequest(String policyName, String jsonKeyValuePairs) {
return this.requestBuilderCache.putIfAbsent(key, xacmlRequest);
}

private Map<String, Object> generateFreemakeTemplateData(String jsonKeyValuePairs) {
private Map<String, Object> generateFreemakerTemplateData(String jsonKeyValuePairs) {
JSONObject jsonObject = new JSONObject(jsonKeyValuePairs.trim());

Iterator<String> keys = jsonObject.keys();
Expand Down

0 comments on commit 128423f

Please sign in to comment.