Moved getContext to CredentialEnum
This commit is contained in:
parent
c88f776552
commit
2560281420
@ -35,11 +35,6 @@ public class Assertion extends Credential {
|
||||
return assertionType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getContext() {
|
||||
return List.of("https://w3id.org/openbadges/v2");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return MoreObjects.toStringHelper(this)
|
||||
@ -97,6 +92,11 @@ public class Assertion extends Credential {
|
||||
public List<String> getAllowedTypeValues() {
|
||||
return allowedTypeValues;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getContextUris() {
|
||||
return List.of("https://w3id.org/openbadges/v2") ;
|
||||
}
|
||||
}
|
||||
|
||||
public static final String ID = Assertion.class.getCanonicalName();
|
||||
|
@ -62,8 +62,6 @@ public abstract class Credential extends GeneratedObject {
|
||||
|
||||
public abstract CredentialEnum getCredentialType();
|
||||
|
||||
public abstract List<String> getContext();
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return MoreObjects.toStringHelper(this)
|
||||
@ -80,6 +78,7 @@ public abstract class Credential extends GeneratedObject {
|
||||
public interface CredentialEnum {
|
||||
List<String> getRequiredTypeValues();
|
||||
List<String> getAllowedTypeValues();
|
||||
List<String> getContextUris();
|
||||
}
|
||||
|
||||
public abstract static class Builder<B extends Credential> {
|
||||
|
@ -39,15 +39,6 @@ public class VerifiableCredential extends Credential {
|
||||
return credentialType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getContext() {
|
||||
return values.get(values.keySet()
|
||||
.stream()
|
||||
.filter(s->s.contains(credentialType))
|
||||
.findFirst()
|
||||
.orElseThrow(()-> new IllegalArgumentException(credentialType.name() + " not recognized")));
|
||||
}
|
||||
|
||||
public ProofType getProofType() {
|
||||
return jwt == null ? ProofType.EMBEDDED : ProofType.EXTERNAL;
|
||||
}
|
||||
@ -59,7 +50,7 @@ public class VerifiableCredential extends Credential {
|
||||
.put(EndorsementCredential, Catalog.OB_30_ENDORSEMENTCREDENTIAL_JSON)
|
||||
.build();
|
||||
|
||||
private static final Map<Set<VerifiableCredential.Type>, List<String>> values = new ImmutableMap.Builder<Set<VerifiableCredential.Type>, List<String>>()
|
||||
private static final Map<Set<VerifiableCredential.Type>, List<String>> contextMap = new ImmutableMap.Builder<Set<VerifiableCredential.Type>, List<String>>()
|
||||
.put(Set.of(Type.OpenBadgeCredential, AchievementCredential, EndorsementCredential),
|
||||
List.of("https://www.w3.org/2018/credentials/v1",
|
||||
//"https://purl.imsglobal.org/spec/ob/v3p0/context.json")) //dev legacy
|
||||
@ -115,6 +106,15 @@ public class VerifiableCredential extends Credential {
|
||||
public List<String> getAllowedTypeValues() {
|
||||
return allowedTypeValues;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getContextUris() {
|
||||
return contextMap.get(contextMap.keySet()
|
||||
.stream()
|
||||
.filter(s->s.contains(this))
|
||||
.findFirst()
|
||||
.orElseThrow(()-> new IllegalArgumentException(this.name() + " not recognized")));
|
||||
}
|
||||
}
|
||||
|
||||
public enum ProofType {
|
||||
|
Loading…
Reference in New Issue
Block a user