From 68950f6bb08b7838ba82abe6a363aa1f84bfedb9 Mon Sep 17 00:00:00 2001 From: Thomas Bouffard Date: Thu, 31 Oct 2019 15:38:01 +0100 Subject: [PATCH] refactor: introduce constant for the JSESSIONID cookie --- src/main/java/com/cdancy/jenkins/rest/JenkinsConstants.java | 2 ++ .../java/com/cdancy/jenkins/rest/parsers/CrumbParser.java | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/cdancy/jenkins/rest/JenkinsConstants.java b/src/main/java/com/cdancy/jenkins/rest/JenkinsConstants.java index b0263214..a5259744 100644 --- a/src/main/java/com/cdancy/jenkins/rest/JenkinsConstants.java +++ b/src/main/java/com/cdancy/jenkins/rest/JenkinsConstants.java @@ -41,6 +41,8 @@ public class JenkinsConstants { public static final String OPTIONAL_FOLDER_PATH_PARAM = "optionalFolderPath"; + public static final String JENKINS_COOKIES_JSESSIONID = "JSESSIONID"; + protected JenkinsConstants() { throw new UnsupportedOperationException("Purposefully not implemented"); } diff --git a/src/main/java/com/cdancy/jenkins/rest/parsers/CrumbParser.java b/src/main/java/com/cdancy/jenkins/rest/parsers/CrumbParser.java index 9e04cdb9..92853ac7 100644 --- a/src/main/java/com/cdancy/jenkins/rest/parsers/CrumbParser.java +++ b/src/main/java/com/cdancy/jenkins/rest/parsers/CrumbParser.java @@ -17,6 +17,8 @@ package com.cdancy.jenkins.rest.parsers; +import static com.cdancy.jenkins.rest.JenkinsConstants.JENKINS_COOKIES_JSESSIONID; + import com.cdancy.jenkins.rest.domain.crumb.Crumb; import com.google.common.base.Function; @@ -55,7 +57,7 @@ private static String crumbValue(HttpResponse input) throws IOException { private static String sessionIdCookie(HttpResponse input) { return input.getHeaders().get(HttpHeaders.SET_COOKIE).stream() - .filter(c -> c.startsWith("JSESSIONID")) + .filter(c -> c.startsWith(JENKINS_COOKIES_JSESSIONID)) .findFirst() .orElse(""); }