mirror of
				https://github.com/spring-projects/spring-security.git
				synced 2025-10-24 19:28:45 +00:00 
			
		
		
		
	Polish CAS Authentication Builder
Issue gh-17861
This commit is contained in:
		
							parent
							
								
									dd50dc0c40
								
							
						
					
					
						commit
						18fbf88993
					
				| @ -23,7 +23,6 @@ import org.apereo.cas.client.validation.Assertion; | |||||||
| import org.jspecify.annotations.Nullable; | import org.jspecify.annotations.Nullable; | ||||||
| 
 | 
 | ||||||
| import org.springframework.security.authentication.AbstractAuthenticationToken; | import org.springframework.security.authentication.AbstractAuthenticationToken; | ||||||
| import org.springframework.security.core.Authentication; |  | ||||||
| import org.springframework.security.core.GrantedAuthority; | import org.springframework.security.core.GrantedAuthority; | ||||||
| import org.springframework.security.core.userdetails.UserDetails; | import org.springframework.security.core.userdetails.UserDetails; | ||||||
| import org.springframework.util.Assert; | import org.springframework.util.Assert; | ||||||
| @ -183,7 +182,7 @@ public class CasAuthenticationToken extends AbstractAuthenticationToken implemen | |||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	/** | 	/** | ||||||
| 	 * A builder preserving the concrete {@link Authentication} type | 	 * A builder of {@link CasAuthenticationToken} instances | ||||||
| 	 * | 	 * | ||||||
| 	 * @since 7.0 | 	 * @since 7.0 | ||||||
| 	 */ | 	 */ | ||||||
| @ -208,8 +207,13 @@ public class CasAuthenticationToken extends AbstractAuthenticationToken implemen | |||||||
| 			this.assertion = token.assertion; | 			this.assertion = token.assertion; | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		public B keyHash(Integer keyHash) { | 		/** | ||||||
| 			this.keyHash = keyHash; | 		 * Use this key | ||||||
|  | 		 * @param key the key to use | ||||||
|  | 		 * @return the {@link Builder} for further configurations | ||||||
|  | 		 */ | ||||||
|  | 		public B key(String key) { | ||||||
|  | 			this.keyHash = key.hashCode(); | ||||||
| 			return (B) this; | 			return (B) this; | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| @ -227,11 +231,21 @@ public class CasAuthenticationToken extends AbstractAuthenticationToken implemen | |||||||
| 			return (B) this; | 			return (B) this; | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
|  | 		/** | ||||||
|  | 		 * Use this {@link UserDetails} | ||||||
|  | 		 * @param userDetails the {@link UserDetails} to use | ||||||
|  | 		 * @return the {@link Builder} for further configurations | ||||||
|  | 		 */ | ||||||
| 		public B userDetails(UserDetails userDetails) { | 		public B userDetails(UserDetails userDetails) { | ||||||
| 			this.userDetails = userDetails; | 			this.userDetails = userDetails; | ||||||
| 			return (B) this; | 			return (B) this; | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
|  | 		/** | ||||||
|  | 		 * Use this {@link Assertion} | ||||||
|  | 		 * @param assertion the {@link Assertion} to use | ||||||
|  | 		 * @return the {@link Builder} for further configurations | ||||||
|  | 		 */ | ||||||
| 		public B assertion(Assertion assertion) { | 		public B assertion(Assertion assertion) { | ||||||
| 			this.assertion = assertion; | 			this.assertion = assertion; | ||||||
| 			return (B) this; | 			return (B) this; | ||||||
|  | |||||||
| @ -22,7 +22,6 @@ import java.util.Collection; | |||||||
| import org.jspecify.annotations.Nullable; | import org.jspecify.annotations.Nullable; | ||||||
| 
 | 
 | ||||||
| import org.springframework.security.authentication.AbstractAuthenticationToken; | import org.springframework.security.authentication.AbstractAuthenticationToken; | ||||||
| import org.springframework.security.core.Authentication; |  | ||||||
| import org.springframework.security.core.GrantedAuthority; | import org.springframework.security.core.GrantedAuthority; | ||||||
| import org.springframework.util.Assert; | import org.springframework.util.Assert; | ||||||
| 
 | 
 | ||||||
| @ -122,7 +121,7 @@ public class CasServiceTicketAuthenticationToken extends AbstractAuthenticationT | |||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	/** | 	/** | ||||||
| 	 * A builder preserving the concrete {@link Authentication} type | 	 * A builder of {@link CasServiceTicketAuthenticationToken} instances | ||||||
| 	 * | 	 * | ||||||
| 	 * @since 7.0 | 	 * @since 7.0 | ||||||
| 	 */ | 	 */ | ||||||
|  | |||||||
| @ -167,7 +167,7 @@ public class CasAuthenticationTokenTests { | |||||||
| 				AuthorityUtils.createAuthorityList("FACTOR_TWO"), PasswordEncodedUser.admin(), assertionTwo); | 				AuthorityUtils.createAuthorityList("FACTOR_TWO"), PasswordEncodedUser.admin(), assertionTwo); | ||||||
| 		CasAuthenticationToken authentication = factorOne.toBuilder() | 		CasAuthenticationToken authentication = factorOne.toBuilder() | ||||||
| 			.authorities((a) -> a.addAll(factorTwo.getAuthorities())) | 			.authorities((a) -> a.addAll(factorTwo.getAuthorities())) | ||||||
| 			.keyHash(factorTwo.getKeyHash()) | 			.key("yek") | ||||||
| 			.principal(factorTwo.getPrincipal()) | 			.principal(factorTwo.getPrincipal()) | ||||||
| 			.credentials(factorTwo.getCredentials()) | 			.credentials(factorTwo.getCredentials()) | ||||||
| 			.userDetails(factorTwo.getUserDetails()) | 			.userDetails(factorTwo.getUserDetails()) | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user