-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(did issuance): update to new dtos for DID issuance & PUT -> POST
- Loading branch information
James Taylor
committed
Jun 8, 2021
1 parent
1531588
commit 3abd5a4
Showing
9 changed files
with
272 additions
and
25 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
48 changes: 48 additions & 0 deletions
48
...rc/main/java/eu/_5gzorro/manager/api/dto/identityPermisssions/CredentialAttributeDto.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,48 @@ | ||
package eu._5gzorro.manager.api.dto.identityPermisssions; | ||
|
||
import java.util.Objects; | ||
|
||
public class CredentialAttributeDto { | ||
private String name; | ||
private String value; | ||
|
||
public CredentialAttributeDto() { | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getValue() { | ||
return value; | ||
} | ||
|
||
public void setValue(String value) { | ||
this.value = value; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
CredentialAttributeDto that = (CredentialAttributeDto) o; | ||
return Objects.equals(name, that.name) && Objects.equals(value, that.value); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(name, value); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "CredentialAttributeDto{" + | ||
"name='" + name + '\'' + | ||
", value='" + value + '\'' + | ||
'}'; | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
app/src/main/java/eu/_5gzorro/manager/api/dto/identityPermisssions/CredentialOfferDto.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,41 @@ | ||
package eu._5gzorro.manager.api.dto.identityPermisssions; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
import java.util.Objects; | ||
|
||
public class CredentialOfferDto { | ||
@JsonProperty("credential_preview") | ||
private CredentialPreviewDto credentialPreview; | ||
|
||
public CredentialOfferDto() { | ||
} | ||
|
||
public CredentialPreviewDto getCredentialPreview() { | ||
return credentialPreview; | ||
} | ||
|
||
public void setCredentialPreview(CredentialPreviewDto credentialPreview) { | ||
this.credentialPreview = credentialPreview; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
CredentialOfferDto that = (CredentialOfferDto) o; | ||
return Objects.equals(credentialPreview, that.credentialPreview); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(credentialPreview); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "CredentialOfferDto{" + | ||
"credentialPreview=" + credentialPreview + | ||
'}'; | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
app/src/main/java/eu/_5gzorro/manager/api/dto/identityPermisssions/CredentialPreviewDto.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,60 @@ | ||
package eu._5gzorro.manager.api.dto.identityPermisssions; | ||
import com.fasterxml.jackson.core.type.TypeReference; | ||
import com.fasterxml.jackson.databind.DeserializationFeature; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import org.apache.commons.lang3.tuple.Pair; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Objects; | ||
import java.util.stream.Collectors; | ||
|
||
public class CredentialPreviewDto { | ||
private List<CredentialAttributeDto> attributes; | ||
|
||
public CredentialPreviewDto() { | ||
} | ||
|
||
public List<CredentialAttributeDto> getAttributes() { | ||
return attributes; | ||
} | ||
|
||
public void setAttributes(List<CredentialAttributeDto> attributes) { | ||
this.attributes = attributes; | ||
} | ||
|
||
public String getDid() { | ||
try { | ||
CredentialAttributeDto attr = attributes.stream().filter(a -> a.getName().equals("credentialSubject")).findFirst().get(); | ||
|
||
String valToDeserialise = attr.getValue().replace("'", "\""); | ||
ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | ||
CredentialSubjectDto subject = mapper.readValue(valToDeserialise, CredentialSubjectDto.class); | ||
return subject.getId(); | ||
} | ||
catch(Exception e) | ||
{ | ||
return null; | ||
} | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
CredentialPreviewDto that = (CredentialPreviewDto) o; | ||
return Objects.equals(attributes, that.attributes); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(attributes); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "CredentialPreviewDto{" + | ||
"attributes=" + attributes + | ||
'}'; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
app/src/main/java/eu/_5gzorro/manager/api/dto/identityPermisssions/CredentialSubjectDto.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,39 @@ | ||
package eu._5gzorro.manager.api.dto.identityPermisssions; | ||
|
||
import java.util.Objects; | ||
|
||
|
||
public class CredentialSubjectDto { | ||
private String id; | ||
|
||
public CredentialSubjectDto() { | ||
} | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
|
||
public void setId(String id) { | ||
this.id = id; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
CredentialSubjectDto that = (CredentialSubjectDto) o; | ||
return id.equals(that.id); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(id); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "CredentialSubjectDto{" + | ||
"id='" + id + '\'' + | ||
'}'; | ||
} | ||
} |
84 changes: 63 additions & 21 deletions
84
app/src/main/java/eu/_5gzorro/manager/api/dto/identityPermisssions/DIDStateDto.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 |
---|---|---|
@@ -1,58 +1,100 @@ | ||
package eu._5gzorro.manager.api.dto.identityPermisssions; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
import java.util.Objects; | ||
|
||
public class DIDStateDto { | ||
private String did; | ||
// private DIDStateEnum state; | ||
@JsonProperty("credential_exchange_id") | ||
private String credentialExchangeId; | ||
|
||
@JsonProperty("credential_offer_dict") | ||
private CredentialOfferDto credentialOffer; | ||
|
||
@JsonProperty("created_at") | ||
private String createdAt; | ||
|
||
@JsonProperty("updated_at") | ||
private String updatedAt; | ||
|
||
@JsonProperty("schema_id") | ||
private String schemaId; | ||
|
||
private String state; | ||
|
||
public DIDStateDto() { | ||
} | ||
|
||
public String getDid() { | ||
return did; | ||
public String getState() { | ||
return state; | ||
} | ||
|
||
public void setDid(String did) { | ||
this.did = did; | ||
public void setState(String state) { | ||
this.state = state; | ||
} | ||
|
||
// public DIDStateEnum getState() { | ||
// return state; | ||
// } | ||
// | ||
// public void setState(DIDStateEnum state) { | ||
// this.state = state; | ||
// } | ||
public String getCredentialExchangeId() { | ||
return credentialExchangeId; | ||
} | ||
|
||
public void setCredentialExchangeId(String credentialExchangeId) { | ||
this.credentialExchangeId = credentialExchangeId; | ||
} | ||
|
||
public String getState() { | ||
return state; | ||
public CredentialOfferDto getCredentialOffer() { | ||
return credentialOffer; | ||
} | ||
|
||
public void setState(String state) { | ||
this.state = state; | ||
public void setCredentialOffer(CredentialOfferDto credentialOffer) { | ||
this.credentialOffer = credentialOffer; | ||
} | ||
|
||
public String getCreatedAt() { | ||
return createdAt; | ||
} | ||
|
||
public void setCreatedAt(String createdAt) { | ||
this.createdAt = createdAt; | ||
} | ||
|
||
public String getUpdatedAt() { | ||
return updatedAt; | ||
} | ||
|
||
public void setUpdatedAt(String updatedAt) { | ||
this.updatedAt = updatedAt; | ||
} | ||
|
||
public String getSchemaId() { | ||
return schemaId; | ||
} | ||
|
||
public void setSchemaId(String schemaId) { | ||
this.schemaId = schemaId; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
DIDStateDto that = (DIDStateDto) o; | ||
return did.equals(that.did) && state == that.state; | ||
return credentialExchangeId.equals(that.credentialExchangeId); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(did, state); | ||
return Objects.hash(credentialExchangeId); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "DIDStateDto{" + | ||
"did='" + did + '\'' + | ||
", state=" + state + | ||
"credentialExchangeId='" + credentialExchangeId + '\'' + | ||
", credentialOffer=" + credentialOffer + | ||
", createdAt='" + createdAt + '\'' + | ||
", updatedAt='" + updatedAt + '\'' + | ||
", schemaId='" + schemaId + '\'' + | ||
", state='" + state + '\'' + | ||
'}'; | ||
} | ||
} |