16
16
17
17
package org .springframework .security .web .authentication .rememberme ;
18
18
19
- import java .io .UnsupportedEncodingException ;
20
19
import java .net .URLDecoder ;
21
20
import java .net .URLEncoder ;
22
21
import java .nio .charset .StandardCharsets ;
@@ -170,7 +169,7 @@ public Authentication autoLogin(HttpServletRequest request, HttpServletResponse
170
169
*/
171
170
protected String extractRememberMeCookie (HttpServletRequest request ) {
172
171
Cookie [] cookies = request .getCookies ();
173
- if (( cookies == null ) || ( cookies . length == 0 ) ) {
172
+ if (cookies == null ) {
174
173
return null ;
175
174
}
176
175
for (Cookie cookie : cookies ) {
@@ -220,12 +219,7 @@ protected String[] decodeCookie(String cookieValue) throws InvalidCookieExceptio
220
219
}
221
220
String [] tokens = StringUtils .delimitedListToStringArray (cookieAsPlainText , DELIMITER );
222
221
for (int i = 0 ; i < tokens .length ; i ++) {
223
- try {
224
- tokens [i ] = URLDecoder .decode (tokens [i ], StandardCharsets .UTF_8 .toString ());
225
- }
226
- catch (UnsupportedEncodingException ex ) {
227
- this .logger .error (ex .getMessage (), ex );
228
- }
222
+ tokens [i ] = URLDecoder .decode (tokens [i ], StandardCharsets .UTF_8 );
229
223
}
230
224
return tokens ;
231
225
}
@@ -238,12 +232,7 @@ protected String[] decodeCookie(String cookieValue) throws InvalidCookieExceptio
238
232
protected String encodeCookie (String [] cookieTokens ) {
239
233
StringBuilder sb = new StringBuilder ();
240
234
for (int i = 0 ; i < cookieTokens .length ; i ++) {
241
- try {
242
- sb .append (URLEncoder .encode (cookieTokens [i ], StandardCharsets .UTF_8 .toString ()));
243
- }
244
- catch (UnsupportedEncodingException ex ) {
245
- this .logger .error (ex .getMessage (), ex );
246
- }
235
+ sb .append (URLEncoder .encode (cookieTokens [i ], StandardCharsets .UTF_8 ));
247
236
if (i < cookieTokens .length - 1 ) {
248
237
sb .append (DELIMITER );
249
238
}
0 commit comments