Skip to content

Commit

Permalink
feat: add ignoring version
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksandra-bel authored and andreibogus committed Feb 27, 2024
1 parent a6c2154 commit 1785080
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,5 @@ private StringPool() {
public static final String COMA_SEPARATOR = ", ";
public static final String BLANK_SEPARATOR = " ";
public static final String COLON_SEPARATOR = ":";
public static final String UNDERSCORE = "_";
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
import static org.eclipse.tractusx.managedidentitywallets.constant.StringPool.BLANK_SEPARATOR;
import static org.eclipse.tractusx.managedidentitywallets.constant.StringPool.COLON_SEPARATOR;
import static org.eclipse.tractusx.managedidentitywallets.constant.StringPool.COMA_SEPARATOR;
import static org.eclipse.tractusx.managedidentitywallets.constant.StringPool.UNDERSCORE;
import static org.eclipse.tractusx.managedidentitywallets.utils.TokenParsingUtils.getClaimsSet;
import static org.eclipse.tractusx.managedidentitywallets.utils.TokenParsingUtils.getScope;

Expand Down Expand Up @@ -301,11 +302,12 @@ public Map<String, Object> createVpWithRequiredScopes(SignedJWT innerJWT, boolea
String[] scopeParts = scope.split(COLON_SEPARATOR);
String vcType = scopeParts[1];
checkReadPermission(scopeParts[2]);
String vcTypeNoVersion = removeVersion(vcType);

List<HoldersCredential> credentials =
holdersCredentialRepository.getByHolderDidAndType(jwtClaimsSet.getIssuer(), vcType);
holdersCredentialRepository.getByHolderDidAndType(jwtClaimsSet.getIssuer(), vcTypeNoVersion);
if ((null == credentials) || credentials.isEmpty()) {
missingVCTypes.add(vcType);
missingVCTypes.add(vcTypeNoVersion);
} else {
holdersCredentials.addAll(credentials);
}
Expand Down Expand Up @@ -333,4 +335,9 @@ private void checkMissingVcs(List<String> missingVCTypes) {
String.join(COMA_SEPARATOR, missingVCTypes)));
}
}

private String removeVersion(String vcType) {
String[] parts = vcType.split(UNDERSCORE);
return (parts.length > 1) ? parts[0] : vcType;
}
}

0 comments on commit 1785080

Please sign in to comment.