-
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 #19 from WorldHealthOrganization/feature/universal…
…-resolver-integration feat: did trustlist parsing and storing
- Loading branch information
Showing
50 changed files
with
1,485 additions
and
928 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
46 changes: 46 additions & 0 deletions
46
src/main/java/tng/trustnetwork/keydistribution/entity/DecentralizedIdentifierEntity.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,46 @@ | ||
package tng.trustnetwork.keydistribution.entity; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.FetchType; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.OneToMany; | ||
import jakarta.persistence.Table; | ||
import java.time.ZonedDateTime; | ||
import java.util.List; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
|
||
@Data | ||
@Getter | ||
@Setter | ||
@Entity | ||
@Table(name = "decentralized_identifier") | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class DecentralizedIdentifierEntity { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "id", columnDefinition = "BIGINT") | ||
private Long id; | ||
|
||
@Column(name = "created_at", nullable = false) | ||
private ZonedDateTime createdAt = ZonedDateTime.now(); | ||
|
||
@Column(name = "did_id", length = 100) | ||
private String didId; | ||
|
||
@OneToMany(mappedBy = "parentDocument", fetch = FetchType.EAGER) | ||
private List<VerificationMethodEntity> verificationMethods; | ||
|
||
@Column(name = "raw", length = 10_000_000) | ||
private String raw; | ||
|
||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/tng/trustnetwork/keydistribution/entity/EcPublicKeyJwkEntity.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 tng.trustnetwork.keydistribution.entity; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.DiscriminatorValue; | ||
import jakarta.persistence.Entity; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
@Getter | ||
@Setter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Entity | ||
@DiscriminatorValue("EC") | ||
public class EcPublicKeyJwkEntity extends PublicKeyJwkEntity { | ||
|
||
@Column(name = "crv", length = 100) | ||
private String crv; | ||
|
||
@Column(name = "x", length = 100) | ||
private String xvalue; | ||
|
||
@Column(name = "y", length = 100) | ||
private String yvalue; | ||
|
||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/tng/trustnetwork/keydistribution/entity/PublicKeyJwkEntity.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 tng.trustnetwork.keydistribution.entity; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.DiscriminatorColumn; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.Inheritance; | ||
import jakarta.persistence.InheritanceType; | ||
import jakarta.persistence.Table; | ||
import java.time.ZonedDateTime; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
@Getter | ||
@Setter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Entity | ||
@Table(name = "public_key_jwk") | ||
@Inheritance(strategy = InheritanceType.SINGLE_TABLE) | ||
@DiscriminatorColumn(name = "kty", columnDefinition = "varchar(10)") | ||
public abstract class PublicKeyJwkEntity { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "id") | ||
private Long id; | ||
|
||
@Column(name = "created_at", nullable = false) | ||
private ZonedDateTime createdAt = ZonedDateTime.now(); | ||
|
||
@Column(name = "x5c", length = 7000) | ||
private String x5c; | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/tng/trustnetwork/keydistribution/entity/RsaPublicKeyJwkEntity.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,25 @@ | ||
package tng.trustnetwork.keydistribution.entity; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.DiscriminatorValue; | ||
import jakarta.persistence.Entity; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
@Getter | ||
@Setter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Entity | ||
@DiscriminatorValue("RSA") | ||
public class RsaPublicKeyJwkEntity extends PublicKeyJwkEntity { | ||
|
||
@Column(name = "n", length = 1000) | ||
private String nvalue; | ||
|
||
@Column(name = "e", length = 1000) | ||
private String evalue; | ||
|
||
} |
54 changes: 54 additions & 0 deletions
54
src/main/java/tng/trustnetwork/keydistribution/entity/VerificationMethodEntity.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,54 @@ | ||
package tng.trustnetwork.keydistribution.entity; | ||
|
||
import jakarta.persistence.CascadeType; | ||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.JoinColumn; | ||
import jakarta.persistence.ManyToOne; | ||
import jakarta.persistence.OneToOne; | ||
import jakarta.persistence.Table; | ||
import java.time.ZonedDateTime; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
@Data | ||
@Getter | ||
@Setter | ||
@Entity | ||
@Table(name = "verification_method") | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class VerificationMethodEntity { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "id", columnDefinition = "BIGINT") | ||
private Long id; | ||
|
||
@Column(name = "vm_id", length = 100) | ||
private String vmId; | ||
|
||
@Column(name = "type", length = 100) | ||
private String type; | ||
|
||
@Column(name = "controller", length = 100) | ||
private String controller; | ||
|
||
@OneToOne(cascade = CascadeType.ALL) | ||
@JoinColumn(name = "public_key_jwk_id") | ||
private PublicKeyJwkEntity publicKeyJwk; | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "parent_document_id") | ||
private DecentralizedIdentifierEntity parentDocument; | ||
|
||
@Column(name = "created_at", nullable = false) | ||
private ZonedDateTime createdAt = ZonedDateTime.now(); | ||
|
||
} |
67 changes: 67 additions & 0 deletions
67
src/main/java/tng/trustnetwork/keydistribution/mapper/DidMapper.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,67 @@ | ||
package tng.trustnetwork.keydistribution.mapper; | ||
|
||
import java.util.List; | ||
import org.mapstruct.Mapper; | ||
import org.mapstruct.Mapping; | ||
import org.mapstruct.SubclassExhaustiveStrategy; | ||
import org.mapstruct.SubclassMapping; | ||
import tng.trustnetwork.keydistribution.entity.DecentralizedIdentifierEntity; | ||
import tng.trustnetwork.keydistribution.entity.EcPublicKeyJwkEntity; | ||
import tng.trustnetwork.keydistribution.entity.PublicKeyJwkEntity; | ||
import tng.trustnetwork.keydistribution.entity.RsaPublicKeyJwkEntity; | ||
import tng.trustnetwork.keydistribution.entity.VerificationMethodEntity; | ||
import tng.trustnetwork.keydistribution.model.DidDocument; | ||
import tng.trustnetwork.keydistribution.model.EcPublicKeyJwk; | ||
import tng.trustnetwork.keydistribution.model.JwkVerificationMethod; | ||
import tng.trustnetwork.keydistribution.model.PublicKeyJwk; | ||
import tng.trustnetwork.keydistribution.model.RsaPublicKeyJwk; | ||
import tng.trustnetwork.keydistribution.model.StringOrObject; | ||
import tng.trustnetwork.keydistribution.model.VerificationMethod; | ||
|
||
@Mapper(componentModel = "spring", subclassExhaustiveStrategy = SubclassExhaustiveStrategy.RUNTIME_EXCEPTION) | ||
public interface DidMapper { | ||
|
||
@Mapping(target = "didId", source = "didDocument.id") | ||
@Mapping(target = "verificationMethods", source = "didDocument.verificationMethod") | ||
@Mapping(target = "id", ignore = true) | ||
@Mapping(target = "createdAt", ignore = true) | ||
DecentralizedIdentifierEntity toEntity(DidDocument didDocument, String raw); | ||
|
||
@SubclassMapping(target = RsaPublicKeyJwkEntity.class, source = RsaPublicKeyJwk.class) | ||
@SubclassMapping(target = EcPublicKeyJwkEntity.class, source = EcPublicKeyJwk.class) | ||
@Mapping(target = "id", ignore = true) | ||
@Mapping(target = "createdAt", ignore = true) | ||
PublicKeyJwkEntity toEntity(PublicKeyJwk publicKeyJwk); | ||
|
||
@Mapping(target = "id", ignore = true) | ||
@Mapping(target = "createdAt", ignore = true) | ||
EcPublicKeyJwkEntity toEntity(EcPublicKeyJwk model); | ||
|
||
@Mapping(target = "id", ignore = true) | ||
@Mapping(target = "createdAt", ignore = true) | ||
RsaPublicKeyJwkEntity toEntity(RsaPublicKeyJwk model); | ||
|
||
@SubclassMapping(target = VerificationMethodEntity.class, source = JwkVerificationMethod.class) | ||
@Mapping(target = "vmId", source = "verificationMethod.id") | ||
@Mapping(target = "id", ignore = true) | ||
@Mapping(target = "createdAt", ignore = true) | ||
@Mapping(target = "parentDocument", ignore = true) | ||
@Mapping(target = "publicKeyJwk", ignore = true) | ||
VerificationMethodEntity toEntity(VerificationMethod verificationMethod); | ||
|
||
@Mapping(target = "type", constant = "JsonWebKey2020") | ||
@Mapping(target = "vmId", source = "verificationMethod.id") | ||
@Mapping(target = "id", ignore = true) | ||
@Mapping(target = "parentDocument", ignore = true) | ||
@Mapping(target = "createdAt", ignore = true) | ||
VerificationMethodEntity toEntity(JwkVerificationMethod verificationMethod); | ||
|
||
default <T> T unwrap(StringOrObject<T> wrapped) { | ||
return wrapped.getObjectValue(); | ||
} | ||
|
||
default String toSingleString(List<String> list) { | ||
|
||
return list == null ? null : String.join(",", list); | ||
} | ||
} |
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
23 changes: 23 additions & 0 deletions
23
src/main/java/tng/trustnetwork/keydistribution/model/DidContext.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,23 @@ | ||
package tng.trustnetwork.keydistribution.model; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
@Getter | ||
@Setter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
public class DidContext { | ||
|
||
private String base; | ||
|
||
private String rating; | ||
|
||
private String publicAccess; | ||
|
||
private String additionalType; | ||
} |
17 changes: 10 additions & 7 deletions
17
src/main/java/tng/trustnetwork/keydistribution/model/DidDocument.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,25 +1,28 @@ | ||
package tng.trustnetwork.keydistribution.model; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import java.util.List; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
@Getter | ||
@Setter | ||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
public class DidDocument { | ||
|
||
@JsonProperty("@context") | ||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
private List<String> context; | ||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
private List<StringOrObject<DidContext>> context; | ||
|
||
private String id; | ||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
|
||
private String controller; | ||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
private Object verificationMethod; | ||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
|
||
|
||
private List<StringOrObject<VerificationMethod>> verificationMethod; | ||
|
||
private Proof proof; | ||
|
||
} |
24 changes: 0 additions & 24 deletions
24
src/main/java/tng/trustnetwork/keydistribution/model/DidDocumentUnmarshal.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.