forked from Sunbird-RC/sunbird-rc-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Sunbird-RC#13 from kesavanp123/generic/apis
Generic/apis
- Loading branch information
Showing
30 changed files
with
651 additions
and
323 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
java/claim/src/main/java/io/opensaber/claim/service/ClaimsAuthorizer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package io.opensaber.claim.service; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import io.opensaber.claim.entity.Claim; | ||
import io.opensaber.registry.middleware.service.ConditionResolverService; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.Collections; | ||
|
||
@Service | ||
public class ClaimsAuthorizer { | ||
|
||
private static final String ATTESTOR = "ATTESTOR"; | ||
|
||
@Autowired | ||
private ConditionResolverService conditionResolverService; | ||
|
||
public boolean isAuthorized(Claim claim, JsonNode attestorNode) { | ||
String resolvedCondition = conditionResolverService.resolve( | ||
attestorNode, | ||
ATTESTOR, | ||
claim.getConditions(), | ||
Collections.emptyList() | ||
); | ||
return conditionResolverService.evaluate(resolvedCondition); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.