Skip to content

Commit 1804da7

Browse files
committed
Merge remote-tracking branch 'origin/master' into gh-2567-master-merge
2019-02-27 Merge of master branch (update of docs) into doc rewrite branch
2 parents db9cc64 + 2b960b0 commit 1804da7

File tree

424 files changed

+23845
-5238
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

424 files changed

+23845
-5238
lines changed

.github/ISSUE_REPLY_TEMPLATES.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
### Complete and Minimal Sample
3+
4+
It would be very helpful if you could provide a complete and minimal sample that reproduces the issue and share it via a GitHub repository. This will allow us to efficiently troubleshoot and help resolve the issue. The sample should contain the minimum amount of code to reproduce the issue along with detailed steps on how to reproduce. Please see the following references for what a complete and minimal sample should consist of.
5+
6+
- http://sscce.org/
7+
- https://stackoverflow.com/help/mcve

CONTRIBUTING.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Create your topic branch to be submitted as a pull request from master. The Spri
4747
# Use short branch names
4848
Branches used when submitting pull requests should preferably be named according to GitHub issues, e.g. 'gh-1234' or 'gh-1234-fix-npe'. Otherwise, use succinct, lower-case, dash (-) delimited names, such as 'fix-warnings', 'fix-typo', etc. This is important, because branch names show up in the merge commits that result from accepting pull requests, and should be as expressive and concise as possible.
4949

50-
#Keep commits focused
50+
# Keep commits focused
5151

5252
Remember each ticket should be focused on a single item of interest since the tickets are used to produce the changelog. Since each commit should be tied to a single GitHub issue, ensure that your commits are focused. For example, do not include an update to a transitive library in your commit unless the GitHub is to update the library. Reviewing your commits is essential before sending a pull request.
5353

@@ -125,7 +125,7 @@ Update the [RELAX NG](http://www.relaxng.org) schema `spring-security-x.y.rnc` i
125125
Changes to the XML schema will be overwritten by the Gradle build task.
126126

127127
# Squash commits
128-
Use git rebase --interactive, git add --patch and other tools to "squash" multiple commits into atomic changes. In addition to the man pages for git, there are many resources online to help you understand how these tools work. Here is one: http://book.git-scm.com/4_interactive_rebasing.html.
128+
Use `git rebase --interactive`, `git add --patch` and other tools to "squash" multiple commits into atomic changes. In addition to the man pages for git, there are many resources online to help you understand how these tools work. Here from the [Git SCM Book](https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History).
129129

130130
# Use real name in git commits
131131
Please configure git to use your real first and last name for any commits you intend to submit as pull requests. For example, this is not acceptable:

Jenkinsfile

+120-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,126 @@ try {
1313
stage('Deploy Docs') {
1414
node {
1515
checkout scm
16-
withEnv(["JAVA_HOME=${ tool 'jdk8' }"]) {
16+
try {
17+
sh "./gradlew clean check --refresh-dependencies --no-daemon --stacktrace"
18+
} catch(Exception e) {
19+
currentBuild.result = 'FAILED: check'
20+
throw e
21+
} finally {
22+
junit '**/build/test-results/*/*.xml'
23+
}
24+
}
25+
}
26+
},
27+
sonar: {
28+
stage('Sonar') {
29+
node {
30+
checkout scm
31+
withCredentials([string(credentialsId: 'spring-sonar.login', variable: 'SONAR_LOGIN')]) {
32+
try {
33+
if ("master" == env.BRANCH_NAME) {
34+
sh "./gradlew sonarqube -PexcludeProjects='**/samples/**' -Dsonar.host.url=$SPRING_SONAR_HOST_URL -Dsonar.login=$SONAR_LOGIN --refresh-dependencies --no-daemon --stacktrace"
35+
} else {
36+
sh "./gradlew sonarqube -PexcludeProjects='**/samples/**' -Dsonar.projectKey='spring-security-${env.BRANCH_NAME}' -Dsonar.projectName='spring-security-${env.BRANCH_NAME}' -Dsonar.host.url=$SPRING_SONAR_HOST_URL -Dsonar.login=$SONAR_LOGIN --refresh-dependencies --no-daemon --stacktrace"
37+
}
38+
} catch(Exception e) {
39+
currentBuild.result = 'FAILED: sonar'
40+
throw e
41+
}
42+
}
43+
}
44+
}
45+
},
46+
snapshots: {
47+
stage('Snapshot Tests') {
48+
node {
49+
checkout scm
50+
try {
51+
sh "./gradlew clean test -PforceMavenRepositories=snapshot -PspringVersion='5.+' -PreactorVersion=Californium-BUILD-SNAPSHOT -PspringDataVersion=Lovelace-BUILD-SNAPSHOT --refresh-dependencies --no-daemon --stacktrace"
52+
} catch(Exception e) {
53+
currentBuild.result = 'FAILED: snapshots'
54+
throw e
55+
}
56+
}
57+
}
58+
},
59+
jdk9: {
60+
stage('JDK 9') {
61+
node {
62+
checkout scm
63+
try {
64+
withEnv(["JAVA_HOME=${ tool 'jdk9' }"]) {
65+
sh "./gradlew clean test --refresh-dependencies --no-daemon --stacktrace"
66+
}
67+
} catch(Exception e) {
68+
currentBuild.result = 'FAILED: jdk9'
69+
throw e
70+
}
71+
}
72+
}
73+
},
74+
jdk10: {
75+
stage('JDK 10') {
76+
node {
77+
checkout scm
78+
try {
79+
withEnv(["JAVA_HOME=${ tool 'jdk10' }"]) {
80+
sh "./gradlew clean test --refresh-dependencies --no-daemon --stacktrace"
81+
}
82+
} catch(Exception e) {
83+
currentBuild.result = 'FAILED: jdk10'
84+
throw e
85+
}
86+
}
87+
}
88+
},
89+
jdk11: {
90+
stage('JDK 11') {
91+
node {
92+
checkout scm
93+
try {
94+
withEnv(["JAVA_HOME=${ tool 'jdk11' }"]) {
95+
sh "./gradlew clean test --refresh-dependencies --no-daemon --stacktrace"
96+
}
97+
} catch(Exception e) {
98+
currentBuild.result = 'FAILED: jdk11'
99+
throw e
100+
}
101+
}
102+
}
103+
}
104+
105+
if(currentBuild.result == 'SUCCESS') {
106+
parallel artifacts: {
107+
stage('Deploy Artifacts') {
108+
node {
109+
checkout scm
110+
withCredentials([file(credentialsId: 'spring-signing-secring.gpg', variable: 'SIGNING_KEYRING_FILE')]) {
111+
withCredentials([string(credentialsId: 'spring-gpg-passphrase', variable: 'SIGNING_PASSWORD')]) {
112+
withCredentials([usernamePassword(credentialsId: 'oss-token', passwordVariable: 'OSSRH_PASSWORD', usernameVariable: 'OSSRH_USERNAME')]) {
113+
withCredentials([usernamePassword(credentialsId: '02bd1690-b54f-4c9f-819d-a77cb7a9822c', usernameVariable: 'ARTIFACTORY_USERNAME', passwordVariable: 'ARTIFACTORY_PASSWORD')]) {
114+
sh "./gradlew deployArtifacts finalizeDeployArtifacts -Psigning.secretKeyRingFile=$SIGNING_KEYRING_FILE -Psigning.keyId=$SPRING_SIGNING_KEYID -Psigning.password='$SIGNING_PASSWORD' -PossrhUsername=$OSSRH_USERNAME -PossrhPassword=$OSSRH_PASSWORD -PartifactoryUsername=$ARTIFACTORY_USERNAME -PartifactoryPassword=$ARTIFACTORY_PASSWORD --refresh-dependencies --no-daemon --stacktrace"
115+
}
116+
}
117+
}
118+
}
119+
}
120+
}
121+
},
122+
docs: {
123+
stage('Deploy Docs') {
124+
node {
125+
checkout scm
126+
withCredentials([file(credentialsId: 'docs.spring.io-jenkins_private_ssh_key', variable: 'DEPLOY_SSH_KEY')]) {
127+
sh "./gradlew deployDocs -PdeployDocsSshKeyPath=$DEPLOY_SSH_KEY -PdeployDocsSshUsername=$SPRING_DOCS_USERNAME --refresh-dependencies --no-daemon --stacktrace"
128+
}
129+
}
130+
}
131+
},
132+
schema: {
133+
stage('Deploy Schema') {
134+
node {
135+
checkout scm
17136
withCredentials([file(credentialsId: 'docs.spring.io-jenkins_private_ssh_key', variable: 'DEPLOY_SSH_KEY')]) {
18137
sh "./gradlew deployDocs -PdeployDocsSshKeyPath=$DEPLOY_SSH_KEY -PdeployDocsSshUsername=$SPRING_DOCS_USERNAME --no-daemon --stacktrace"
19138
}

README.adoc

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ See https://github.com/spring-projects/spring-framework/wiki/Downloading-Spring-
1818

1919
== Documentation
2020
Be sure to read the http://docs.spring.io/spring-security/site/docs/current/reference/htmlsingle/[Spring Security Reference].
21-
Extensive JavaDoc for the Spring Security code is also available in the http://docs.spring.io/spring-security/site/docs/current/apidocs/[Spring Security API Documentation].
21+
Extensive JavaDoc for the Spring Security code is also available in the https://docs.spring.io/spring-security/site/docs/current/api/[Spring Security API Documentation].
2222

2323
== Quick Start
2424
We recommend you visit http://docs.spring.io/spring-security/site/docs/current/reference/htmlsingle/[Spring Security Reference] and read the "Getting Started" page.
@@ -59,7 +59,7 @@ Check out the http://stackoverflow.com/questions/tagged/spring-security[Spring S
5959
http://spring.io/services[Commercial support] is available too.
6060

6161
== Contributing
62-
http://help.github.com/send-pull-requests[Pull requests] are welcome; see the https://github.com/spring-projects/spring-security/blob/master/CONTRIBUTING.md[contributor guidelines] for details.
62+
https://help.github.com/articles/creating-a-pull-request[Pull requests] are welcome; see the https://github.com/spring-projects/spring-security/blob/master/CONTRIBUTING.md[contributor guidelines] for details.
6363

6464
== License
6565
Spring Security is Open Source software released under the

acl/src/main/java/org/springframework/security/acls/jdbc/AclClassIdUtils.java

+43-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,11 +18,17 @@
1818
import java.io.Serializable;
1919
import java.sql.ResultSet;
2020
import java.sql.SQLException;
21+
import java.util.UUID;
2122

2223
import org.apache.commons.logging.Log;
2324
import org.apache.commons.logging.LogFactory;
25+
import org.springframework.core.convert.ConversionFailedException;
2426
import org.springframework.core.convert.ConversionService;
27+
import org.springframework.core.convert.TypeDescriptor;
28+
import org.springframework.core.convert.converter.Converter;
29+
import org.springframework.core.convert.support.GenericConversionService;
2530
import org.springframework.security.acls.model.ObjectIdentity;
31+
import org.springframework.util.Assert;
2632

2733
/**
2834
* Utility class for helping convert database representations of {@link ObjectIdentity#getIdentifier()} into
@@ -36,6 +42,15 @@ class AclClassIdUtils {
3642
private ConversionService conversionService;
3743

3844
public AclClassIdUtils() {
45+
GenericConversionService genericConversionService = new GenericConversionService();
46+
genericConversionService.addConverter(String.class, Long.class, new StringToLongConverter());
47+
genericConversionService.addConverter(String.class, UUID.class, new StringToUUIDConverter());
48+
this.conversionService = genericConversionService;
49+
}
50+
51+
public AclClassIdUtils(ConversionService conversionService) {
52+
Assert.notNull(conversionService, "conversionService must not be null");
53+
this.conversionService = conversionService;
3954
}
4055

4156
/**
@@ -86,17 +101,13 @@ private <T extends Serializable> Class<T> classIdTypeFrom(String className) {
86101
}
87102

88103
private <T> boolean canConvertFromStringTo(Class<T> targetType) {
89-
return hasConversionService() && conversionService.canConvert(String.class, targetType);
104+
return conversionService.canConvert(String.class, targetType);
90105
}
91106

92107
private <T extends Serializable> T convertFromStringTo(String identifier, Class<T> targetType) {
93108
return conversionService.convert(identifier, targetType);
94109
}
95110

96-
private boolean hasConversionService() {
97-
return conversionService != null;
98-
}
99-
100111
/**
101112
* Converts to a {@link Long}, attempting to use the {@link ConversionService} if available.
102113
* @param identifier The identifier
@@ -107,7 +118,7 @@ private boolean hasConversionService() {
107118
*/
108119
private Long convertToLong(Serializable identifier) {
109120
Long idAsLong;
110-
if (hasConversionService()) {
121+
if (canConvertFromStringTo(Long.class)) {
111122
idAsLong = conversionService.convert(identifier, Long.class);
112123
} else {
113124
idAsLong = Long.valueOf(identifier.toString());
@@ -120,6 +131,31 @@ private boolean isString(Serializable object) {
120131
}
121132

122133
public void setConversionService(ConversionService conversionService) {
134+
Assert.notNull(conversionService, "conversionService must not be null");
123135
this.conversionService = conversionService;
124136
}
137+
138+
private static class StringToLongConverter implements Converter<String, Long> {
139+
@Override
140+
public Long convert(String identifierAsString) {
141+
if (identifierAsString == null) {
142+
throw new ConversionFailedException(TypeDescriptor.valueOf(String.class),
143+
TypeDescriptor.valueOf(Long.class), null, null);
144+
145+
}
146+
return Long.parseLong(identifierAsString);
147+
}
148+
}
149+
150+
private static class StringToUUIDConverter implements Converter<String, UUID> {
151+
@Override
152+
public UUID convert(String identifierAsString) {
153+
if (identifierAsString == null) {
154+
throw new ConversionFailedException(TypeDescriptor.valueOf(String.class),
155+
TypeDescriptor.valueOf(UUID.class), null, null);
156+
157+
}
158+
return UUID.fromString(identifierAsString);
159+
}
160+
}
125161
}

acl/src/main/java/org/springframework/security/acls/jdbc/BasicLookupStrategy.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import javax.sql.DataSource;
3232

3333
import org.springframework.core.convert.ConversionException;
34+
import org.springframework.core.convert.ConversionService;
3435
import org.springframework.jdbc.core.JdbcTemplate;
3536
import org.springframework.jdbc.core.PreparedStatementSetter;
3637
import org.springframework.jdbc.core.ResultSetExtractor;
@@ -553,8 +554,8 @@ public final void setAclClassIdSupported(boolean aclClassIdSupported) {
553554
}
554555
}
555556

556-
public final void setAclClassIdUtils(AclClassIdUtils aclClassIdUtils) {
557-
this.aclClassIdUtils = aclClassIdUtils;
557+
public final void setConversionService(ConversionService conversionService) {
558+
this.aclClassIdUtils = new AclClassIdUtils(conversionService);
558559
}
559560

560561
// ~ Inner Classes

acl/src/main/java/org/springframework/security/acls/jdbc/JdbcAclService.java

+14-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2004, 2005, 2006, 2017 Acegi Technology Pty Limited
2+
* Copyright 2004, 2005, 2006, 2017, 2018 Acegi Technology Pty Limited
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -26,6 +26,8 @@
2626

2727
import org.apache.commons.logging.Log;
2828
import org.apache.commons.logging.LogFactory;
29+
import org.springframework.core.convert.ConversionService;
30+
import org.springframework.jdbc.core.JdbcOperations;
2931
import org.springframework.jdbc.core.JdbcTemplate;
3032
import org.springframework.jdbc.core.RowMapper;
3133
import org.springframework.security.acls.domain.ObjectIdentityImpl;
@@ -66,7 +68,7 @@ public class JdbcAclService implements AclService {
6668
// ~ Instance fields
6769
// ================================================================================================
6870

69-
protected final JdbcTemplate jdbcTemplate;
71+
protected final JdbcOperations jdbcOperations;
7072
private final LookupStrategy lookupStrategy;
7173
private boolean aclClassIdSupported;
7274
private String findChildrenSql = DEFAULT_SELECT_ACL_WITH_PARENT_SQL;
@@ -76,9 +78,13 @@ public class JdbcAclService implements AclService {
7678
// ===================================================================================================
7779

7880
public JdbcAclService(DataSource dataSource, LookupStrategy lookupStrategy) {
79-
Assert.notNull(dataSource, "DataSource required");
81+
this(new JdbcTemplate(dataSource), lookupStrategy);
82+
}
83+
84+
public JdbcAclService(JdbcOperations jdbcOperations, LookupStrategy lookupStrategy) {
85+
Assert.notNull(jdbcOperations, "JdbcOperations required");
8086
Assert.notNull(lookupStrategy, "LookupStrategy required");
81-
this.jdbcTemplate = new JdbcTemplate(dataSource);
87+
this.jdbcOperations = jdbcOperations;
8288
this.lookupStrategy = lookupStrategy;
8389
this.aclClassIdUtils = new AclClassIdUtils();
8490
}
@@ -87,15 +93,14 @@ public JdbcAclService(DataSource dataSource, LookupStrategy lookupStrategy) {
8793
// ========================================================================================================
8894

8995
public List<ObjectIdentity> findChildren(ObjectIdentity parentIdentity) {
90-
Object[] args = { parentIdentity.getIdentifier(), parentIdentity.getType() };
91-
List<ObjectIdentity> objects = jdbcTemplate.query(findChildrenSql, args,
96+
Object[] args = { parentIdentity.getIdentifier().toString(), parentIdentity.getType() };
97+
List<ObjectIdentity> objects = jdbcOperations.query(findChildrenSql, args,
9298
new RowMapper<ObjectIdentity>() {
9399
public ObjectIdentity mapRow(ResultSet rs, int rowNum)
94100
throws SQLException {
95101
String javaType = rs.getString("class");
96102
Serializable identifier = (Serializable) rs.getObject("obj_id");
97103
identifier = aclClassIdUtils.identifierFrom(identifier, rs);
98-
99104
return new ObjectIdentityImpl(javaType, identifier);
100105
}
101106
});
@@ -163,8 +168,8 @@ public void setAclClassIdSupported(boolean aclClassIdSupported) {
163168
}
164169
}
165170

166-
public void setAclClassIdUtils(AclClassIdUtils aclClassIdUtils) {
167-
this.aclClassIdUtils = aclClassIdUtils;
171+
public void setConversionService(ConversionService conversionService) {
172+
this.aclClassIdUtils = new AclClassIdUtils(conversionService);
168173
}
169174

170175
protected boolean isAclClassIdSupported() {

0 commit comments

Comments
 (0)