Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit bb27474

Browse files
Merge branch 'spring-projects:main' into bugfix/fixed-nullity-documentation-mismatch-regexRequestMatcher
2 parents 985e7cf + 9f7e92d commit bb27474

File tree

442 files changed

+13613
-1021
lines changed

Some content is hidden

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

442 files changed

+13613
-1021
lines changed

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ atlassian-ide-plugin.xml
2525
s101plugin.state
2626
.attach_pid*
2727
.~lock.*#
28+
.kotlin/
2829

2930
!.idea/checkstyle-idea.xml
3031
!.idea/externalDependencies.xml

‎cas/spring-security-cas.gradle‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ dependencies {
1515
api 'org.springframework:spring-web'
1616

1717
optional 'com.fasterxml.jackson.core:jackson-databind'
18+
optional 'tools.jackson.core:jackson-databind'
1819

1920
provided 'jakarta.servlet:jakarta.servlet-api'
2021

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
* Copyright 2004-present the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.security.cas.jackson;
18+
19+
import java.util.Date;
20+
import java.util.Map;
21+
22+
import com.fasterxml.jackson.annotation.JsonAutoDetect;
23+
import com.fasterxml.jackson.annotation.JsonCreator;
24+
import com.fasterxml.jackson.annotation.JsonProperty;
25+
import com.fasterxml.jackson.annotation.JsonTypeInfo;
26+
import org.apereo.cas.client.authentication.AttributePrincipal;
27+
28+
/**
29+
* Helps in jackson deserialization of class
30+
* {@link org.apereo.cas.client.validation.AssertionImpl}, which is used with
31+
* {@link org.springframework.security.cas.authentication.CasAuthenticationToken}.
32+
*
33+
* @author Sebastien Deleuze
34+
* @author Jitendra Singh
35+
* @since 7.0
36+
* @see CasJacksonModule
37+
* @see org.springframework.security.jackson.SecurityJacksonModules
38+
*/
39+
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS)
40+
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE,
41+
isGetterVisibility = JsonAutoDetect.Visibility.NONE)
42+
class AssertionImplMixin {
43+
44+
/**
45+
* Mixin Constructor helps in deserialize
46+
* {@link org.apereo.cas.client.validation.AssertionImpl}
47+
* @param principal the Principal to associate with the Assertion.
48+
* @param validFromDate when the assertion is valid from.
49+
* @param validUntilDate when the assertion is valid to.
50+
* @param authenticationDate when the assertion is authenticated.
51+
* @param attributes the key/value pairs for this attribute.
52+
*/
53+
@JsonCreator
54+
AssertionImplMixin(@JsonProperty("principal") AttributePrincipal principal,
55+
@JsonProperty("validFromDate") Date validFromDate, @JsonProperty("validUntilDate") Date validUntilDate,
56+
@JsonProperty("authenticationDate") Date authenticationDate,
57+
@JsonProperty("attributes") Map<String, Object> attributes) {
58+
}
59+
60+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* Copyright 2004-present the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.security.cas.jackson;
18+
19+
import java.util.Map;
20+
21+
import com.fasterxml.jackson.annotation.JsonAutoDetect;
22+
import com.fasterxml.jackson.annotation.JsonCreator;
23+
import com.fasterxml.jackson.annotation.JsonProperty;
24+
import com.fasterxml.jackson.annotation.JsonTypeInfo;
25+
import org.apereo.cas.client.proxy.ProxyRetriever;
26+
27+
/**
28+
* Helps in deserialize
29+
* {@link org.apereo.cas.client.authentication.AttributePrincipalImpl} which is used with
30+
* {@link org.springframework.security.cas.authentication.CasAuthenticationToken}.
31+
*
32+
* @author Sebastien Deleuze
33+
* @author Jitendra Singh
34+
* @since 7.0
35+
* @see CasJacksonModule
36+
* @see org.springframework.security.jackson.SecurityJacksonModules
37+
*/
38+
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS)
39+
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE,
40+
isGetterVisibility = JsonAutoDetect.Visibility.NONE)
41+
class AttributePrincipalImplMixin {
42+
43+
/**
44+
* Mixin Constructor helps in deserialize
45+
* {@link org.apereo.cas.client.authentication.AttributePrincipalImpl}
46+
* @param name the unique identifier for the principal.
47+
* @param attributes the key/value pairs for this principal.
48+
* @param proxyGrantingTicket the ticket associated with this principal.
49+
* @param proxyRetriever the ProxyRetriever implementation to call back to the CAS
50+
* server.
51+
*/
52+
@JsonCreator
53+
AttributePrincipalImplMixin(@JsonProperty("name") String name,
54+
@JsonProperty("attributes") Map<String, Object> attributes,
55+
@JsonProperty("proxyGrantingTicket") String proxyGrantingTicket,
56+
@JsonProperty("proxyRetriever") ProxyRetriever proxyRetriever) {
57+
}
58+
59+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
2+
* Copyright 2004-present the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.security.cas.jackson;
18+
19+
import java.util.Collection;
20+
21+
import com.fasterxml.jackson.annotation.JsonAutoDetect;
22+
import com.fasterxml.jackson.annotation.JsonCreator;
23+
import com.fasterxml.jackson.annotation.JsonProperty;
24+
import com.fasterxml.jackson.annotation.JsonTypeInfo;
25+
import org.apereo.cas.client.validation.Assertion;
26+
27+
import org.springframework.security.cas.authentication.CasAuthenticationProvider;
28+
import org.springframework.security.cas.authentication.CasAuthenticationToken;
29+
import org.springframework.security.core.GrantedAuthority;
30+
import org.springframework.security.core.userdetails.UserDetails;
31+
32+
/**
33+
* Mixin class which helps in deserialize {@link CasAuthenticationToken} using jackson.
34+
*
35+
* @author Sebastien Deleuze
36+
* @author Jitendra Singh
37+
* @since 7.0
38+
* @see CasJacksonModule
39+
* @see org.springframework.security.jackson.SecurityJacksonModules
40+
*/
41+
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS)
42+
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, isGetterVisibility = JsonAutoDetect.Visibility.NONE,
43+
getterVisibility = JsonAutoDetect.Visibility.NONE, creatorVisibility = JsonAutoDetect.Visibility.ANY)
44+
class CasAuthenticationTokenMixin {
45+
46+
/**
47+
* Mixin Constructor helps in deserialize {@link CasAuthenticationToken}
48+
* @param keyHash hashCode of provided key to identify if this object made by a given
49+
* {@link CasAuthenticationProvider}
50+
* @param principal typically the UserDetails object (cannot be <code>null</code>)
51+
* @param credentials the service/proxy ticket ID from CAS (cannot be
52+
* <code>null</code>)
53+
* @param authorities the authorities granted to the user (from the
54+
* {@link org.springframework.security.core.userdetails.UserDetailsService}) (cannot
55+
* be <code>null</code>)
56+
* @param userDetails the user details (from the
57+
* {@link org.springframework.security.core.userdetails.UserDetailsService}) (cannot
58+
* be <code>null</code>)
59+
* @param assertion the assertion returned from the CAS servers. It contains the
60+
* principal and how to obtain a proxy ticket for the user.
61+
*/
62+
@JsonCreator
63+
CasAuthenticationTokenMixin(@JsonProperty("keyHash") Integer keyHash, @JsonProperty("principal") Object principal,
64+
@JsonProperty("credentials") Object credentials,
65+
@JsonProperty("authorities") Collection<? extends GrantedAuthority> authorities,
66+
@JsonProperty("userDetails") UserDetails userDetails, @JsonProperty("assertion") Assertion assertion) {
67+
}
68+
69+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*
2+
* Copyright 2004-present the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.security.cas.jackson;
18+
19+
import org.apereo.cas.client.authentication.AttributePrincipalImpl;
20+
import org.apereo.cas.client.validation.AssertionImpl;
21+
import tools.jackson.core.Version;
22+
import tools.jackson.databind.jsontype.BasicPolymorphicTypeValidator;
23+
24+
import org.springframework.security.cas.authentication.CasAuthenticationToken;
25+
import org.springframework.security.jackson.SecurityJacksonModule;
26+
import org.springframework.security.jackson.SecurityJacksonModules;
27+
28+
/**
29+
* Jackson module for spring-security-cas. This module register
30+
* {@link AssertionImplMixin}, {@link AttributePrincipalImplMixin} and
31+
* {@link CasAuthenticationTokenMixin}. If no default typing enabled by default then it'll
32+
* enable it because typing info is needed to properly serialize/deserialize objects. In
33+
* order to use this module just add this module into your JsonMapper configuration.
34+
*
35+
* <p>
36+
* The recommended way to configure it is to use {@link SecurityJacksonModules} in order
37+
* to enable properly automatic inclusion of type information with related validation.
38+
*
39+
* <pre>
40+
* ClassLoader loader = getClass().getClassLoader();
41+
* JsonMapper mapper = JsonMapper.builder()
42+
* .addModules(SecurityJacksonModules.getModules(loader))
43+
* .build();
44+
* </pre>
45+
*
46+
* @author Sebastien Deleuze
47+
* @author Jitendra Singh
48+
* @since 7.0
49+
* @see SecurityJacksonModules
50+
*/
51+
public class CasJacksonModule extends SecurityJacksonModule {
52+
53+
public CasJacksonModule() {
54+
super(CasJacksonModule.class.getName(), new Version(1, 0, 0, null, null, null));
55+
}
56+
57+
@Override
58+
public void configurePolymorphicTypeValidator(BasicPolymorphicTypeValidator.Builder builder) {
59+
builder.allowIfSubType(AssertionImpl.class)
60+
.allowIfSubType(AttributePrincipalImpl.class)
61+
.allowIfSubType(CasAuthenticationToken.class);
62+
}
63+
64+
@Override
65+
public void setupModule(SetupContext context) {
66+
context.setMixIn(AssertionImpl.class, AssertionImplMixin.class);
67+
context.setMixIn(AttributePrincipalImpl.class, AttributePrincipalImplMixin.class);
68+
context.setMixIn(CasAuthenticationToken.class, CasAuthenticationTokenMixin.class);
69+
}
70+
71+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright 2004-present the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
/**
18+
* Jackson 3+ serialization support for CAS.
19+
*/
20+
package org.springframework.security.cas.jackson;

‎cas/src/main/java/org/springframework/security/cas/jackson2/AssertionImplMixin.java‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
* this class we need to register with
3434
* {@link com.fasterxml.jackson.databind.ObjectMapper}. Type information will be stored
3535
* in @class property.
36+
*
3637
* <p>
3738
* <pre>
3839
* ObjectMapper mapper = new ObjectMapper();
@@ -43,7 +44,11 @@
4344
* @since 4.2
4445
* @see CasJackson2Module
4546
* @see org.springframework.security.jackson2.SecurityJackson2Modules
47+
* @deprecated as of 7.0 in favor of
48+
* {@code org.springframework.security.cas.jackson.AssertionImplMixin} based on Jackson 3
4649
*/
50+
@SuppressWarnings("removal")
51+
@Deprecated(forRemoval = true)
4752
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY)
4853
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE,
4954
isGetterVisibility = JsonAutoDetect.Visibility.NONE)

‎cas/src/main/java/org/springframework/security/cas/jackson2/AttributePrincipalImplMixin.java‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
* {@link org.apereo.cas.client.authentication.AttributePrincipalImpl} which is used with
3131
* {@link org.springframework.security.cas.authentication.CasAuthenticationToken}. Type
3232
* information will be stored in property named @class.
33+
*
3334
* <p>
3435
* <pre>
3536
* ObjectMapper mapper = new ObjectMapper();
@@ -40,7 +41,12 @@
4041
* @since 4.2
4142
* @see CasJackson2Module
4243
* @see org.springframework.security.jackson2.SecurityJackson2Modules
44+
* @deprecated as of 7.0 in favor of
45+
* {@code org.springframework.security.cas.jackson.AttributePrincipalImplMixin} based on
46+
* Jackson 3
4347
*/
48+
@SuppressWarnings("removal")
49+
@Deprecated(forRemoval = true)
4450
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY)
4551
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE,
4652
isGetterVisibility = JsonAutoDetect.Visibility.NONE)

‎cas/src/main/java/org/springframework/security/cas/jackson2/CasAuthenticationTokenMixin.java‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
* </ol>
4141
*
4242
* <p>
43-
*
4443
* <pre>
4544
* ObjectMapper mapper = new ObjectMapper();
4645
* mapper.registerModule(new CasJackson2Module());
@@ -50,7 +49,12 @@
5049
* @since 4.2
5150
* @see CasJackson2Module
5251
* @see org.springframework.security.jackson2.SecurityJackson2Modules
52+
* @deprecated as of 7.0 in favor of
53+
* {@code org.springframework.security.cas.jackson.CasAuthenticationTokenMixin} based on
54+
* Jackson 3
5355
*/
56+
@SuppressWarnings("removal")
57+
@Deprecated(forRemoval = true)
5458
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY)
5559
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, isGetterVisibility = JsonAutoDetect.Visibility.NONE,
5660
getterVisibility = JsonAutoDetect.Visibility.NONE, creatorVisibility = JsonAutoDetect.Visibility.ANY)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /