Skip to content

Commit

Permalink
Merge pull request #495 from Vlatombe/credentialsprovider-compatibili…
Browse files Browse the repository at this point in the history
…ty-fix

Fix a compatibility error in `CredentialsProvider`
  • Loading branch information
jtnord committed Nov 9, 2023
2 parents 3757c78 + 14183ea commit 8835d63
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1255,7 +1255,7 @@ public <C extends Credentials> List<C> getCredentials(@NonNull Class<C> type,
@NonNull Item item,
@Nullable org.acegisecurity.Authentication authentication) {
Objects.requireNonNull(item);
return getCredentialsInItemGroup(type, item.getParent(), authentication == null ? null : authentication.toSpring(), List.of());
return getCredentialsInItemFallback(type, item, authentication == null ? null : authentication.toSpring(), List.of());
}

/**
Expand All @@ -1267,7 +1267,7 @@ public <C extends Credentials> List<C> getCredentials(@NonNull Class<C> type,
@NonNull Item item,
@Nullable org.acegisecurity.Authentication authentication,
@NonNull List<DomainRequirement> domainRequirements) {
return getCredentialsInItem(type, item, authentication == null ? null : authentication.toSpring(), domainRequirements);
return getCredentialsInItemFallback(type, item, authentication == null ? null : authentication.toSpring(), domainRequirements);
}

/**
Expand All @@ -1287,6 +1287,17 @@ public <C extends Credentials> List<C> getCredentialsInItem(@NonNull Class<C> ty
@NonNull Item item,
@Nullable Authentication authentication,
@NonNull List<DomainRequirement> domainRequirements) {
if (Util.isOverridden(CredentialsProvider.class, getClass(), "getCredentials", Class.class, Item.class, org.acegisecurity.Authentication.class, List.class)) {
return getCredentials(type, item, authentication == null ? null : org.acegisecurity.Authentication.fromSpring(authentication), domainRequirements);
}
if (Util.isOverridden(CredentialsProvider.class, getClass(), "getCredentials", Class.class, Item.class, org.acegisecurity.Authentication.class)) {
return getCredentials(type, item, authentication == null ? null : org.acegisecurity.Authentication.fromSpring(authentication));
}
return getCredentialsInItemFallback(type, item, authentication, domainRequirements);
}

@NonNull
private <C extends Credentials> List<C> getCredentialsInItemFallback(@NonNull Class<C> type, @NonNull Item item, @Nullable Authentication authentication, @NonNull List<DomainRequirement> domainRequirements) {
return getCredentialsInItemGroup(type, item instanceof ItemGroup ? (ItemGroup) item : item.getParent(),
authentication, domainRequirements);
}
Expand Down

0 comments on commit 8835d63

Please sign in to comment.