-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into extend-examples
- Loading branch information
Showing
22 changed files
with
559 additions
and
112 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
14 changes: 14 additions & 0 deletions
14
.../main/java/com/concordium/sdk/crypto/wallet/identityobject/MissingAttributeException.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,14 @@ | ||
package com.concordium.sdk.crypto.wallet.identityobject; | ||
|
||
import com.concordium.sdk.responses.accountinfo.credential.AttributeType; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public class MissingAttributeException extends Exception { | ||
private AttributeType attribute; | ||
|
||
public MissingAttributeException(AttributeType attribute) { | ||
this.attribute = attribute; | ||
} | ||
} |
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
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
10 changes: 10 additions & 0 deletions
10
...um-sdk/src/main/java/com/concordium/sdk/crypto/wallet/web3Id/Statement/StatementType.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,10 @@ | ||
package com.concordium.sdk.crypto.wallet.web3Id.Statement; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
public enum StatementType { | ||
@JsonProperty("cred") | ||
Credential, | ||
@JsonProperty("sci") | ||
SmartContract | ||
} |
52 changes: 52 additions & 0 deletions
52
.../java/com/concordium/sdk/crypto/wallet/web3Id/Statement/did/AccountRequestIdentifier.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,52 @@ | ||
package com.concordium.sdk.crypto.wallet.web3Id.Statement.did; | ||
|
||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
|
||
import javax.annotation.Nullable; | ||
|
||
import com.concordium.sdk.crypto.wallet.Network; | ||
import com.concordium.sdk.crypto.wallet.web3Id.Statement.StatementType; | ||
import com.concordium.sdk.transactions.CredentialRegistrationId; | ||
import com.fasterxml.jackson.annotation.JsonValue; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public class AccountRequestIdentifier extends RequestIdentifier { | ||
private CredentialRegistrationId credId; | ||
private static Pattern pattern = Pattern.compile( "^" + getDID("(mainnet|testnet)", "([a-zA-Z0-9]*)") + "$"); | ||
|
||
@Builder | ||
public AccountRequestIdentifier(Network network, CredentialRegistrationId credId) { | ||
super(network); | ||
this.credId = credId; | ||
} | ||
|
||
private static String getDID(String network, String credId) { | ||
return "did:ccd:" + network + ":cred:" + credId; | ||
} | ||
|
||
@JsonValue | ||
@Override | ||
public String toString() { | ||
return getDID(network.getValue().toLowerCase(), credId.getEncoded()); | ||
} | ||
|
||
@Nullable | ||
public static AccountRequestIdentifier tryFromString(String did) { | ||
Matcher matcher = pattern.matcher(did); | ||
if (matcher.matches()) { | ||
Network network = Network.fromLowerCase(matcher.group(1)); | ||
CredentialRegistrationId credId = CredentialRegistrationId.from(matcher.group(2)); | ||
return new AccountRequestIdentifier(network, credId); | ||
} | ||
return null; | ||
} | ||
|
||
@Override | ||
public StatementType getType() { | ||
return StatementType.Credential; | ||
} | ||
} |
Oops, something went wrong.