Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a compatibility error in CredentialsProvider #495

Merged
Merged
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 @@ -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());
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prevents infinite recursion in case the overrides delegates to super implementation.

}

/**
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