Compare commits

..

No commits in common. "main" and "7.0.4" have entirely different histories.
main ... 7.0.4

1413 changed files with 4855 additions and 25037 deletions

123
.github/dependabot.yml vendored
View File

@ -1,10 +1,12 @@
version: 2 version: 2
registries: registries:
spring-milestones:
type: maven-repository
url: https://repo.spring.io/milestone
shibboleth: shibboleth:
type: maven-repository type: maven-repository
url: https://build.shibboleth.net/maven/releases url: https://build.shibboleth.net/maven/releases
updates: updates:
# 6.5.x
- package-ecosystem: gradle - package-ecosystem: gradle
target-branch: 6.5.x target-branch: 6.5.x
directory: / directory: /
@ -15,6 +17,7 @@ updates:
labels: labels:
- 'type: dependency-upgrade' - 'type: dependency-upgrade'
registries: registries:
- spring-milestones
- shibboleth - shibboleth
ignore: ignore:
- dependency-name: com.nimbusds:nimbus-jose-jwt - dependency-name: com.nimbusds:nimbus-jose-jwt
@ -31,28 +34,8 @@ updates:
update-types: update-types:
- version-update:semver-major - version-update:semver-major
- version-update:semver-minor - version-update:semver-minor
- package-ecosystem: npm
target-branch: 6.5.x
directory: /docs
schedule:
interval: weekly
labels:
- 'type: task'
- 'type: dependency-upgrade'
- 'in: build'
- package-ecosystem: github-actions
target-branch: 6.5.x
directory: /
schedule:
interval: weekly
labels:
- 'type: task'
- 'type: dependency-upgrade'
- 'in: build'
# 7.0.x
- package-ecosystem: gradle - package-ecosystem: gradle
target-branch: 7.0.x target-branch: 6.4.x
directory: / directory: /
schedule: schedule:
interval: daily interval: daily
@ -61,10 +44,10 @@ updates:
labels: labels:
- 'type: dependency-upgrade' - 'type: dependency-upgrade'
registries: registries:
- spring-milestones
- shibboleth - shibboleth
ignore: ignore:
- dependency-name: com.nimbusds:nimbus-jose-jwt - dependency-name: com.nimbusds:nimbus-jose-jwt
- dependency-name: io.spring.nullability:*
- dependency-name: org.python:jython - dependency-name: org.python:jython
- dependency-name: org.apache.directory.server:* - dependency-name: org.apache.directory.server:*
- dependency-name: org.apache.directory.shared:* - dependency-name: org.apache.directory.shared:*
@ -74,34 +57,11 @@ updates:
- dependency-name: org.mockito:mockito-bom - dependency-name: org.mockito:mockito-bom
update-types: update-types:
- version-update:semver-major - version-update:semver-major
- dependency-name: com.gradle.enterprise
update-types:
- version-update:semver-major
- version-update:semver-minor
- dependency-name: '*' - dependency-name: '*'
update-types: update-types:
- version-update:semver-major - version-update:semver-major
- version-update:semver-minor - version-update:semver-minor
- package-ecosystem: npm
target-branch: 7.0.x
directory: /docs
schedule:
interval: weekly
labels:
- 'type: task'
- 'type: dependency-upgrade'
- 'in: build'
- package-ecosystem: github-actions
target-branch: 7.0.x
directory: /
schedule:
interval: weekly
labels:
- 'type: task'
- 'type: dependency-upgrade'
- 'in: build'
# main
- package-ecosystem: gradle - package-ecosystem: gradle
target-branch: main target-branch: main
directory: / directory: /
@ -112,6 +72,7 @@ updates:
labels: labels:
- 'type: dependency-upgrade' - 'type: dependency-upgrade'
registries: registries:
- spring-milestones
- shibboleth - shibboleth
ignore: ignore:
- dependency-name: com.nimbusds:nimbus-jose-jwt - dependency-name: com.nimbusds:nimbus-jose-jwt
@ -131,6 +92,17 @@ updates:
- dependency-name: '*' - dependency-name: '*'
update-types: update-types:
- version-update:semver-major - version-update:semver-major
- version-update:semver-minor
- package-ecosystem: npm
target-branch: docs-build
directory: /
schedule:
interval: weekly
labels:
- 'type: task'
- 'in: build'
- package-ecosystem: npm - package-ecosystem: npm
target-branch: main target-branch: main
directory: /docs directory: /docs
@ -138,63 +110,4 @@ updates:
interval: weekly interval: weekly
labels: labels:
- 'type: task' - 'type: task'
- 'type: dependency-upgrade'
- 'in: build'
- package-ecosystem: github-actions
target-branch: main
directory: /
schedule:
interval: weekly
labels:
- 'type: task'
- 'type: dependency-upgrade'
- 'in: build'
# docs-build
- package-ecosystem: gradle
target-branch: docs-build
directory: /
schedule:
interval: daily
time: '03:00'
timezone: Etc/UTC
labels:
- 'type: dependency-upgrade'
registries:
- shibboleth
ignore:
- dependency-name: com.nimbusds:nimbus-jose-jwt
- dependency-name: org.python:jython
- dependency-name: org.apache.directory.server:*
- dependency-name: org.apache.directory.shared:*
- dependency-name: org.junit:junit-bom
update-types:
- version-update:semver-major
- dependency-name: org.mockito:mockito-bom
update-types:
- version-update:semver-major
- dependency-name: com.gradle.enterprise
update-types:
- version-update:semver-major
- version-update:semver-minor
- dependency-name: '*'
update-types:
- version-update:semver-major
- package-ecosystem: npm
target-branch: docs-build
directory: /
schedule:
interval: weekly
labels:
- 'type: task'
- 'type: dependency-upgrade'
- 'in: build'
- package-ecosystem: github-actions
target-branch: docs-build
directory: /
schedule:
interval: weekly
labels:
- 'type: task'
- 'type: dependency-upgrade'
- 'in: build' - 'in: build'

View File

@ -1,17 +0,0 @@
name: Merge Dependabot PR
on:
pull_request:
branches:
- main
- '*.x'
- 'docs-build'
run-name: Merge Dependabot PR ${{ github.ref_name }}
jobs:
merge-dependabot-pr:
permissions: write-all
uses: spring-io/spring-github-workflows/.github/workflows/spring-merge-dependabot-pr.yml@v7
with:
mergeArguments: --auto --rebase

View File

@ -14,12 +14,14 @@ permissions:
jobs: jobs:
snapshot-test: snapshot-test:
name: Test Against Snapshots name: Test Against Snapshots
uses: spring-io/spring-security-release-tools/.github/workflows/test.yml@b92832ecbc7cbe969201e6beafbde0ee400cf095 # v1.0.15 uses: spring-io/spring-security-release-tools/.github/workflows/test.yml@v1
strategy: strategy:
matrix: matrix:
include: include:
- java-version: 25 - java-version: 21-ea
toolchain: 25 toolchain: 21
- java-version: 17
toolchain: 17
with: with:
java-version: ${{ matrix.java-version }} java-version: ${{ matrix.java-version }}
test-args: --refresh-dependencies -PforceMavenRepositories=snapshot,https://oss.sonatype.org/content/repositories/snapshots -PisOverrideVersionCatalog -PtestToolchain=${{ matrix.toolchain }} -PspringFrameworkVersion=7.+ -PreactorVersion=2025.+ -PspringDataVersion=2025.+ --stacktrace test-args: --refresh-dependencies -PforceMavenRepositories=snapshot,https://oss.sonatype.org/content/repositories/snapshots -PisOverrideVersionCatalog -PtestToolchain=${{ matrix.toolchain }} -PspringFrameworkVersion=7.+ -PreactorVersion=2025.+ -PspringDataVersion=2025.+ --stacktrace
@ -31,6 +33,6 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Send Notification - name: Send Notification
uses: spring-io/spring-security-release-tools/.github/actions/send-notification@b92832ecbc7cbe969201e6beafbde0ee400cf095 # v1.0.15 uses: spring-io/spring-security-release-tools/.github/actions/send-notification@v1
with: with:
webhook-url: ${{ secrets.SPRING_SECURITY_CI_GCHAT_WEBHOOK_URL }} webhook-url: ${{ secrets.SPRING_SECURITY_CI_GCHAT_WEBHOOK_URL }}

View File

@ -21,7 +21,7 @@ jobs:
strategy: strategy:
matrix: matrix:
os: [ ubuntu-latest, windows-latest ] os: [ ubuntu-latest, windows-latest ]
jdk: [ 25 ] jdk: [ 17 ]
with: with:
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
java-version: ${{ matrix.jdk }} java-version: ${{ matrix.jdk }}
@ -34,7 +34,6 @@ jobs:
with: with:
should-deploy-artifacts: ${{ needs.build.outputs.should-deploy-artifacts }} should-deploy-artifacts: ${{ needs.build.outputs.should-deploy-artifacts }}
default-publish-milestones-central: true default-publish-milestones-central: true
java-version: 25
secrets: inherit secrets: inherit
deploy-schema: deploy-schema:
name: Deploy Schema name: Deploy Schema
@ -42,7 +41,6 @@ jobs:
uses: spring-io/spring-security-release-tools/.github/workflows/deploy-schema.yml@b92832ecbc7cbe969201e6beafbde0ee400cf095 # v1.0.15 uses: spring-io/spring-security-release-tools/.github/workflows/deploy-schema.yml@b92832ecbc7cbe969201e6beafbde0ee400cf095 # v1.0.15
with: with:
should-deploy-schema: ${{ needs.build.outputs.should-deploy-artifacts }} should-deploy-schema: ${{ needs.build.outputs.should-deploy-artifacts }}
java-version: 25
secrets: inherit secrets: inherit
perform-release: perform-release:
name: Perform Release name: Perform Release
@ -55,7 +53,6 @@ jobs:
release-repo-url: https://repo1.maven.org/maven2 release-repo-url: https://repo1.maven.org/maven2
artifact-path: org/springframework/security/spring-security-core artifact-path: org/springframework/security/spring-security-core
slack-announcing-id: spring-security-announcing slack-announcing-id: spring-security-announcing
java-version: 25
secrets: inherit secrets: inherit
send-notification: send-notification:
name: Send Notification name: Send Notification

View File

@ -16,7 +16,7 @@ permissions:
jobs: jobs:
perform-release: perform-release:
name: Perform Release name: Perform Release
uses: spring-io/spring-security-release-tools/.github/workflows/perform-release.yml@b92832ecbc7cbe969201e6beafbde0ee400cf095 # v1.0.15 uses: spring-io/spring-security-release-tools/.github/workflows/perform-release.yml@v1
with: with:
should-perform-release: true should-perform-release: true
project-version: ${{ inputs.version }} project-version: ${{ inputs.version }}

View File

@ -9,7 +9,6 @@ permissions:
jobs: jobs:
upgrade_wrapper: upgrade_wrapper:
name: Execution name: Execution
if: ${{ github.repository == 'spring-projects/spring-security' }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Set up Git configuration - name: Set up Git configuration
@ -21,10 +20,10 @@ jobs:
git config --global user.email 'github-actions[bot]@users.noreply.github.com' git config --global user.email 'github-actions[bot]@users.noreply.github.com'
- name: Checkout - name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up JDK 25 - name: Set up JDK 17
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0 uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
with: with:
java-version: '25' java-version: '17'
distribution: 'temurin' distribution: 'temurin'
- name: Set up Gradle - name: Set up Gradle
uses: gradle/setup-gradle@f29f5a9d7b09a7c6b29859002d29d24e1674c884 # v5.0.1 uses: gradle/setup-gradle@f29f5a9d7b09a7c6b29859002d29d24e1674c884 # v5.0.1

View File

@ -30,6 +30,6 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Send Notification - name: Send Notification
uses: spring-io/spring-security-release-tools/.github/actions/send-notification@b92832ecbc7cbe969201e6beafbde0ee400cf095 # v1.0.15 uses: spring-io/spring-security-release-tools/.github/actions/send-notification@729fed56d42122f88583aff1be35c0800b7d77e9 # v1.0.14
with: with:
webhook-url: ${{ secrets.SPRING_SECURITY_CI_GCHAT_WEBHOOK_URL }} webhook-url: ${{ secrets.SPRING_SECURITY_CI_GCHAT_WEBHOOK_URL }}

View File

@ -13,9 +13,9 @@ jobs:
steps: steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up gradle - name: Set up gradle
uses: spring-io/spring-gradle-build-action@c8668747d7c264864c8c7f7026d0d277d14a78dc # v2.0.6 uses: spring-io/spring-gradle-build-action@efc55f07f4dfa22f2afd97f9ea1be4212eeed737 # v2.0.5
with: with:
java-version: '25' java-version: '17'
distribution: 'temurin' distribution: 'temurin'
- name: Build with Gradle - name: Build with Gradle
run: ./gradlew clean build -PskipCheckExpectedBranchVersion --continue --scan run: ./gradlew clean build -PskipCheckExpectedBranchVersion --continue --scan
@ -26,9 +26,9 @@ jobs:
steps: steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up gradle - name: Set up gradle
uses: spring-io/spring-gradle-build-action@c8668747d7c264864c8c7f7026d0d277d14a78dc # v2.0.6 uses: spring-io/spring-gradle-build-action@efc55f07f4dfa22f2afd97f9ea1be4212eeed737 # v2.0.5
with: with:
java-version: '25' java-version: '17'
distribution: 'temurin' distribution: 'temurin'
- name: Run Antora - name: Run Antora
run: ./gradlew -PbuildSrc.skipTests=true :spring-security-docs:antora run: ./gradlew -PbuildSrc.skipTests=true :spring-security-docs:antora
@ -46,6 +46,6 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Send Notification - name: Send Notification
uses: spring-io/spring-security-release-tools/.github/actions/send-notification@b92832ecbc7cbe969201e6beafbde0ee400cf095 # v1.0.15 uses: spring-io/spring-security-release-tools/.github/actions/send-notification@729fed56d42122f88583aff1be35c0800b7d77e9 # v1.0.14
with: with:
webhook-url: ${{ secrets.SPRING_SECURITY_CI_GCHAT_WEBHOOK_URL }} webhook-url: ${{ secrets.SPRING_SECURITY_CI_GCHAT_WEBHOOK_URL }}

View File

@ -11,7 +11,7 @@ jobs:
strategy: strategy:
matrix: matrix:
# List of active maintenance branches. # List of active maintenance branches.
branch: [ main, 7.0.x, 6.5.x, 6.4.x, 6.3.x ] branch: [ main, 6.5.x, 6.4.x, 6.3.x ]
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout

View File

@ -12,12 +12,11 @@ permissions:
jobs: jobs:
update-antora-ui-spring: update-antora-ui-spring:
name: Update on Supported Branches
if: ${{ github.repository == 'spring-projects/spring-security' }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
name: Update on Supported Branches
strategy: strategy:
matrix: matrix:
branch: [ '6.5.x', '7.0.x', 'main' ] branch: [ '6.4.x', '6.5.x', 'main' ]
steps: steps:
- uses: spring-io/spring-doc-actions/update-antora-spring-ui@415e2b11a766ba64799fffb5c97a4f7e17f677cf - uses: spring-io/spring-doc-actions/update-antora-spring-ui@415e2b11a766ba64799fffb5c97a4f7e17f677cf
name: Update name: Update
@ -26,9 +25,8 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
antora-file-path: 'docs/antora-playbook.yml' antora-file-path: 'docs/antora-playbook.yml'
update-antora-ui-spring-docs-build: update-antora-ui-spring-docs-build:
name: Update on docs-build
if: ${{ github.repository == 'spring-projects/spring-security' }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
name: Update on docs-build
steps: steps:
- uses: spring-io/spring-doc-actions/update-antora-spring-ui@415e2b11a766ba64799fffb5c97a4f7e17f677cf - uses: spring-io/spring-doc-actions/update-antora-spring-ui@415e2b11a766ba64799fffb5c97a4f7e17f677cf
name: Update name: Update

View File

@ -9,7 +9,7 @@ permissions:
jobs: jobs:
update-scheduled-release-version: update-scheduled-release-version:
name: Update Scheduled Release Version name: Update Scheduled Release Version
uses: spring-io/spring-security-release-tools/.github/workflows/update-scheduled-release-version.yml@b92832ecbc7cbe969201e6beafbde0ee400cf095 # v1.0.15 uses: spring-io/spring-security-release-tools/.github/workflows/update-scheduled-release-version.yml@729fed56d42122f88583aff1be35c0800b7d77e9 # v1.0.14
secrets: inherit secrets: inherit
send-notification: send-notification:
name: Send Notification name: Send Notification
@ -18,6 +18,6 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Send Notification - name: Send Notification
uses: spring-io/spring-security-release-tools/.github/actions/send-notification@b92832ecbc7cbe969201e6beafbde0ee400cf095 # v1.0.15 uses: spring-io/spring-security-release-tools/.github/actions/send-notification@729fed56d42122f88583aff1be35c0800b7d77e9 # v1.0.14
with: with:
webhook-url: ${{ secrets.SPRING_SECURITY_CI_GCHAT_WEBHOOK_URL }} webhook-url: ${{ secrets.SPRING_SECURITY_CI_GCHAT_WEBHOOK_URL }}

View File

@ -3,4 +3,4 @@
# See https://sdkman.io/usage#config # See https://sdkman.io/usage#config
# A summary is to add the following to ~/.sdkman/etc/config # A summary is to add the following to ~/.sdkman/etc/config
# sdkman_auto_env=true # sdkman_auto_env=true
java=25-librca java=17.0.3-tem

View File

@ -1,3 +1,3 @@
{ {
"java.gradle.buildServer.enabled": "off" "java.import.gradle.enabled": false
} }

View File

@ -31,7 +31,7 @@ If you have a question, check Stack Overflow using
https://stackoverflow.com/questions/tagged/spring-security+or+spring-ldap+or+spring-authorization-server+or+spring-session?tab=Newest[this list of tags]. https://stackoverflow.com/questions/tagged/spring-security+or+spring-ldap+or+spring-authorization-server+or+spring-session?tab=Newest[this list of tags].
Find an existing discussion, or start a new one if necessary. Find an existing discussion, or start a new one if necessary.
If you believe there is an issue, search through https://github.com/spring-projects/spring-security/issues[existing issues] trying a few different ways to find discussions, past or current, that are related to the issue. If you believe there is an issue, search through https://github.com/spring-projects/spring-security/issues[existing issues] trying a few different ways to find discussions, past or current, that are related to the issue.
Reading those discussions helps you to learn about the issue, and helps us to make a decision. Reading those discussions helps you to learn about the issue, and helps us to make a decision.
[[find-an-issue]] [[find-an-issue]]
@ -94,7 +94,7 @@ Don't worry if you don't get them all correct the first time, we will help you.
1. [[sign-cla]] All commits must include a __Signed-off-by__ trailer at the end of each commit message to indicate that the contributor agrees to the Developer Certificate of Origin. 1. [[sign-cla]] All commits must include a __Signed-off-by__ trailer at the end of each commit message to indicate that the contributor agrees to the Developer Certificate of Origin.
For additional details, please refer to the blog post https://spring.io/blog/2025/01/06/hello-dco-goodbye-cla-simplifying-contributions-to-spring[Hello DCO, Goodbye CLA: Simplifying Contributions to Spring]. For additional details, please refer to the blog post https://spring.io/blog/2025/01/06/hello-dco-goodbye-cla-simplifying-contributions-to-spring[Hello DCO, Goodbye CLA: Simplifying Contributions to Spring].
2. [[create-an-issue-list]] Must you https://github.com/spring-projects/spring-security/issues/new/choose[create an issue] first? No, but it is recommended for features and larger bug fixes. It's easier to discuss with the team first to determine the right fix or enhancement. 2. [[create-an-issue-list]] Must you https://github.com/spring-projects/spring-security/issues/new/choose[create an issue] first? No, but it is recommended for features and larger bug fixes. It's easier discuss with the team first to determine the right fix or enhancement.
For typos and straightforward bug fixes, starting with a pull request is encouraged. For typos and straightforward bug fixes, starting with a pull request is encouraged.
Please include a description for context and motivation. Please include a description for context and motivation.
Note that the team may close your pull request if it's not a fit for the project. Note that the team may close your pull request if it's not a fit for the project.

View File

@ -1,8 +1,3 @@
plugins {
id 'compile-warnings-error'
id 'javadoc-warnings-error'
}
apply plugin: 'io.spring.convention.spring-module' apply plugin: 'io.spring.convention.spring-module'
dependencies { dependencies {

View File

@ -20,8 +20,6 @@ import java.io.Serial;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.jspecify.annotations.Nullable;
import org.springframework.security.authorization.AuthorizationManager; import org.springframework.security.authorization.AuthorizationManager;
import org.springframework.security.core.annotation.SecurityAnnotationScanner; import org.springframework.security.core.annotation.SecurityAnnotationScanner;
import org.springframework.util.Assert; import org.springframework.util.Assert;
@ -52,7 +50,7 @@ public class SecurityConfig implements ConfigAttribute {
} }
@Override @Override
public boolean equals(@Nullable Object obj) { public boolean equals(Object obj) {
if (obj instanceof ConfigAttribute attr) { if (obj instanceof ConfigAttribute attr) {
return this.attrib.equals(attr.getAttribute()); return this.attrib.equals(attr.getAttribute());
} }

View File

@ -31,7 +31,6 @@ import org.jspecify.annotations.Nullable;
import org.springframework.core.annotation.AnnotationUtils; import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.security.access.ConfigAttribute; import org.springframework.security.access.ConfigAttribute;
import org.springframework.security.access.method.AbstractFallbackMethodSecurityMetadataSource; import org.springframework.security.access.method.AbstractFallbackMethodSecurityMetadataSource;
import org.springframework.util.StringUtils;
/** /**
* Sources method security metadata from major JSR 250 security annotations. * Sources method security metadata from major JSR 250 security annotations.
@ -109,7 +108,7 @@ public class Jsr250MethodSecurityMetadataSource extends AbstractFallbackMethodSe
if (role == null) { if (role == null) {
return role; return role;
} }
if (!StringUtils.hasLength(this.defaultRolePrefix)) { if (this.defaultRolePrefix == null || this.defaultRolePrefix.length() == 0) {
return role; return role;
} }
if (role.startsWith(this.defaultRolePrefix)) { if (role.startsWith(this.defaultRolePrefix)) {

View File

@ -53,9 +53,7 @@ import org.springframework.util.CollectionUtils;
* *
* @author Ben Alex * @author Ben Alex
* @author Luke Taylor * @author Luke Taylor
* @deprecated Use * @deprecated Use {@link EnableMethodSecurity} or publish interceptors directly
* <code>org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity</code>
* or publish interceptors directly
*/ */
@NullUnmarked @NullUnmarked
@Deprecated @Deprecated

View File

@ -114,10 +114,8 @@ public final class DelegatingMethodSecurityMetadataSource extends AbstractMethod
} }
@Override @Override
public boolean equals(@Nullable Object other) { public boolean equals(Object other) {
if (!(other instanceof DefaultCacheKey otherKey)) { DefaultCacheKey otherKey = (DefaultCacheKey) other;
return false;
}
return (this.method.equals(otherKey.method) return (this.method.equals(otherKey.method)
&& ObjectUtils.nullSafeEquals(this.targetClass, otherKey.targetClass)); && ObjectUtils.nullSafeEquals(this.targetClass, otherKey.targetClass));
} }

View File

@ -265,7 +265,7 @@ public class MapBasedMethodSecurityMetadataSource extends AbstractFallbackMethod
} }
@Override @Override
public boolean equals(@Nullable Object obj) { public boolean equals(Object obj) {
if (this == obj) { if (this == obj) {
return true; return true;
} }

View File

@ -145,7 +145,6 @@ public class PrePostAdviceReactiveMethodInterceptor implements MethodInterceptor
.map((r) -> (attr != null) ? this.postAdvice.after(auth, invocation, attr, r) : r)); .map((r) -> (attr != null) ? this.postAdvice.after(auth, invocation, attr, r) : r));
} }
@SuppressWarnings("unchecked")
private static <T extends Publisher<?>> @Nullable T proceed(final MethodInvocation invocation) { private static <T extends Publisher<?>> @Nullable T proceed(final MethodInvocation invocation) {
try { try {
return (T) invocation.proceed(); return (T) invocation.proceed();

View File

@ -111,7 +111,6 @@ public class AclEntryAfterInvocationCollectionFilteringProvider extends Abstract
return returnedObject; return returnedObject;
} }
@SuppressWarnings({ "unchecked", "rawtypes" })
private Filterer getFilterer(Object returnedObject) { private Filterer getFilterer(Object returnedObject) {
if (returnedObject instanceof Collection) { if (returnedObject instanceof Collection) {
return new CollectionFilterer((Collection) returnedObject); return new CollectionFilterer((Collection) returnedObject);

View File

@ -50,7 +50,6 @@ class MessageExpressionConfigAttribute implements ConfigAttribute, EvaluationCon
* @param authorizeExpression the {@link Expression} to use. Cannot be null * @param authorizeExpression the {@link Expression} to use. Cannot be null
* @param matcher the {@link MessageMatcher} used to match the messages. * @param matcher the {@link MessageMatcher} used to match the messages.
*/ */
@SuppressWarnings("unchecked")
MessageExpressionConfigAttribute(Expression authorizeExpression, MessageMatcher<?> matcher) { MessageExpressionConfigAttribute(Expression authorizeExpression, MessageMatcher<?> matcher) {
Assert.notNull(authorizeExpression, "authorizeExpression cannot be null"); Assert.notNull(authorizeExpression, "authorizeExpression cannot be null");
Assert.notNull(matcher, "matcher cannot be null"); Assert.notNull(matcher, "matcher cannot be null");

View File

@ -41,7 +41,6 @@ public class DefaultWebSecurityExpressionHandler extends AbstractSecurityExpress
private String defaultRolePrefix = DEFAULT_ROLE_PREFIX; private String defaultRolePrefix = DEFAULT_ROLE_PREFIX;
@Override @Override
@SuppressWarnings("deprecation")
protected SecurityExpressionOperations createSecurityExpressionRoot(@Nullable Authentication authentication, protected SecurityExpressionOperations createSecurityExpressionRoot(@Nullable Authentication authentication,
FilterInvocation fi) { FilterInvocation fi) {
FilterInvocationExpressionRoot root = new FilterInvocationExpressionRoot(() -> authentication, fi); FilterInvocationExpressionRoot root = new FilterInvocationExpressionRoot(() -> authentication, fi);

View File

@ -29,7 +29,6 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
* *
* @author Ben Alex * @author Ben Alex
*/ */
@SuppressWarnings("deprecation")
public class AuthenticationCredentialsNotFoundEventTests { public class AuthenticationCredentialsNotFoundEventTests {
@Test @Test

View File

@ -32,7 +32,6 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
* *
* @author Ben Alex * @author Ben Alex
*/ */
@SuppressWarnings("deprecation")
public class AuthorizationFailureEventTests { public class AuthorizationFailureEventTests {
private final UsernamePasswordAuthenticationToken foo = UsernamePasswordAuthenticationToken.unauthenticated("foo", private final UsernamePasswordAuthenticationToken foo = UsernamePasswordAuthenticationToken.unauthenticated("foo",

View File

@ -29,7 +29,6 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
* *
* @author Ben Alex * @author Ben Alex
*/ */
@SuppressWarnings("deprecation")
public class AuthorizedEventTests { public class AuthorizedEventTests {
@Test @Test

View File

@ -27,7 +27,6 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
* *
* @author Ben Alex * @author Ben Alex
*/ */
@SuppressWarnings("deprecation")
public class SecurityConfigTests { public class SecurityConfigTests {
@Test @Test

View File

@ -32,7 +32,6 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Luke Taylor * @author Luke Taylor
* @author Ben Alex * @author Ben Alex
*/ */
@SuppressWarnings("deprecation")
public class Jsr250MethodSecurityMetadataSourceTests { public class Jsr250MethodSecurityMetadataSourceTests {
Jsr250MethodSecurityMetadataSource mds; Jsr250MethodSecurityMetadataSource mds;

View File

@ -31,7 +31,6 @@ import static org.assertj.core.api.Assertions.assertThat;
/** /**
* @author Luke Taylor * @author Luke Taylor
*/ */
@SuppressWarnings("deprecation")
public class Jsr250VoterTests { public class Jsr250VoterTests {
// SEC-1443 // SEC-1443

View File

@ -46,7 +46,6 @@ import static org.assertj.core.api.Assertions.fail;
* @author Ben Alex * @author Ben Alex
* @author Luke Taylor * @author Luke Taylor
*/ */
@SuppressWarnings("deprecation")
public class SecuredAnnotationSecurityMetadataSourceTests { public class SecuredAnnotationSecurityMetadataSourceTests {
private SecuredAnnotationSecurityMetadataSource mds = new SecuredAnnotationSecurityMetadataSource(); private SecuredAnnotationSecurityMetadataSource mds = new SecuredAnnotationSecurityMetadataSource();

View File

@ -79,13 +79,11 @@ public class DefaultMethodSecurityExpressionHandlerTests {
} }
@Test @Test
@SuppressWarnings("deprecation")
public void setTrustResolverNull() { public void setTrustResolverNull() {
assertThatIllegalArgumentException().isThrownBy(() -> this.handler.setTrustResolver(null)); assertThatIllegalArgumentException().isThrownBy(() -> this.handler.setTrustResolver(null));
} }
@Test @Test
@SuppressWarnings("deprecation")
public void createEvaluationContextCustomTrustResolver() { public void createEvaluationContextCustomTrustResolver() {
setupMocks(); setupMocks();
this.handler.setTrustResolver(this.trustResolver); this.handler.setTrustResolver(this.trustResolver);
@ -177,7 +175,7 @@ public class DefaultMethodSecurityExpressionHandlerTests {
@Test @Test
public void createEvaluationContextSupplierAuthentication() { public void createEvaluationContextSupplierAuthentication() {
setupMocks(); setupMocks();
Supplier<Authentication> mockAuthenticationSupplier = mock(); Supplier<Authentication> mockAuthenticationSupplier = mock(Supplier.class);
given(mockAuthenticationSupplier.get()).willReturn(this.authentication); given(mockAuthenticationSupplier.get()).willReturn(this.authentication);
EvaluationContext context = this.handler.createEvaluationContext(mockAuthenticationSupplier, EvaluationContext context = this.handler.createEvaluationContext(mockAuthenticationSupplier,
this.methodInvocation); this.methodInvocation);

View File

@ -39,7 +39,6 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
* @since 5.2 * @since 5.2
*/ */
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
@SuppressWarnings("deprecation")
public class ExpressionBasedPreInvocationAdviceTests { public class ExpressionBasedPreInvocationAdviceTests {
@Mock @Mock

View File

@ -34,7 +34,7 @@ import org.springframework.security.util.SimpleMethodInvocation;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
@SuppressWarnings({ "unchecked", "deprecation" }) @SuppressWarnings("unchecked")
public class MethodExpressionVoterTests { public class MethodExpressionVoterTests {
private TestingAuthenticationToken joe = new TestingAuthenticationToken("joe", "joespass", "ROLE_blah"); private TestingAuthenticationToken joe = new TestingAuthenticationToken("joe", "joespass", "ROLE_blah");

View File

@ -27,7 +27,6 @@ import org.springframework.expression.spel.support.StandardEvaluationContext;
import org.springframework.security.access.PermissionEvaluator; import org.springframework.security.access.PermissionEvaluator;
import org.springframework.security.access.expression.ExpressionUtils; import org.springframework.security.access.expression.ExpressionUtils;
import org.springframework.security.authentication.AuthenticationTrustResolver; import org.springframework.security.authentication.AuthenticationTrustResolver;
import org.springframework.security.authorization.DefaultAuthorizationManagerFactory;
import org.springframework.security.core.Authentication; import org.springframework.security.core.Authentication;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
@ -59,9 +58,7 @@ public class MethodSecurityExpressionRootTests {
this.ctx = new StandardEvaluationContext(); this.ctx = new StandardEvaluationContext();
this.ctx.setRootObject(this.root); this.ctx.setRootObject(this.root);
this.trustResolver = mock(AuthenticationTrustResolver.class); this.trustResolver = mock(AuthenticationTrustResolver.class);
DefaultAuthorizationManagerFactory<MethodInvocation> authorizationManagerFactory = new DefaultAuthorizationManagerFactory<>(); this.root.setTrustResolver(this.trustResolver);
authorizationManagerFactory.setTrustResolver(this.trustResolver);
this.root.setAuthorizationManagerFactory(authorizationManagerFactory);
} }
@Test @Test

View File

@ -44,7 +44,6 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Luke Taylor * @author Luke Taylor
* @since 3.0 * @since 3.0
*/ */
@SuppressWarnings("deprecation")
public class PrePostAnnotationSecurityMetadataSourceTests { public class PrePostAnnotationSecurityMetadataSourceTests {
private PrePostAnnotationSecurityMetadataSource mds = new PrePostAnnotationSecurityMetadataSource( private PrePostAnnotationSecurityMetadataSource mds = new PrePostAnnotationSecurityMetadataSource(

View File

@ -32,7 +32,6 @@ import static org.mockito.Mockito.mock;
* *
* @author Ben Alex * @author Ben Alex
*/ */
@SuppressWarnings("deprecation")
public class AbstractSecurityInterceptorTests { public class AbstractSecurityInterceptorTests {
@Test @Test

View File

@ -38,7 +38,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
* *
* @author Ben Alex * @author Ben Alex
*/ */
@SuppressWarnings({ "unchecked", "deprecation" }) @SuppressWarnings("unchecked")
public class AfterInvocationProviderManagerTests { public class AfterInvocationProviderManagerTests {
@Test @Test

View File

@ -34,7 +34,6 @@ import static org.assertj.core.api.Assertions.assertThat;
* *
* @author Ben Alex * @author Ben Alex
*/ */
@SuppressWarnings("deprecation")
public class InterceptorStatusTokenTests { public class InterceptorStatusTokenTests {
@Test @Test

View File

@ -27,7 +27,6 @@ import static org.assertj.core.api.Assertions.assertThat;
* *
* @author Ben Alex * @author Ben Alex
*/ */
@SuppressWarnings("deprecation")
public class NullRunAsManagerTests { public class NullRunAsManagerTests {
@Test @Test

View File

@ -31,7 +31,6 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
/** /**
* Tests {@link RunAsImplAuthenticationProvider}. * Tests {@link RunAsImplAuthenticationProvider}.
*/ */
@SuppressWarnings("deprecation")
public class RunAsImplAuthenticationProviderTests { public class RunAsImplAuthenticationProviderTests {
@Test @Test

View File

@ -34,7 +34,6 @@ import static org.assertj.core.api.Assertions.fail;
* *
* @author Ben Alex * @author Ben Alex
*/ */
@SuppressWarnings("deprecation")
public class RunAsManagerImplTests { public class RunAsManagerImplTests {
@Test @Test

View File

@ -29,7 +29,6 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
* *
* @author Ben Alex * @author Ben Alex
*/ */
@SuppressWarnings("deprecation")
public class RunAsUserTokenTests { public class RunAsUserTokenTests {
@Test @Test

View File

@ -65,7 +65,7 @@ import static org.mockito.Mockito.verifyNoMoreInteractions;
* @author Ben Alex * @author Ben Alex
* @author Rob Winch * @author Rob Winch
*/ */
@SuppressWarnings({ "unchecked", "deprecation" }) @SuppressWarnings("unchecked")
public class MethodSecurityInterceptorTests { public class MethodSecurityInterceptorTests {
private TestingAuthenticationToken token; private TestingAuthenticationToken token;

View File

@ -33,7 +33,6 @@ import static org.mockito.Mockito.mock;
* *
* @author Ben Alex * @author Ben Alex
*/ */
@SuppressWarnings("deprecation")
public class MethodSecurityMetadataSourceAdvisorTests { public class MethodSecurityMetadataSourceAdvisorTests {
@Test @Test

View File

@ -62,7 +62,6 @@ import static org.mockito.Mockito.verifyNoMoreInteractions;
* @author Luke Taylor * @author Luke Taylor
* @author Rob Winch * @author Rob Winch
*/ */
@SuppressWarnings("deprecation")
public class AspectJMethodSecurityInterceptorTests { public class AspectJMethodSecurityInterceptorTests {
private TestingAuthenticationToken token; private TestingAuthenticationToken token;

View File

@ -34,7 +34,6 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Luke Taylor * @author Luke Taylor
* @since 2.0.4 * @since 2.0.4
*/ */
@SuppressWarnings("deprecation")
public class MapBasedMethodSecurityMetadataSourceTests { public class MapBasedMethodSecurityMetadataSourceTests {
private final List<ConfigAttribute> ROLE_A = SecurityConfig.createList("ROLE_A"); private final List<ConfigAttribute> ROLE_A = SecurityConfig.createList("ROLE_A");

View File

@ -49,7 +49,6 @@ import static org.mockito.Mockito.mock;
* *
* @author Ben Alex * @author Ben Alex
*/ */
@SuppressWarnings("deprecation")
public class MethodInvocationPrivilegeEvaluatorTests { public class MethodInvocationPrivilegeEvaluatorTests {
private TestingAuthenticationToken token; private TestingAuthenticationToken token;

View File

@ -36,7 +36,7 @@ import static org.mockito.Mockito.mock;
/** /**
* @author Luke Taylor * @author Luke Taylor
*/ */
@SuppressWarnings({ "unchecked", "deprecation" }) @SuppressWarnings({ "unchecked" })
public class DelegatingMethodSecurityMetadataSourceTests { public class DelegatingMethodSecurityMetadataSourceTests {
DelegatingMethodSecurityMetadataSource mds; DelegatingMethodSecurityMetadataSource mds;

View File

@ -29,7 +29,6 @@ import org.springframework.security.access.intercept.aspectj.MethodInvocationAda
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
@SuppressWarnings("deprecation")
public class PostInvocationAdviceProviderTests { public class PostInvocationAdviceProviderTests {
@Mock @Mock

View File

@ -29,7 +29,6 @@ import org.springframework.security.access.intercept.aspectj.MethodInvocationAda
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
@SuppressWarnings("deprecation")
public class PreInvocationAuthorizationAdviceVoterTests { public class PreInvocationAuthorizationAdviceVoterTests {
@Mock @Mock

View File

@ -36,7 +36,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
* *
* @author Ben Alex * @author Ben Alex
*/ */
@SuppressWarnings({ "unchecked", "deprecation" }) @SuppressWarnings("unchecked")
public class AbstractAccessDecisionManagerTests { public class AbstractAccessDecisionManagerTests {
@Test @Test

View File

@ -31,7 +31,6 @@ import static org.assertj.core.api.Assertions.assertThat;
/** /**
* @author Luke Taylor * @author Luke Taylor
*/ */
@SuppressWarnings("deprecation")
public class AbstractAclVoterTests { public class AbstractAclVoterTests {
private AbstractAclVoter voter = new AbstractAclVoter() { private AbstractAclVoter voter = new AbstractAclVoter() {

View File

@ -40,7 +40,6 @@ import static org.mockito.Mockito.mock;
* *
* @author Ben Alex * @author Ben Alex
*/ */
@SuppressWarnings("deprecation")
public class AffirmativeBasedTests { public class AffirmativeBasedTests {
private final List<ConfigAttribute> attrs = new ArrayList<>(); private final List<ConfigAttribute> attrs = new ArrayList<>();

View File

@ -37,7 +37,6 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
* *
* @author Ben Alex * @author Ben Alex
*/ */
@SuppressWarnings("deprecation")
public class AuthenticatedVoterTests { public class AuthenticatedVoterTests {
private Authentication createAnonymous() { private Authentication createAnonymous() {

View File

@ -35,7 +35,6 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
* *
* @author Ben Alex * @author Ben Alex
*/ */
@SuppressWarnings("deprecation")
public class ConsensusBasedTests { public class ConsensusBasedTests {
@Test @Test

View File

@ -32,7 +32,6 @@ import org.springframework.security.core.Authentication;
* *
* @author Ben Alex * @author Ben Alex
*/ */
@SuppressWarnings("deprecation")
public class DenyAgainVoter implements AccessDecisionVoter<Object> { public class DenyAgainVoter implements AccessDecisionVoter<Object> {
@Override @Override

View File

@ -34,7 +34,6 @@ import org.springframework.security.core.Authentication;
* *
* @author Ben Alex * @author Ben Alex
*/ */
@SuppressWarnings("deprecation")
public class DenyVoter implements AccessDecisionVoter<Object> { public class DenyVoter implements AccessDecisionVoter<Object> {
@Override @Override

View File

@ -25,7 +25,6 @@ import org.springframework.security.authentication.TestingAuthenticationToken;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@SuppressWarnings("deprecation")
public class RoleHierarchyVoterTests { public class RoleHierarchyVoterTests {
@Test @Test

View File

@ -28,7 +28,6 @@ import static org.assertj.core.api.Assertions.assertThat;
/** /**
* @author Luke Taylor * @author Luke Taylor
*/ */
@SuppressWarnings("deprecation")
public class RoleVoterTests { public class RoleVoterTests {
@Test @Test

View File

@ -35,7 +35,6 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
* *
* @author Ben Alex * @author Ben Alex
*/ */
@SuppressWarnings("deprecation")
public class UnanimousBasedTests { public class UnanimousBasedTests {
private UnanimousBased makeDecisionManager() { private UnanimousBased makeDecisionManager() {

View File

@ -44,7 +44,7 @@ import static org.mockito.Mockito.verify;
/** /**
* @author Luke Taylor * @author Luke Taylor
*/ */
@SuppressWarnings({ "unchecked", "deprecation" }) @SuppressWarnings({ "unchecked" })
public class AclEntryAfterInvocationCollectionFilteringProviderTests { public class AclEntryAfterInvocationCollectionFilteringProviderTests {
@Test @Test

View File

@ -48,7 +48,7 @@ import static org.mockito.Mockito.verify;
/** /**
* @author Luke Taylor * @author Luke Taylor
*/ */
@SuppressWarnings({ "unchecked", "deprecation" }) @SuppressWarnings({ "unchecked" })
public class AclEntryAfterInvocationProviderTests { public class AclEntryAfterInvocationProviderTests {
@Test @Test

View File

@ -35,7 +35,6 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.given;
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
@SuppressWarnings("deprecation")
public class ExpressionBasedMessageSecurityMetadataSourceFactoryTests { public class ExpressionBasedMessageSecurityMetadataSourceFactoryTests {
@Mock @Mock
@ -58,7 +57,7 @@ public class ExpressionBasedMessageSecurityMetadataSourceFactoryTests {
MessageSecurityMetadataSource source; MessageSecurityMetadataSource source;
MessageSecurityExpressionRoot<Object> rootObject; MessageSecurityExpressionRoot rootObject;
@BeforeEach @BeforeEach
public void setup() { public void setup() {
@ -69,7 +68,7 @@ public class ExpressionBasedMessageSecurityMetadataSourceFactoryTests {
this.matcherToExpression.put(this.matcher2, this.expression2); this.matcherToExpression.put(this.matcher2, this.expression2);
this.source = ExpressionBasedMessageSecurityMetadataSourceFactory this.source = ExpressionBasedMessageSecurityMetadataSourceFactory
.createExpressionMessageMetadataSource(this.matcherToExpression); .createExpressionMessageMetadataSource(this.matcherToExpression);
this.rootObject = new MessageSecurityExpressionRoot<>(this.authentication, this.message); this.rootObject = new MessageSecurityExpressionRoot(this.authentication, this.message);
} }
@Test @Test

View File

@ -37,7 +37,6 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
@SuppressWarnings("deprecation")
public class MessageExpressionConfigAttributeTests { public class MessageExpressionConfigAttributeTests {
@Mock @Mock

View File

@ -44,7 +44,6 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
@SuppressWarnings("deprecation")
public class MessageExpressionVoterTests { public class MessageExpressionVoterTests {
@Mock @Mock
@ -77,7 +76,6 @@ public class MessageExpressionVoterTests {
} }
@Test @Test
@SuppressWarnings("unchecked")
public void voteGranted() { public void voteGranted() {
given(this.expression.getValue(any(EvaluationContext.class), eq(Boolean.class))).willReturn(true); given(this.expression.getValue(any(EvaluationContext.class), eq(Boolean.class))).willReturn(true);
given(this.matcher.matcher(any())).willCallRealMethod(); given(this.matcher.matcher(any())).willCallRealMethod();
@ -86,7 +84,6 @@ public class MessageExpressionVoterTests {
} }
@Test @Test
@SuppressWarnings("unchecked")
public void voteDenied() { public void voteDenied() {
given(this.expression.getValue(any(EvaluationContext.class), eq(Boolean.class))).willReturn(false); given(this.expression.getValue(any(EvaluationContext.class), eq(Boolean.class))).willReturn(false);
given(this.matcher.matcher(any())).willCallRealMethod(); given(this.matcher.matcher(any())).willCallRealMethod();
@ -95,7 +92,6 @@ public class MessageExpressionVoterTests {
} }
@Test @Test
@SuppressWarnings("unchecked")
public void voteAbstain() { public void voteAbstain() {
this.attributes = Arrays.<ConfigAttribute>asList(new SecurityConfig("ROLE_USER")); this.attributes = Arrays.<ConfigAttribute>asList(new SecurityConfig("ROLE_USER"));
assertThat(this.voter.vote(this.authentication, this.message, this.attributes)) assertThat(this.voter.vote(this.authentication, this.message, this.attributes))
@ -103,13 +99,11 @@ public class MessageExpressionVoterTests {
} }
@Test @Test
@SuppressWarnings("unchecked")
public void supportsObjectClassFalse() { public void supportsObjectClassFalse() {
assertThat(this.voter.supports(Object.class)).isFalse(); assertThat(this.voter.supports(Object.class)).isFalse();
} }
@Test @Test
@SuppressWarnings("unchecked")
public void supportsMessageClassTrue() { public void supportsMessageClassTrue() {
assertThat(this.voter.supports(Message.class)).isTrue(); assertThat(this.voter.supports(Message.class)).isTrue();
} }
@ -125,13 +119,11 @@ public class MessageExpressionVoterTests {
} }
@Test @Test
@SuppressWarnings("unchecked")
public void setExpressionHandlerNull() { public void setExpressionHandlerNull() {
assertThatIllegalArgumentException().isThrownBy(() -> this.voter.setExpressionHandler(null)); assertThatIllegalArgumentException().isThrownBy(() -> this.voter.setExpressionHandler(null));
} }
@Test @Test
@SuppressWarnings("unchecked")
public void customExpressionHandler() { public void customExpressionHandler() {
this.voter.setExpressionHandler(this.expressionHandler); this.voter.setExpressionHandler(this.expressionHandler);
given(this.expressionHandler.createEvaluationContext(this.authentication, this.message)) given(this.expressionHandler.createEvaluationContext(this.authentication, this.message))
@ -144,7 +136,6 @@ public class MessageExpressionVoterTests {
} }
@Test @Test
@SuppressWarnings("unchecked")
public void postProcessEvaluationContext() { public void postProcessEvaluationContext() {
final MessageExpressionConfigAttribute configAttribute = mock(MessageExpressionConfigAttribute.class); final MessageExpressionConfigAttribute configAttribute = mock(MessageExpressionConfigAttribute.class);
this.voter.setExpressionHandler(this.expressionHandler); this.voter.setExpressionHandler(this.expressionHandler);

View File

@ -47,7 +47,6 @@ import static org.mockito.BDDMockito.given;
import static org.mockito.BDDMockito.willThrow; import static org.mockito.BDDMockito.willThrow;
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
@SuppressWarnings("deprecation")
public class ChannelSecurityInterceptorTests { public class ChannelSecurityInterceptorTests {
@Mock @Mock

View File

@ -36,7 +36,6 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.given;
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
@SuppressWarnings("deprecation")
public class DefaultMessageSecurityMetadataSourceTests { public class DefaultMessageSecurityMetadataSourceTests {
@Mock @Mock

View File

@ -43,7 +43,6 @@ import org.springframework.security.web.access.intercept.FilterSecurityIntercept
* *
* @author Ben Alex * @author Ben Alex
*/ */
@SuppressWarnings("deprecation")
public class DefaultWebInvocationPrivilegeEvaluatorTests { public class DefaultWebInvocationPrivilegeEvaluatorTests {
private AccessDecisionManager adm; private AccessDecisionManager adm;

View File

@ -42,7 +42,7 @@ import static org.mockito.Mockito.mock;
* *
* @author Ben Alex * @author Ben Alex
*/ */
@SuppressWarnings({ "unchecked", "deprecation" }) @SuppressWarnings("unchecked")
public class ChannelDecisionManagerImplTests { public class ChannelDecisionManagerImplTests {
@Test @Test

View File

@ -39,7 +39,6 @@ import static org.mockito.Mockito.mock;
* *
* @author Ben Alex * @author Ben Alex
*/ */
@SuppressWarnings("deprecation")
public class ChannelProcessingFilterTests { public class ChannelProcessingFilterTests {
@Test @Test

View File

@ -35,7 +35,6 @@ import static org.mockito.Mockito.mock;
* *
* @author Ben Alex * @author Ben Alex
*/ */
@SuppressWarnings("deprecation")
public class InsecureChannelProcessorTests { public class InsecureChannelProcessorTests {
@Test @Test

View File

@ -36,7 +36,6 @@ import static org.mockito.Mockito.mock;
* *
* @author Ben Alex * @author Ben Alex
*/ */
@SuppressWarnings("deprecation")
public class RetryWithHttpEntryPointTests { public class RetryWithHttpEntryPointTests {
@Test @Test

View File

@ -33,7 +33,6 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
* *
* @author Ben Alex * @author Ben Alex
*/ */
@SuppressWarnings("deprecation")
public class RetryWithHttpsEntryPointTests { public class RetryWithHttpsEntryPointTests {
@Test @Test

View File

@ -35,7 +35,6 @@ import static org.mockito.Mockito.mock;
* *
* @author Ben Alex * @author Ben Alex
*/ */
@SuppressWarnings("deprecation")
public class SecureChannelProcessorTests { public class SecureChannelProcessorTests {
@Test @Test

View File

@ -64,7 +64,6 @@ public class DefaultWebSecurityExpressionHandlerTests {
} }
@Test @Test
@SuppressWarnings("deprecation")
public void expressionPropertiesAreResolvedAgainstAppContextBeans() { public void expressionPropertiesAreResolvedAgainstAppContextBeans() {
StaticApplicationContext appContext = new StaticApplicationContext(); StaticApplicationContext appContext = new StaticApplicationContext();
RootBeanDefinition bean = new RootBeanDefinition(SecurityConfig.class); RootBeanDefinition bean = new RootBeanDefinition(SecurityConfig.class);
@ -79,13 +78,11 @@ public class DefaultWebSecurityExpressionHandlerTests {
} }
@Test @Test
@SuppressWarnings("deprecation")
public void setTrustResolverNull() { public void setTrustResolverNull() {
assertThatIllegalArgumentException().isThrownBy(() -> this.handler.setTrustResolver(null)); assertThatIllegalArgumentException().isThrownBy(() -> this.handler.setTrustResolver(null));
} }
@Test @Test
@SuppressWarnings("deprecation")
public void createEvaluationContextCustomTrustResolver() { public void createEvaluationContextCustomTrustResolver() {
this.handler.setTrustResolver(this.trustResolver); this.handler.setTrustResolver(this.trustResolver);
Expression expression = this.handler.getExpressionParser().parseExpression("anonymous"); Expression expression = this.handler.getExpressionParser().parseExpression("anonymous");

View File

@ -33,7 +33,6 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
/** /**
* @author Luke Taylor * @author Luke Taylor
*/ */
@SuppressWarnings("deprecation")
public class ExpressionBasedFilterInvocationSecurityMetadataSourceTests { public class ExpressionBasedFilterInvocationSecurityMetadataSourceTests {
@Test @Test

View File

@ -41,7 +41,7 @@ import static org.mockito.Mockito.mock;
/** /**
* @author Luke Taylor * @author Luke Taylor
*/ */
@SuppressWarnings({ "unchecked", "deprecation" }) @SuppressWarnings({ "unchecked" })
public class WebExpressionVoterTests { public class WebExpressionVoterTests {
private Authentication user = new TestingAuthenticationToken("user", "pass", "X"); private Authentication user = new TestingAuthenticationToken("user", "pass", "X");

View File

@ -40,7 +40,6 @@ import static org.mockito.Mockito.mock;
* *
* @author Ben Alex * @author Ben Alex
*/ */
@SuppressWarnings("deprecation")
public class DefaultFilterInvocationSecurityMetadataSourceTests { public class DefaultFilterInvocationSecurityMetadataSourceTests {
private DefaultFilterInvocationSecurityMetadataSource fids; private DefaultFilterInvocationSecurityMetadataSource fids;

View File

@ -62,7 +62,6 @@ import static org.mockito.Mockito.verifyNoMoreInteractions;
* @author Luke Taylor * @author Luke Taylor
* @author Rob Winch * @author Rob Winch
*/ */
@SuppressWarnings("deprecation")
public class FilterSecurityInterceptorTests { public class FilterSecurityInterceptorTests {
private AuthenticationManager am; private AuthenticationManager am;

View File

@ -1,9 +1,3 @@
plugins {
id 'compile-warnings-error'
id 'javadoc-warnings-error'
id 'security-nullability'
}
apply plugin: 'io.spring.convention.spring-module' apply plugin: 'io.spring.convention.spring-module'
dependencies { dependencies {

View File

@ -23,7 +23,6 @@ import java.util.Locale;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.jspecify.annotations.Nullable;
import org.springframework.core.log.LogMessage; import org.springframework.core.log.LogMessage;
import org.springframework.security.access.PermissionEvaluator; import org.springframework.security.access.PermissionEvaluator;
@ -45,7 +44,7 @@ import org.springframework.security.core.Authentication;
/** /**
* Used by Spring Security's expression-based access control implementation to evaluate * Used by Spring Security's expression-based access control implementation to evaluate
* permissions for a particular object using the ACL module. Similar in behaviour to * permissions for a particular object using the ACL module. Similar in behaviour to
* <code> org.springframework.security.acls.AclEntryVoter AclEntryVoter </code> * {@link org.springframework.security.acls.AclEntryVoter AclEntryVoter}.
* *
* @author Luke Taylor * @author Luke Taylor
* @since 3.0 * @since 3.0
@ -74,7 +73,7 @@ public class AclPermissionEvaluator implements PermissionEvaluator {
* be overridden using a null check in the expression itself). * be overridden using a null check in the expression itself).
*/ */
@Override @Override
public boolean hasPermission(Authentication authentication, @Nullable Object domainObject, Object permission) { public boolean hasPermission(Authentication authentication, Object domainObject, Object permission) {
if (domainObject == null) { if (domainObject == null) {
return false; return false;
} }

View File

@ -1,79 +0,0 @@
/*
* Copyright 2004-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.security.acls.aot.hint;
import java.util.stream.Stream;
import org.jspecify.annotations.Nullable;
import org.springframework.aot.hint.MemberCategory;
import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.RuntimeHintsRegistrar;
import org.springframework.aot.hint.TypeReference;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.security.acls.domain.AclImpl;
import org.springframework.security.acls.domain.AuditLogger;
import org.springframework.security.acls.domain.BasePermission;
import org.springframework.security.acls.domain.GrantedAuthoritySid;
import org.springframework.security.acls.domain.ObjectIdentityImpl;
import org.springframework.security.acls.domain.PrincipalSid;
import org.springframework.security.acls.model.AccessControlEntry;
import org.springframework.security.acls.model.Acl;
import org.springframework.security.acls.model.AuditableAccessControlEntry;
import org.springframework.security.acls.model.ObjectIdentity;
import org.springframework.security.acls.model.Sid;
/**
* {@link RuntimeHintsRegistrar} for ACL (Access Control List) classes.
*
* @author Josh Long
*/
class AclRuntimeHints implements RuntimeHintsRegistrar {
@Override
public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader) {
registerAclDomainHints(hints);
registerJdbcSchemaHints(hints);
}
private void registerAclDomainHints(RuntimeHints hints) {
// Register core ACL domain types
Stream
.of(Acl.class, AccessControlEntry.class, AuditableAccessControlEntry.class, ObjectIdentity.class, Sid.class,
AclImpl.class, AccessControlEntry.class, AuditLogger.class, ObjectIdentityImpl.class,
PrincipalSid.class, GrantedAuthoritySid.class, BasePermission.class)
.forEach((c) -> hints.reflection()
.registerType(TypeReference.of(c),
(builder) -> builder.withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS,
MemberCategory.INVOKE_DECLARED_METHODS, MemberCategory.ACCESS_DECLARED_FIELDS)));
}
private void registerJdbcSchemaHints(RuntimeHints hints) {
String[] sqlFiles = new String[] { "createAclSchema.sql", "createAclSchemaMySQL.sql",
"createAclSchemaOracle.sql", "createAclSchemaPostgres.sql", "createAclSchemaSqlServer.sql",
"createAclSchemaWithAclClassIdType.sql", "select.sql" };
for (String sqlFile : sqlFiles) {
Resource sqlResource = new ClassPathResource(sqlFile);
if (sqlResource.exists()) {
hints.resources().registerResource(sqlResource);
}
}
}
}

View File

@ -1,23 +0,0 @@
/*
* Copyright 2004-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* AOT and native image hint support for ACLs.
*/
@NullMarked
package org.springframework.security.acls.aot.hint;
import org.jspecify.annotations.NullMarked;

View File

@ -16,8 +16,6 @@
package org.springframework.security.acls.domain; package org.springframework.security.acls.domain;
import org.jspecify.annotations.Nullable;
import org.springframework.security.acls.model.Permission; import org.springframework.security.acls.model.Permission;
/** /**
@ -54,7 +52,7 @@ public abstract class AbstractPermission implements Permission {
} }
@Override @Override
public final boolean equals(@Nullable Object obj) { public final boolean equals(Object obj) {
if (obj == null) { if (obj == null) {
return false; return false;
} }

View File

@ -18,8 +18,6 @@ package org.springframework.security.acls.domain;
import java.io.Serializable; import java.io.Serializable;
import org.jspecify.annotations.Nullable;
import org.springframework.security.acls.model.AccessControlEntry; import org.springframework.security.acls.model.AccessControlEntry;
import org.springframework.security.acls.model.Acl; import org.springframework.security.acls.model.Acl;
import org.springframework.security.acls.model.AuditableAccessControlEntry; import org.springframework.security.acls.model.AuditableAccessControlEntry;
@ -38,7 +36,7 @@ public class AccessControlEntryImpl implements AccessControlEntry, AuditableAcce
private Permission permission; private Permission permission;
private final @Nullable Serializable id; private final Serializable id;
private final Sid sid; private final Sid sid;
@ -48,7 +46,7 @@ public class AccessControlEntryImpl implements AccessControlEntry, AuditableAcce
private final boolean granting; private final boolean granting;
public AccessControlEntryImpl(@Nullable Serializable id, Acl acl, Sid sid, Permission permission, boolean granting, public AccessControlEntryImpl(Serializable id, Acl acl, Sid sid, Permission permission, boolean granting,
boolean auditSuccess, boolean auditFailure) { boolean auditSuccess, boolean auditFailure) {
Assert.notNull(acl, "Acl required"); Assert.notNull(acl, "Acl required");
Assert.notNull(sid, "Sid required"); Assert.notNull(sid, "Sid required");
@ -63,7 +61,7 @@ public class AccessControlEntryImpl implements AccessControlEntry, AuditableAcce
} }
@Override @Override
public boolean equals(@Nullable Object arg0) { public boolean equals(Object arg0) {
if (!(arg0 instanceof AccessControlEntryImpl)) { if (!(arg0 instanceof AccessControlEntryImpl)) {
return false; return false;
} }
@ -135,7 +133,7 @@ public class AccessControlEntryImpl implements AccessControlEntry, AuditableAcce
} }
@Override @Override
public @Nullable Serializable getId() { public Serializable getId() {
return this.id; return this.id;
} }

View File

@ -99,8 +99,7 @@ public class AclAuthorizationStrategyImpl implements AclAuthorizationStrategy {
Authentication authentication = context.getAuthentication(); Authentication authentication = context.getAuthentication();
// Check if authorized by virtue of ACL ownership // Check if authorized by virtue of ACL ownership
Sid currentUser = createCurrentUser(authentication); Sid currentUser = createCurrentUser(authentication);
Sid owner = acl.getOwner(); if (currentUser.equals(acl.getOwner())
if (owner != null && currentUser.equals(owner)
&& ((changeType == CHANGE_GENERAL) || (changeType == CHANGE_OWNERSHIP))) { && ((changeType == CHANGE_GENERAL) || (changeType == CHANGE_OWNERSHIP))) {
return; return;
} }
@ -109,8 +108,8 @@ public class AclAuthorizationStrategyImpl implements AclAuthorizationStrategy {
Collection<? extends GrantedAuthority> reachableGrantedAuthorities = this.roleHierarchy Collection<? extends GrantedAuthority> reachableGrantedAuthorities = this.roleHierarchy
.getReachableGrantedAuthorities(authentication.getAuthorities()); .getReachableGrantedAuthorities(authentication.getAuthorities());
Set<String> authorities = AuthorityUtils.authorityListToSet(reachableGrantedAuthorities); Set<String> authorities = AuthorityUtils.authorityListToSet(reachableGrantedAuthorities);
if (owner instanceof GrantedAuthoritySid if (acl.getOwner() instanceof GrantedAuthoritySid
&& authorities.contains(((GrantedAuthoritySid) owner).getGrantedAuthority())) { && authorities.contains(((GrantedAuthoritySid) acl.getOwner()).getGrantedAuthority())) {
return; return;
} }

View File

@ -20,8 +20,6 @@ import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.jspecify.annotations.Nullable;
import org.springframework.security.acls.model.AccessControlEntry; import org.springframework.security.acls.model.AccessControlEntry;
import org.springframework.security.acls.model.Acl; import org.springframework.security.acls.model.Acl;
import org.springframework.security.acls.model.AuditableAcl; import org.springframework.security.acls.model.AuditableAcl;
@ -43,7 +41,7 @@ import org.springframework.util.ObjectUtils;
*/ */
public class AclImpl implements Acl, MutableAcl, AuditableAcl, OwnershipAcl { public class AclImpl implements Acl, MutableAcl, AuditableAcl, OwnershipAcl {
private @Nullable Acl parentAcl; private Acl parentAcl;
private transient AclAuthorizationStrategy aclAuthorizationStrategy; private transient AclAuthorizationStrategy aclAuthorizationStrategy;
@ -56,10 +54,10 @@ public class AclImpl implements Acl, MutableAcl, AuditableAcl, OwnershipAcl {
private Serializable id; private Serializable id;
// OwnershipAcl // OwnershipAcl
private @Nullable Sid owner; private Sid owner;
// includes all SIDs the WHERE clause covered, even if there was no ACE for a SID // includes all SIDs the WHERE clause covered, even if there was no ACE for a SID
private @Nullable List<Sid> loadedSids = null; private List<Sid> loadedSids = null;
private boolean entriesInheriting = true; private boolean entriesInheriting = true;
@ -99,8 +97,8 @@ public class AclImpl implements Acl, MutableAcl, AuditableAcl, OwnershipAcl {
* @param owner the owner (required) * @param owner the owner (required)
*/ */
public AclImpl(ObjectIdentity objectIdentity, Serializable id, AclAuthorizationStrategy aclAuthorizationStrategy, public AclImpl(ObjectIdentity objectIdentity, Serializable id, AclAuthorizationStrategy aclAuthorizationStrategy,
PermissionGrantingStrategy grantingStrategy, @Nullable Acl parentAcl, @Nullable List<Sid> loadedSids, PermissionGrantingStrategy grantingStrategy, Acl parentAcl, List<Sid> loadedSids, boolean entriesInheriting,
boolean entriesInheriting, Sid owner) { Sid owner) {
Assert.notNull(objectIdentity, "Object Identity required"); Assert.notNull(objectIdentity, "Object Identity required");
Assert.notNull(id, "Id required"); Assert.notNull(id, "Id required");
Assert.notNull(aclAuthorizationStrategy, "AclAuthorizationStrategy required"); Assert.notNull(aclAuthorizationStrategy, "AclAuthorizationStrategy required");
@ -119,7 +117,7 @@ public class AclImpl implements Acl, MutableAcl, AuditableAcl, OwnershipAcl {
* Private no-argument constructor for use by reflection-based persistence tools along * Private no-argument constructor for use by reflection-based persistence tools along
* with field-level access. * with field-level access.
*/ */
@SuppressWarnings({ "unused", "NullAway.Init" }) @SuppressWarnings("unused")
private AclImpl() { private AclImpl() {
} }
@ -201,7 +199,7 @@ public class AclImpl implements Acl, MutableAcl, AuditableAcl, OwnershipAcl {
} }
@Override @Override
public boolean isSidLoaded(@Nullable List<Sid> sids) { public boolean isSidLoaded(List<Sid> sids) {
// If loadedSides is null, this indicates all SIDs were loaded // If loadedSides is null, this indicates all SIDs were loaded
// Also return true if the caller didn't specify a SID to find // Also return true if the caller didn't specify a SID to find
if ((this.loadedSids == null) || (sids == null) || sids.isEmpty()) { if ((this.loadedSids == null) || (sids == null) || sids.isEmpty()) {
@ -240,19 +238,19 @@ public class AclImpl implements Acl, MutableAcl, AuditableAcl, OwnershipAcl {
} }
@Override @Override
public @Nullable Sid getOwner() { public Sid getOwner() {
return this.owner; return this.owner;
} }
@Override @Override
public void setParent(@Nullable Acl newParent) { public void setParent(Acl newParent) {
this.aclAuthorizationStrategy.securityCheck(this, AclAuthorizationStrategy.CHANGE_GENERAL); this.aclAuthorizationStrategy.securityCheck(this, AclAuthorizationStrategy.CHANGE_GENERAL);
Assert.isTrue(newParent == null || !newParent.equals(this), "Cannot be the parent of yourself"); Assert.isTrue(newParent == null || !newParent.equals(this), "Cannot be the parent of yourself");
this.parentAcl = newParent; this.parentAcl = newParent;
} }
@Override @Override
public @Nullable Acl getParentAcl() { public Acl getParentAcl() {
return this.parentAcl; return this.parentAcl;
} }
@ -278,7 +276,7 @@ public class AclImpl implements Acl, MutableAcl, AuditableAcl, OwnershipAcl {
} }
@Override @Override
public boolean equals(@Nullable Object obj) { public boolean equals(Object obj) {
if (obj == this) { if (obj == this) {
return true; return true;
} }

View File

@ -16,8 +16,6 @@
package org.springframework.security.acls.domain; package org.springframework.security.acls.domain;
import org.jspecify.annotations.Nullable;
import org.springframework.security.acls.model.Sid; import org.springframework.security.acls.model.Sid;
import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.GrantedAuthority;
import org.springframework.util.Assert; import org.springframework.util.Assert;
@ -49,7 +47,7 @@ public class GrantedAuthoritySid implements Sid {
} }
@Override @Override
public boolean equals(@Nullable Object object) { public boolean equals(Object object) {
if ((object == null) || !(object instanceof GrantedAuthoritySid)) { if ((object == null) || !(object instanceof GrantedAuthoritySid)) {
return false; return false;
} }

View File

@ -19,8 +19,6 @@ package org.springframework.security.acls.domain;
import java.io.Serializable; import java.io.Serializable;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import org.jspecify.annotations.Nullable;
import org.springframework.security.acls.model.ObjectIdentity; import org.springframework.security.acls.model.ObjectIdentity;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.ClassUtils; import org.springframework.util.ClassUtils;
@ -99,7 +97,7 @@ public class ObjectIdentityImpl implements ObjectIdentity {
* @return <code>true</code> if the presented object matches this object * @return <code>true</code> if the presented object matches this object
*/ */
@Override @Override
public boolean equals(@Nullable Object obj) { public boolean equals(Object obj) {
if (obj == null || !(obj instanceof ObjectIdentityImpl)) { if (obj == null || !(obj instanceof ObjectIdentityImpl)) {
return false; return false;
} }

View File

@ -16,8 +16,6 @@
package org.springframework.security.acls.domain; package org.springframework.security.acls.domain;
import org.jspecify.annotations.Nullable;
import org.springframework.security.acls.model.Sid; import org.springframework.security.acls.model.Sid;
import org.springframework.security.core.Authentication; import org.springframework.security.core.Authentication;
import org.springframework.util.Assert; import org.springframework.util.Assert;
@ -48,7 +46,7 @@ public class PrincipalSid implements Sid {
} }
@Override @Override
public boolean equals(@Nullable Object object) { public boolean equals(Object object) {
if ((object == null) || !(object instanceof PrincipalSid)) { if ((object == null) || !(object instanceof PrincipalSid)) {
return false; return false;
} }

View File

@ -18,8 +18,6 @@ package org.springframework.security.acls.domain;
import java.io.Serializable; import java.io.Serializable;
import org.jspecify.annotations.Nullable;
import org.springframework.cache.Cache; import org.springframework.cache.Cache;
import org.springframework.security.acls.model.AclCache; import org.springframework.security.acls.model.AclCache;
import org.springframework.security.acls.model.MutableAcl; import org.springframework.security.acls.model.MutableAcl;
@ -80,13 +78,13 @@ public class SpringCacheBasedAclCache implements AclCache {
} }
@Override @Override
public @Nullable MutableAcl getFromCache(ObjectIdentity objectIdentity) { public MutableAcl getFromCache(ObjectIdentity objectIdentity) {
Assert.notNull(objectIdentity, "ObjectIdentity required"); Assert.notNull(objectIdentity, "ObjectIdentity required");
return getFromCache((Object) objectIdentity); return getFromCache((Object) objectIdentity);
} }
@Override @Override
public @Nullable MutableAcl getFromCache(Serializable pk) { public MutableAcl getFromCache(Serializable pk) {
Assert.notNull(pk, "Primary key (identifier) required"); Assert.notNull(pk, "Primary key (identifier) required");
return getFromCache((Object) pk); return getFromCache((Object) pk);
} }
@ -103,16 +101,12 @@ public class SpringCacheBasedAclCache implements AclCache {
this.cache.put(acl.getId(), acl); this.cache.put(acl.getId(), acl);
} }
private @Nullable MutableAcl getFromCache(Object key) { private MutableAcl getFromCache(Object key) {
Cache.ValueWrapper element = this.cache.get(key); Cache.ValueWrapper element = this.cache.get(key);
if (element == null) { if (element == null) {
return null; return null;
} }
Object value = element.get(); return initializeTransientFields((MutableAcl) element.get());
if (value == null) {
return null;
}
return initializeTransientFields((MutableAcl) value);
} }
private MutableAcl initializeTransientFields(MutableAcl value) { private MutableAcl initializeTransientFields(MutableAcl value) {

View File

@ -17,7 +17,4 @@
/** /**
* Basic implementation of access control lists (ACLs) interfaces. * Basic implementation of access control lists (ACLs) interfaces.
*/ */
@NullMarked
package org.springframework.security.acls.domain; package org.springframework.security.acls.domain;
import org.jspecify.annotations.NullMarked;

View File

@ -23,7 +23,6 @@ import java.util.UUID;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.jspecify.annotations.Nullable;
import org.springframework.core.convert.ConversionFailedException; import org.springframework.core.convert.ConversionFailedException;
import org.springframework.core.convert.ConversionService; import org.springframework.core.convert.ConversionService;
@ -68,10 +67,10 @@ class AclClassIdUtils {
* @return The identifier in the appropriate target Java type. Typically Long or UUID. * @return The identifier in the appropriate target Java type. Typically Long or UUID.
* @throws SQLException * @throws SQLException
*/ */
@Nullable Serializable identifierFrom(Serializable identifier, ResultSet resultSet) throws SQLException { Serializable identifierFrom(Serializable identifier, ResultSet resultSet) throws SQLException {
Class<? extends Serializable> classIdType = classIdTypeFrom(resultSet); if (isString(identifier) && hasValidClassIdType(resultSet)
if (isString(identifier) && classIdType != null && canConvertFromStringTo(classIdType)) { && canConvertFromStringTo(classIdTypeFrom(resultSet))) {
return convertFromStringTo((String) identifier, classIdType); return convertFromStringTo((String) identifier, classIdTypeFrom(resultSet));
} }
// Assume it should be a Long type // Assume it should be a Long type
return convertToLong(identifier); return convertToLong(identifier);
@ -87,38 +86,28 @@ class AclClassIdUtils {
} }
} }
private @Nullable Class<? extends Serializable> classIdTypeFrom(ResultSet resultSet) throws SQLException { private <T extends Serializable> Class<T> classIdTypeFrom(ResultSet resultSet) throws SQLException {
try { return classIdTypeFrom(resultSet.getString(DEFAULT_CLASS_ID_TYPE_COLUMN_NAME));
return classIdTypeFrom(resultSet.getString(DEFAULT_CLASS_ID_TYPE_COLUMN_NAME));
}
catch (SQLException ex) {
log.debug("Unable to obtain the class id type", ex);
return null;
}
} }
private @Nullable Class<? extends Serializable> classIdTypeFrom(String className) { private <T extends Serializable> Class<T> classIdTypeFrom(String className) {
if (className == null) { if (className == null) {
return null; return null;
} }
try { try {
return Class.forName(className).asSubclass(Serializable.class); return (Class) Class.forName(className);
} }
catch (ClassNotFoundException ex) { catch (ClassNotFoundException ex) {
log.debug("Unable to find class id type on classpath", ex); log.debug("Unable to find class id type on classpath", ex);
return null; return null;
} }
catch (ClassCastException ex) {
log.debug("Class id type is not a Serializable type", ex);
return null;
}
} }
private <T> boolean canConvertFromStringTo(Class<T> targetType) { private <T> boolean canConvertFromStringTo(Class<T> targetType) {
return this.conversionService.canConvert(String.class, targetType); return this.conversionService.canConvert(String.class, targetType);
} }
private <T extends Serializable> @Nullable T convertFromStringTo(String identifier, Class<T> targetType) { private <T extends Serializable> T convertFromStringTo(String identifier, Class<T> targetType) {
return this.conversionService.convert(identifier, targetType); return this.conversionService.convert(identifier, targetType);
} }
@ -132,7 +121,7 @@ class AclClassIdUtils {
* exception occurred * exception occurred
* @throws IllegalArgumentException if targetType is null * @throws IllegalArgumentException if targetType is null
*/ */
private @Nullable Long convertToLong(Serializable identifier) { private Long convertToLong(Serializable identifier) {
if (this.conversionService.canConvert(identifier.getClass(), Long.class)) { if (this.conversionService.canConvert(identifier.getClass(), Long.class)) {
return this.conversionService.convert(identifier, Long.class); return this.conversionService.convert(identifier, Long.class);
} }
@ -151,10 +140,10 @@ class AclClassIdUtils {
private static class StringToLongConverter implements Converter<String, Long> { private static class StringToLongConverter implements Converter<String, Long> {
@Override @Override
public Long convert(@Nullable String identifierAsString) { public Long convert(String identifierAsString) {
if (identifierAsString == null) { if (identifierAsString == null) {
throw new ConversionFailedException(TypeDescriptor.valueOf(String.class), throw new ConversionFailedException(TypeDescriptor.valueOf(String.class),
TypeDescriptor.valueOf(Long.class), identifierAsString, new NullPointerException()); TypeDescriptor.valueOf(Long.class), null, null);
} }
return Long.parseLong(identifierAsString); return Long.parseLong(identifierAsString);
@ -165,10 +154,10 @@ class AclClassIdUtils {
private static class StringToUUIDConverter implements Converter<String, UUID> { private static class StringToUUIDConverter implements Converter<String, UUID> {
@Override @Override
public UUID convert(@Nullable String identifierAsString) { public UUID convert(String identifierAsString) {
if (identifierAsString == null) { if (identifierAsString == null) {
throw new ConversionFailedException(TypeDescriptor.valueOf(String.class), throw new ConversionFailedException(TypeDescriptor.valueOf(String.class),
TypeDescriptor.valueOf(UUID.class), identifierAsString, new NullPointerException()); TypeDescriptor.valueOf(UUID.class), null, null);
} }
return UUID.fromString(identifierAsString); return UUID.fromString(identifierAsString);

View File

@ -31,8 +31,6 @@ import java.util.Set;
import javax.sql.DataSource; import javax.sql.DataSource;
import org.jspecify.annotations.Nullable;
import org.springframework.core.convert.ConversionException; import org.springframework.core.convert.ConversionException;
import org.springframework.core.convert.ConversionService; import org.springframework.core.convert.ConversionService;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
@ -226,8 +224,7 @@ public class BasicLookupStrategy implements LookupStrategy {
* @param findNow Long-based primary keys to retrieve * @param findNow Long-based primary keys to retrieve
* @param sids * @param sids
*/ */
private void lookupPrimaryKeys(final Map<Serializable, Acl> acls, final Set<Long> findNow, private void lookupPrimaryKeys(final Map<Serializable, Acl> acls, final Set<Long> findNow, final List<Sid> sids) {
final @Nullable List<Sid> sids) {
Assert.notNull(acls, "ACLs are required"); Assert.notNull(acls, "ACLs are required");
Assert.notEmpty(findNow, "Items to find now required"); Assert.notEmpty(findNow, "Items to find now required");
String sql = computeRepeatingSql(this.lookupPrimaryKeysWhereClause, findNow.size()); String sql = computeRepeatingSql(this.lookupPrimaryKeysWhereClause, findNow.size());
@ -267,7 +264,7 @@ public class BasicLookupStrategy implements LookupStrategy {
* automatically create entries if required) * automatically create entries if required)
*/ */
@Override @Override
public final Map<ObjectIdentity, Acl> readAclsById(List<ObjectIdentity> objects, @Nullable List<Sid> sids) { public final Map<ObjectIdentity, Acl> readAclsById(List<ObjectIdentity> objects, List<Sid> sids) {
Assert.isTrue(this.batchSize >= 1, "BatchSize must be >= 1"); Assert.isTrue(this.batchSize >= 1, "BatchSize must be >= 1");
Assert.notEmpty(objects, "Objects to lookup required"); Assert.notEmpty(objects, "Objects to lookup required");
// Map<ObjectIdentity,Acl> // Map<ObjectIdentity,Acl>
@ -326,7 +323,7 @@ public class BasicLookupStrategy implements LookupStrategy {
* properly-configured parent ACLs. * properly-configured parent ACLs.
*/ */
private Map<ObjectIdentity, Acl> lookupObjectIdentities(final Collection<ObjectIdentity> objectIdentities, private Map<ObjectIdentity, Acl> lookupObjectIdentities(final Collection<ObjectIdentity> objectIdentities,
@Nullable List<Sid> sids) { List<Sid> sids) {
Assert.notEmpty(objectIdentities, "Must provide identities to lookup"); Assert.notEmpty(objectIdentities, "Must provide identities to lookup");
// contains Acls with StubAclParents // contains Acls with StubAclParents
@ -402,10 +399,8 @@ public class BasicLookupStrategy implements LookupStrategy {
} }
// Now we have the parent (if there is one), create the true AclImpl // Now we have the parent (if there is one), create the true AclImpl
Sid owner = inputAcl.getOwner();
Assert.isTrue(owner != null, "Owner is required");
AclImpl result = new AclImpl(inputAcl.getObjectIdentity(), inputAcl.getId(), this.aclAuthorizationStrategy, AclImpl result = new AclImpl(inputAcl.getObjectIdentity(), inputAcl.getId(), this.aclAuthorizationStrategy,
this.grantingStrategy, parent, null, inputAcl.isEntriesInheriting(), owner); this.grantingStrategy, parent, null, inputAcl.isEntriesInheriting(), inputAcl.getOwner());
// Copy the "aces" from the input to the destination // Copy the "aces" from the input to the destination
@ -511,9 +506,9 @@ public class BasicLookupStrategy implements LookupStrategy {
private final Map<Serializable, Acl> acls; private final Map<Serializable, Acl> acls;
private final @Nullable List<Sid> sids; private final List<Sid> sids;
ProcessResultSet(Map<Serializable, Acl> acls, @Nullable List<Sid> sids) { ProcessResultSet(Map<Serializable, Acl> acls, List<Sid> sids) {
Assert.notNull(acls, "ACLs cannot be null"); Assert.notNull(acls, "ACLs cannot be null");
this.acls = acls; this.acls = acls;
this.sids = sids; // can be null this.sids = sids; // can be null
@ -584,9 +579,6 @@ public class BasicLookupStrategy implements LookupStrategy {
// target id type, e.g. UUID. // target id type, e.g. UUID.
Serializable identifier = (Serializable) rs.getObject("object_id_identity"); Serializable identifier = (Serializable) rs.getObject("object_id_identity");
identifier = BasicLookupStrategy.this.aclClassIdUtils.identifierFrom(identifier, rs); identifier = BasicLookupStrategy.this.aclClassIdUtils.identifierFrom(identifier, rs);
if (identifier == null) {
throw new IllegalStateException("Identifier cannot be null");
}
ObjectIdentity objectIdentity = BasicLookupStrategy.this.objectIdentityGenerator ObjectIdentity objectIdentity = BasicLookupStrategy.this.objectIdentityGenerator
.createObjectIdentity(identifier, rs.getString("class")); .createObjectIdentity(identifier, rs.getString("class"));
@ -678,7 +670,7 @@ public class BasicLookupStrategy implements LookupStrategy {
} }
@Override @Override
public boolean isSidLoaded(@Nullable List<Sid> sids) { public boolean isSidLoaded(List<Sid> sids) {
throw new UnsupportedOperationException("Stub only"); throw new UnsupportedOperationException("Stub only");
} }

View File

@ -27,7 +27,6 @@ import javax.sql.DataSource;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.jspecify.annotations.Nullable;
import org.springframework.core.convert.ConversionService; import org.springframework.core.convert.ConversionService;
import org.springframework.jdbc.core.JdbcOperations; import org.springframework.jdbc.core.JdbcOperations;
@ -99,7 +98,7 @@ public class JdbcAclService implements AclService {
} }
@Override @Override
public @Nullable List<ObjectIdentity> findChildren(ObjectIdentity parentIdentity) { public List<ObjectIdentity> findChildren(ObjectIdentity parentIdentity) {
Object[] args = { parentIdentity.getIdentifier().toString(), parentIdentity.getType() }; Object[] args = { parentIdentity.getIdentifier().toString(), parentIdentity.getType() };
List<ObjectIdentity> objects = this.jdbcOperations.query(this.findChildrenSql, List<ObjectIdentity> objects = this.jdbcOperations.query(this.findChildrenSql,
(rs, rowNum) -> mapObjectIdentityRow(rs), args); (rs, rowNum) -> mapObjectIdentityRow(rs), args);
@ -110,14 +109,11 @@ public class JdbcAclService implements AclService {
String javaType = rs.getString("class"); String javaType = rs.getString("class");
Serializable identifier = (Serializable) rs.getObject("obj_id"); Serializable identifier = (Serializable) rs.getObject("obj_id");
identifier = this.aclClassIdUtils.identifierFrom(identifier, rs); identifier = this.aclClassIdUtils.identifierFrom(identifier, rs);
if (identifier == null) {
throw new IllegalStateException("Identifier cannot be null");
}
return this.objectIdentityGenerator.createObjectIdentity(identifier, javaType); return this.objectIdentityGenerator.createObjectIdentity(identifier, javaType);
} }
@Override @Override
public Acl readAclById(ObjectIdentity object, @Nullable List<Sid> sids) throws NotFoundException { public Acl readAclById(ObjectIdentity object, List<Sid> sids) throws NotFoundException {
Map<ObjectIdentity, Acl> map = readAclsById(Collections.singletonList(object), sids); Map<ObjectIdentity, Acl> map = readAclsById(Collections.singletonList(object), sids);
Assert.isTrue(map.containsKey(object), Assert.isTrue(map.containsKey(object),
() -> "There should have been an Acl entry for ObjectIdentity " + object); () -> "There should have been an Acl entry for ObjectIdentity " + object);
@ -135,7 +131,7 @@ public class JdbcAclService implements AclService {
} }
@Override @Override
public Map<ObjectIdentity, Acl> readAclsById(List<ObjectIdentity> objects, @Nullable List<Sid> sids) public Map<ObjectIdentity, Acl> readAclsById(List<ObjectIdentity> objects, List<Sid> sids)
throws NotFoundException { throws NotFoundException {
Map<ObjectIdentity, Acl> result = this.lookupStrategy.readAclsById(objects, sids); Map<ObjectIdentity, Acl> result = this.lookupStrategy.readAclsById(objects, sids);
// Check every requested object identity was found (throw NotFoundException if // Check every requested object identity was found (throw NotFoundException if

View File

@ -22,8 +22,6 @@ import java.util.List;
import javax.sql.DataSource; import javax.sql.DataSource;
import org.jspecify.annotations.Nullable;
import org.springframework.dao.DataAccessException; import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.BatchPreparedStatementSetter; import org.springframework.jdbc.core.BatchPreparedStatementSetter;
import org.springframework.security.acls.domain.AccessControlEntryImpl; import org.springframework.security.acls.domain.AccessControlEntryImpl;
@ -122,7 +120,6 @@ public class JdbcMutableAclService extends JdbcAclService implements MutableAclS
// Need to retrieve the current principal, in order to know who "owns" this ACL // Need to retrieve the current principal, in order to know who "owns" this ACL
// (can be changed later on) // (can be changed later on)
Authentication auth = this.securityContextHolderStrategy.getContext().getAuthentication(); Authentication auth = this.securityContextHolderStrategy.getContext().getAuthentication();
Assert.isTrue(auth != null, "Authentication required");
PrincipalSid sid = new PrincipalSid(auth); PrincipalSid sid = new PrincipalSid(auth);
// Create the acl_object_identity row // Create the acl_object_identity row
@ -158,12 +155,9 @@ public class JdbcMutableAclService extends JdbcAclService implements MutableAclS
Assert.isTrue(entry_ instanceof AccessControlEntryImpl, "Unknown ACE class"); Assert.isTrue(entry_ instanceof AccessControlEntryImpl, "Unknown ACE class");
AccessControlEntryImpl entry = (AccessControlEntryImpl) entry_; AccessControlEntryImpl entry = (AccessControlEntryImpl) entry_;
Assert.state(acl.getId() != null, "ACL ID cannot be null");
stmt.setLong(1, (Long) acl.getId()); stmt.setLong(1, (Long) acl.getId());
stmt.setInt(2, i); stmt.setInt(2, i);
Long sidPrimaryKey = createOrRetrieveSidPrimaryKey(entry.getSid(), true); stmt.setLong(3, createOrRetrieveSidPrimaryKey(entry.getSid(), true));
Assert.state(sidPrimaryKey != null, "SID primary key cannot be null");
stmt.setLong(3, sidPrimaryKey);
stmt.setInt(4, entry.getPermission().getMask()); stmt.setInt(4, entry.getPermission().getMask());
stmt.setBoolean(5, entry.isGranting()); stmt.setBoolean(5, entry.isGranting());
stmt.setBoolean(6, entry.isAuditSuccess()); stmt.setBoolean(6, entry.isAuditSuccess());
@ -195,14 +189,11 @@ public class JdbcMutableAclService extends JdbcAclService implements MutableAclS
* @param allowCreate true if creation is permitted if not found * @param allowCreate true if creation is permitted if not found
* @return the primary key or null if not found * @return the primary key or null if not found
*/ */
protected @Nullable Long createOrRetrieveClassPrimaryKey(String type, boolean allowCreate, Class idType) { protected Long createOrRetrieveClassPrimaryKey(String type, boolean allowCreate, Class idType) {
List<@Nullable Long> classIds = this.jdbcOperations.queryForList(this.selectClassPrimaryKey, Long.class, type); List<Long> classIds = this.jdbcOperations.queryForList(this.selectClassPrimaryKey, Long.class, type);
if (!classIds.isEmpty()) { if (!classIds.isEmpty()) {
Long result = classIds.get(0); return classIds.get(0);
if (result != null) {
return result;
}
} }
if (allowCreate) { if (allowCreate) {
@ -213,9 +204,7 @@ public class JdbcMutableAclService extends JdbcAclService implements MutableAclS
this.jdbcOperations.update(this.insertClass, type, idType.getCanonicalName()); this.jdbcOperations.update(this.insertClass, type, idType.getCanonicalName());
} }
Assert.isTrue(TransactionSynchronizationManager.isSynchronizationActive(), "Transaction must be running"); Assert.isTrue(TransactionSynchronizationManager.isSynchronizationActive(), "Transaction must be running");
Long result = this.jdbcOperations.queryForObject(this.classIdentityQuery, Long.class); return this.jdbcOperations.queryForObject(this.classIdentityQuery, Long.class);
Assert.state(result != null, "Failed to retrieve class primary key");
return result;
} }
return null; return null;
@ -230,7 +219,7 @@ public class JdbcMutableAclService extends JdbcAclService implements MutableAclS
* @throws IllegalArgumentException if the <tt>Sid</tt> is not a recognized * @throws IllegalArgumentException if the <tt>Sid</tt> is not a recognized
* implementation. * implementation.
*/ */
protected @Nullable Long createOrRetrieveSidPrimaryKey(Sid sid, boolean allowCreate) { protected Long createOrRetrieveSidPrimaryKey(Sid sid, boolean allowCreate) {
Assert.notNull(sid, "Sid required"); Assert.notNull(sid, "Sid required");
if (sid instanceof PrincipalSid) { if (sid instanceof PrincipalSid) {
String sidName = ((PrincipalSid) sid).getPrincipal(); String sidName = ((PrincipalSid) sid).getPrincipal();
@ -251,22 +240,16 @@ public class JdbcMutableAclService extends JdbcAclService implements MutableAclS
* @param allowCreate true if creation is permitted if not found * @param allowCreate true if creation is permitted if not found
* @return the primary key or null if not found * @return the primary key or null if not found
*/ */
protected @Nullable Long createOrRetrieveSidPrimaryKey(String sidName, boolean sidIsPrincipal, protected Long createOrRetrieveSidPrimaryKey(String sidName, boolean sidIsPrincipal, boolean allowCreate) {
boolean allowCreate) { List<Long> sidIds = this.jdbcOperations.queryForList(this.selectSidPrimaryKey, Long.class, sidIsPrincipal,
List<@Nullable Long> sidIds = this.jdbcOperations.queryForList(this.selectSidPrimaryKey, Long.class, sidName);
sidIsPrincipal, sidName);
if (!sidIds.isEmpty()) { if (!sidIds.isEmpty()) {
Long result = sidIds.get(0); return sidIds.get(0);
if (result != null) {
return result;
}
} }
if (allowCreate) { if (allowCreate) {
this.jdbcOperations.update(this.insertSid, sidIsPrincipal, sidName); this.jdbcOperations.update(this.insertSid, sidIsPrincipal, sidName);
Assert.isTrue(TransactionSynchronizationManager.isSynchronizationActive(), "Transaction must be running"); Assert.isTrue(TransactionSynchronizationManager.isSynchronizationActive(), "Transaction must be running");
Long result = this.jdbcOperations.queryForObject(this.sidIdentityQuery, Long.class); return this.jdbcOperations.queryForObject(this.sidIdentityQuery, Long.class);
Assert.state(result != null, "Failed to retrieve sid primary key");
return result;
} }
return null; return null;
} }
@ -296,9 +279,6 @@ public class JdbcMutableAclService extends JdbcAclService implements MutableAclS
} }
Long oidPrimaryKey = retrieveObjectIdentityPrimaryKey(objectIdentity); Long oidPrimaryKey = retrieveObjectIdentityPrimaryKey(objectIdentity);
if (oidPrimaryKey == null) {
throw new NotFoundException("Object identity not found: " + objectIdentity);
}
// Delete this ACL's ACEs in the acl_entry table // Delete this ACL's ACEs in the acl_entry table
deleteEntries(oidPrimaryKey); deleteEntries(oidPrimaryKey);
@ -339,11 +319,10 @@ public class JdbcMutableAclService extends JdbcAclService implements MutableAclS
* @param oid to find * @param oid to find
* @return the object identity or null if not found * @return the object identity or null if not found
*/ */
protected @Nullable Long retrieveObjectIdentityPrimaryKey(ObjectIdentity oid) { protected Long retrieveObjectIdentityPrimaryKey(ObjectIdentity oid) {
try { try {
Long result = this.jdbcOperations.queryForObject(this.selectObjectIdentityPrimaryKey, Long.class, return this.jdbcOperations.queryForObject(this.selectObjectIdentityPrimaryKey, Long.class, oid.getType(),
oid.getType(), oid.getIdentifier().toString()); oid.getIdentifier().toString());
return result;
} }
catch (DataAccessException notFound) { catch (DataAccessException notFound) {
return null; return null;
@ -361,11 +340,7 @@ public class JdbcMutableAclService extends JdbcAclService implements MutableAclS
Assert.notNull(acl.getId(), "Object Identity doesn't provide an identifier"); Assert.notNull(acl.getId(), "Object Identity doesn't provide an identifier");
// Delete this ACL's ACEs in the acl_entry table // Delete this ACL's ACEs in the acl_entry table
Long oidPrimaryKey = retrieveObjectIdentityPrimaryKey(acl.getObjectIdentity()); deleteEntries(retrieveObjectIdentityPrimaryKey(acl.getObjectIdentity()));
if (oidPrimaryKey == null) {
throw new NotFoundException("Object identity not found for ACL: " + acl.getObjectIdentity());
}
deleteEntries(oidPrimaryKey);
// Create this ACL's ACEs in the acl_entry table // Create this ACL's ACEs in the acl_entry table
createEntries(acl); createEntries(acl);

View File

@ -19,8 +19,6 @@ package org.springframework.security.acls.jdbc;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.jspecify.annotations.Nullable;
import org.springframework.security.acls.model.Acl; import org.springframework.security.acls.model.Acl;
import org.springframework.security.acls.model.NotFoundException; import org.springframework.security.acls.model.NotFoundException;
import org.springframework.security.acls.model.ObjectIdentity; import org.springframework.security.acls.model.ObjectIdentity;
@ -44,6 +42,6 @@ public interface LookupStrategy {
* {@link NotFoundException}, as a chain of {@link LookupStrategy}s may be used to * {@link NotFoundException}, as a chain of {@link LookupStrategy}s may be used to
* automatically create entries if required) * automatically create entries if required)
*/ */
Map<ObjectIdentity, Acl> readAclsById(List<ObjectIdentity> objects, @Nullable List<Sid> sids); Map<ObjectIdentity, Acl> readAclsById(List<ObjectIdentity> objects, List<Sid> sids);
} }

View File

@ -17,7 +17,4 @@
/** /**
* JDBC-based persistence of ACL information * JDBC-based persistence of ACL information
*/ */
@NullMarked
package org.springframework.security.acls.jdbc; package org.springframework.security.acls.jdbc;
import org.jspecify.annotations.NullMarked;

View File

@ -18,8 +18,6 @@ package org.springframework.security.acls.model;
import java.io.Serializable; import java.io.Serializable;
import org.jspecify.annotations.Nullable;
/** /**
* Represents an individual permission assignment within an {@link Acl}. * Represents an individual permission assignment within an {@link Acl}.
* *
@ -38,7 +36,7 @@ public interface AccessControlEntry extends Serializable {
* Obtains an identifier that represents this ACE. * Obtains an identifier that represents this ACE.
* @return the identifier, or <code>null</code> if unsaved * @return the identifier, or <code>null</code> if unsaved
*/ */
@Nullable Serializable getId(); Serializable getId();
Permission getPermission(); Permission getPermission();

Some files were not shown because too many files have changed in this diff Show More