-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'spring-projects:main' into main
- Loading branch information
Showing
43 changed files
with
2,063 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# This workflow is an adaptation from https://github.com/spring-projects/spring-integration/blob/main/.github/workflows/merge-dependabot-pr.yml | ||
# and https://github.com/spring-io/spring-github-workflows/blob/main/.github/workflows/spring-merge-dependabot-pr.yml | ||
|
||
name: Edit Dependabot PR | ||
|
||
on: | ||
pull_request: | ||
|
||
run-name: Edit Dependabot PR ${{ github.ref_name }} | ||
|
||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
jobs: | ||
edit-dependabot-pr: | ||
runs-on: ubuntu-latest | ||
if: github.actor == 'dependabot[bot]' | ||
permissions: write-all | ||
steps: | ||
|
||
- uses: actions/checkout@v4 | ||
with: | ||
show-progress: false | ||
|
||
- uses: actions/setup-java@v4 | ||
with: | ||
distribution: temurin | ||
java-version: 17 | ||
|
||
- name: Dependabot metadata | ||
id: metadata | ||
uses: dependabot/fetch-metadata@v1 | ||
with: | ||
github-token: ${{ env.GH_TOKEN }} | ||
|
||
- name: Set Milestone to Dependabot pull request | ||
id: set-milestone | ||
run: | | ||
if test -f pom.xml | ||
then | ||
CURRENT_VERSION=$(mvn help:evaluate -Dexpression="project.version" -q -DforceStdout) | ||
else | ||
CURRENT_VERSION=$(cat gradle.properties | sed -n '/^version=/ { s/^version=//;p }') | ||
fi | ||
export CANDIDATE_VERSION=${CURRENT_VERSION/-SNAPSHOT} | ||
MILESTONE=$(gh api repos/$GITHUB_REPOSITORY/milestones --jq 'map(select(.due_on != null and (.title | startswith(env.CANDIDATE_VERSION)))) | .[0] | .title') | ||
if [ -z $MILESTONE ] | ||
then | ||
gh run cancel ${{ github.run_id }} | ||
echo "::warning title=Cannot merge::No scheduled milestone for $CURRENT_VERSION version" | ||
else | ||
gh pr edit ${{ github.event.pull_request.number }} --milestone $MILESTONE | ||
echo mergeEnabled=true >> $GITHUB_OUTPUT | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
crypto/src/main/java/org/springframework/security/crypto/encrypt/KeyStoreKeyFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/* | ||
* Copyright 2013-2024 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.crypto.encrypt; | ||
|
||
import java.io.InputStream; | ||
import java.security.KeyFactory; | ||
import java.security.KeyPair; | ||
import java.security.KeyStore; | ||
import java.security.PublicKey; | ||
import java.security.cert.Certificate; | ||
import java.security.interfaces.RSAPrivateCrtKey; | ||
import java.security.spec.RSAPublicKeySpec; | ||
|
||
import org.springframework.core.io.Resource; | ||
import org.springframework.util.StringUtils; | ||
|
||
/** | ||
* @author Dave Syer | ||
* @author Tim Ysewyn | ||
* @since 6.3 | ||
*/ | ||
public class KeyStoreKeyFactory { | ||
|
||
private final Resource resource; | ||
|
||
private final char[] password; | ||
|
||
private KeyStore store; | ||
|
||
private final Object lock = new Object(); | ||
|
||
private final String type; | ||
|
||
public KeyStoreKeyFactory(Resource resource, char[] password) { | ||
this(resource, password, type(resource)); | ||
} | ||
|
||
private static String type(Resource resource) { | ||
String ext = StringUtils.getFilenameExtension(resource.getFilename()); | ||
return (ext != null) ? ext : "jks"; | ||
} | ||
|
||
public KeyStoreKeyFactory(Resource resource, char[] password, String type) { | ||
this.resource = resource; | ||
this.password = password; | ||
this.type = type; | ||
} | ||
|
||
public KeyPair getKeyPair(String alias) { | ||
return getKeyPair(alias, this.password); | ||
} | ||
|
||
public KeyPair getKeyPair(String alias, char[] password) { | ||
try { | ||
synchronized (this.lock) { | ||
if (this.store == null) { | ||
synchronized (this.lock) { | ||
this.store = KeyStore.getInstance(this.type); | ||
try (InputStream stream = this.resource.getInputStream()) { | ||
this.store.load(stream, this.password); | ||
} | ||
} | ||
} | ||
} | ||
RSAPrivateCrtKey key = (RSAPrivateCrtKey) this.store.getKey(alias, password); | ||
Certificate certificate = this.store.getCertificate(alias); | ||
PublicKey publicKey = null; | ||
if (certificate != null) { | ||
publicKey = certificate.getPublicKey(); | ||
} | ||
else if (key != null) { | ||
RSAPublicKeySpec spec = new RSAPublicKeySpec(key.getModulus(), key.getPublicExponent()); | ||
publicKey = KeyFactory.getInstance("RSA").generatePublic(spec); | ||
} | ||
return new KeyPair(publicKey, key); | ||
} | ||
catch (Exception ex) { | ||
throw new IllegalStateException("Cannot load keys from store: " + this.resource, ex); | ||
} | ||
} | ||
|
||
} |
44 changes: 44 additions & 0 deletions
44
crypto/src/main/java/org/springframework/security/crypto/encrypt/RsaAlgorithm.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright 2013-2024 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.crypto.encrypt; | ||
|
||
/** | ||
* @author Dave Syer | ||
* @since 6.3 | ||
*/ | ||
public enum RsaAlgorithm { | ||
|
||
DEFAULT("RSA", 117), OAEP("RSA/ECB/OAEPPadding", 86); | ||
|
||
private final String name; | ||
|
||
private final int maxLength; | ||
|
||
RsaAlgorithm(String name, int maxLength) { | ||
this.name = name; | ||
this.maxLength = maxLength; | ||
} | ||
|
||
public String getJceName() { | ||
return this.name; | ||
} | ||
|
||
public int getMaxLength() { | ||
return this.maxLength; | ||
} | ||
|
||
} |
Oops, something went wrong.