Skip to content

Commit

Permalink
fix: add asJwt as query param and fix exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
mustafasalfiti authored and nitin-vavdiya committed May 21, 2024
1 parent 30a60d5 commit 8cbb756
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
package org.eclipse.tractusx.managedidentitywallets.apidocs;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
Expand All @@ -15,6 +10,11 @@
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

public class IssuersCredentialControllerApiDocs {
/**
* The constant API_TAG_VERIFIABLE_CREDENTIAL_ISSUER.
Expand Down Expand Up @@ -1178,7 +1178,6 @@ public class IssuersCredentialControllerApiDocs {
public @interface IssueVerifiableCredentialUsingBaseWalletApiDocs {
}


@Parameter(description = "Specifies whether the VC (Verifiable Credential) should be created as a JWT (JSON Web Token). "
+
"If set to true, the VC will be generated in JWT format"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
package org.eclipse.tractusx.managedidentitywallets.controller;


import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.Min;
import lombok.RequiredArgsConstructor;
Expand All @@ -38,10 +41,11 @@
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.security.Principal;
import java.util.List;
Expand Down Expand Up @@ -122,6 +126,6 @@ public ResponseEntity<CredentialsResponse> issueCredential(@RequestBody Map<Stri
@AsJwtParam @RequestParam(name = "asJwt", defaultValue = "false") boolean asJwt
) {
log.debug("Received request to issue credential. BPN: {}", getBPNFromToken(principal));
return ResponseEntity.status(HttpStatus.CREATED).body(holdersCredentialService.issueCredential(data, getBPNFromToken(principal) , asJwt));
return ResponseEntity.status(HttpStatus.CREATED).body(holdersCredentialService.issueCredential(data, getBPNFromToken(principal), asJwt));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
import lombok.*;
import org.eclipse.tractusx.managedidentitywallets.constant.StringPool;

import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.Set;

/**
Expand All @@ -52,6 +50,4 @@ public class IssueDismantlerCredentialRequest {
@Builder.Default
private Set<@NotBlank String> allowedVehicleBrands = Set.of();

@JsonProperty("asJwt")
private boolean asJwt;
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ public class IssueFrameworkCredentialRequest {
@NotBlank(message = "Please provide contract-template")
@JsonProperty("contract-version")
private String contractVersion;

@JsonProperty("asJwt")
private boolean asJwt;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ public CredentialsResponse issueCredential(Map<String, Object> data, String call
if (verifiableCredential.getExpirationDate() != null) {
expiryDate = Date.from(verifiableCredential.getExpirationDate());
}

// Create Credential
HoldersCredential credential = CommonUtils.getHoldersCredential(verifiableCredential.getCredentialSubject().get(0),
verifiableCredential.getTypes(), issuerWallet.getDidDocument(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public Object getPrivateKeyByWalletIdAndAlgorithm(long walletId, SupportedAlgori
}

/**
* Gets wallet key by wallet identifier.
* Gets wallet key by wallet id.
*
* @param walletId the wallet id
* @return the wallet key by wallet identifier
Expand All @@ -115,5 +115,4 @@ public String getWalletKeyIdByWalletId(long walletId) {
return walletKeyRepository.getByWalletId(walletId).getKeyId();
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ public static String vcAsJwt(Wallet issuerWallet, Wallet holderWallet, Verifiabl
SignedJWT vcJWT = vcFactory.createVCJwt(issuerDid, holderDid, vc,
privateKey,
walletKeyService.getWalletKeyIdByWalletId(issuerWallet.getId())

);
return vcJWT.serialize();
}
Expand Down

0 comments on commit 8cbb756

Please sign in to comment.