mirror of
				https://github.com/spring-projects/spring-security.git
				synced 2025-10-30 22:28:46 +00:00 
			
		
		
		
	Make WebAuthenticationDetails constructor public
Closes gh-10564
This commit is contained in:
		
							parent
							
								
									a2d1965c25
								
							
						
					
					
						commit
						d6cbacb27a
					
				| @ -43,9 +43,7 @@ public class WebAuthenticationDetails implements Serializable { | |||||||
| 	 * @param request that the authentication request was received from | 	 * @param request that the authentication request was received from | ||||||
| 	 */ | 	 */ | ||||||
| 	public WebAuthenticationDetails(HttpServletRequest request) { | 	public WebAuthenticationDetails(HttpServletRequest request) { | ||||||
| 		this.remoteAddress = request.getRemoteAddr(); | 		this(request.getRemoteAddr(), extractSessionId(request)); | ||||||
| 		HttpSession session = request.getSession(false); |  | ||||||
| 		this.sessionId = (session != null) ? session.getId() : null; |  | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	/** | 	/** | ||||||
| @ -53,11 +51,16 @@ public class WebAuthenticationDetails implements Serializable { | |||||||
| 	 * @param remoteAddress remote address of current request | 	 * @param remoteAddress remote address of current request | ||||||
| 	 * @param sessionId session id | 	 * @param sessionId session id | ||||||
| 	 */ | 	 */ | ||||||
| 	private WebAuthenticationDetails(final String remoteAddress, final String sessionId) { | 	public WebAuthenticationDetails(String remoteAddress, String sessionId) { | ||||||
| 		this.remoteAddress = remoteAddress; | 		this.remoteAddress = remoteAddress; | ||||||
| 		this.sessionId = sessionId; | 		this.sessionId = sessionId; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	private static String extractSessionId(HttpServletRequest request) { | ||||||
|  | 		HttpSession session = request.getSession(false); | ||||||
|  | 		return (session != null) ? session.getId() : null; | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
| 	@Override | 	@Override | ||||||
| 	public boolean equals(Object obj) { | 	public boolean equals(Object obj) { | ||||||
| 		if (obj instanceof WebAuthenticationDetails) { | 		if (obj instanceof WebAuthenticationDetails) { | ||||||
|  | |||||||
| @ -64,6 +64,13 @@ public class WebAuthenticationDetailsMixinTests extends AbstractMixinTests { | |||||||
| 		JSONAssert.assertEquals(AUTHENTICATION_DETAILS_JSON, actualJson, true); | 		JSONAssert.assertEquals(AUTHENTICATION_DETAILS_JSON, actualJson, true); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	@Test | ||||||
|  | 	public void webAuthenticationDetailsJackson2SerializeTest() throws JsonProcessingException, JSONException { | ||||||
|  | 		WebAuthenticationDetails details = new WebAuthenticationDetails("/localhost", "1"); | ||||||
|  | 		String actualJson = this.mapper.writeValueAsString(details); | ||||||
|  | 		JSONAssert.assertEquals(AUTHENTICATION_DETAILS_JSON, actualJson, true); | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
| 	@Test | 	@Test | ||||||
| 	public void webAuthenticationDetailsDeserializeTest() throws IOException { | 	public void webAuthenticationDetailsDeserializeTest() throws IOException { | ||||||
| 		WebAuthenticationDetails details = this.mapper.readValue(AUTHENTICATION_DETAILS_JSON, | 		WebAuthenticationDetails details = this.mapper.readValue(AUTHENTICATION_DETAILS_JSON, | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user