8000 [OID4VCI] Initial public client for credential issuance by tdiesler · Pull Request #45855 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -960,8 +960,7 @@ public Response requestCredential(String requestPayload) {
String proofType = originalProofs != null ? originalProofs.getProofType() : null;

for (String currentProof : allProofs) {
Proofs proofForIteration = new Proofs();
proofForIteration.setProofByType(proofType, currentProof);
Proofs proofForIteration = Proofs.create(proofType, currentProof);
// Creating credential with keybinding to the current proof
credentialRequest.setProofs(proofForIteration);
Object theCredential = getCredential(authResult, supportedCredential, tokenAuthDetail, credentialRequest, eventBuilder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,6 @@ public class Proofs {
@JsonProperty("attestation")
private List<String> attestation;

public Proofs() {
}

public Proofs(List<String> jwt, List<DiVpProof> diVp, List<String> attestation) {
this.jwt = jwt;
this.diVp = diVp;
this.attestation = attestation;
}

public List<String> getJwt() {
return jwt;
}
Expand Down Expand Up @@ -78,6 +69,23 @@ public Proofs setAttestation(List<String> attestation) {
return this;
}

/**
* Create proofs based on the proof type.
* Sets the appropriate field (JWT or Attestation) depending on the proof type.
*
* @param proofType the proof type (ProofType.JWT or ProofType.ATTESTATION)
* @param proof the proof value to set
*/
public static Proofs create(String proofType, String proof) {
Proofs proofs = new Proofs();
if (ProofType.JWT.equals(proofType)) {
proofs.setJwt(List.of(proof));
} else if (ProofType.ATTESTATION.equals(proofType)) {
proofs.setAttestation(List.of(proof));
}
return proofs;
}

/**
* Determines the proof type based on which field is populated.
* Checks JWT first, then Attestation.
Expand All @@ -94,23 +102,6 @@ public String getProofType() {
return null;
}

/**
* Sets the proof value based on the proof type.
* Sets the appropriate field (JWT or Attestation) depending on the proof type.
*
* @param proofType the proof type (ProofType.JWT or ProofType.ATTESTATION)
* @param proof the proof value to set
* @return this instance for method chaining
*/
public Proofs setProofByType(String proofType, String proof) {
if (ProofType.JWT.equals(proofType)) {
setJwt(List.of(proof));
} else if (ProofType.ATTESTATION.equals(proofType)) {
setAttestation(List.of(proof));
}
return this;
}

/**
* Returns all proof values as a list.
* Checks JWT proofs first, then Attestation proofs.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,9 @@ public class OID4VCActionTest extends OID4VCIssuerTestBase {
ManagedUser user;

OID4VCTestContext ctx;
OID4VCBasicWallet wallet;

@BeforeEach
void beforeEach() {
wallet = new OID4VCBasicWallet(keycloak, oauth);
ctx = new OID4VCTestContext(client, minimalJwtTypeCredentialScope);
user.admin().logout();
}
Expand Down Expand Up @@ -134,7 +132,7 @@ public void testCredentialOfferAIASuccess_authorizationCodeFlow() throws Excepti
//
AuthorizationEndpointResponse authResponse = wallet
.authorizationRequest()
.scope(ctx.getCredScopeName())
.scope(ctx.getScope())
.issuerState(issuerState)
.send(user.getUsername(), "password");
String authCode = authResponse.getCode();
Expand Down
Loading
Loading
0