generated from amosproj/amos202Xss0Y-projname
-
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.
Signed-off-by: Jannik Kiesel <jannik.kiesel@fau.de>
- Loading branch information
Showing
3 changed files
with
105 additions
and
0 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
...tity-backend/src/main/java/didentity/amos/digitalIdentity/controller/ProofController.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,44 @@ | ||
package didentity.amos.digitalIdentity.controller; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.ResponseBody; | ||
|
||
import didentity.amos.digitalIdentity.services.AuthenticationService; | ||
import didentity.amos.digitalIdentity.services.ProofService; | ||
|
||
@Controller | ||
@RequestMapping(path = "/proof") | ||
public class ProofController { | ||
|
||
@Autowired | ||
private AuthenticationService authenticationService; | ||
|
||
@Autowired | ||
private ProofService proofService; | ||
|
||
// TODO RequestParam image can be added | ||
@PostMapping(path = "/create") | ||
public @ResponseBody ResponseEntity<String> createProof( | ||
@RequestParam String requestedSelfAttestedAttributes, | ||
@RequestParam String revocationFilterType, | ||
@RequestParam String requestedAttributes, | ||
@RequestParam String name, | ||
@RequestParam String requestedPredicates, | ||
@RequestParam String requestedDeviceBindingVerifications, | ||
@RequestParam String version, | ||
@RequestParam String revocationFilterTimes, | ||
@RequestParam(required = false) String authorization) { | ||
|
||
if (authenticationService.authentication(authorization) == false) { | ||
return authenticationService.getError(); | ||
} | ||
|
||
return proofService.createProof(requestedSelfAttestedAttributes, revocationFilterType, requestedAttributes, name, requestedPredicates, requestedDeviceBindingVerifications, version, revocationFilterTimes); | ||
} | ||
|
||
} |
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
35 changes: 35 additions & 0 deletions
35
...lIdentity-backend/src/main/java/didentity/amos/digitalIdentity/services/ProofService.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,35 @@ | ||
package didentity.amos.digitalIdentity.services; | ||
|
||
import java.io.File; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
public class ProofService { | ||
|
||
@Autowired | ||
private LissiApiService lissiApiService; | ||
|
||
@Autowired | ||
private ResourceService resourceService; | ||
|
||
public ResponseEntity<String> createProof(String requestedSelfAttestedAttributes, | ||
String revocationFilterType, | ||
String requestedAttributes, | ||
String name, | ||
String requestedPredicates, | ||
String requestedDeviceBindingVerifications, | ||
String version, | ||
String revocationFilterTimes) { | ||
|
||
File image = resourceService.getDummyPng(); | ||
if (image == null) { | ||
return ResponseEntity.status(500).body("Could not find image."); | ||
} | ||
|
||
return lissiApiService.createProof(image, requestedSelfAttestedAttributes, revocationFilterType, requestedAttributes, name, requestedPredicates, requestedDeviceBindingVerifications, version, revocationFilterTimes); | ||
} | ||
|
||
} |