-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #340 from PerimeterX/release/v6.9.4
Release/v6.9.4
- Loading branch information
Showing
12 changed files
with
132 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.perimeterx.utils; | ||
|
||
import com.perimeterx.models.configuration.PXConfiguration; | ||
import org.apache.http.client.methods.HttpRequestBase; | ||
|
||
import static com.perimeterx.utils.Constants.*; | ||
import static org.apache.commons.lang3.StringUtils.isBlank; | ||
|
||
public class PXResourcesUtil { | ||
public static boolean isValidPxThirdPartyRequest(HttpRequestBase req) { | ||
if (req != null && req.getHeaders(FIRST_PARTY_HEADER_NAME).length > 0) { | ||
return FIRST_PARTY_HEADER_VALUE | ||
.equals(req.getFirstHeader(FIRST_PARTY_HEADER_NAME).getValue()); | ||
} | ||
return false; | ||
} | ||
|
||
public static String getPxCaptchaURL(PXConfiguration config, String params, boolean alternativeCaptcha) { | ||
final String host = alternativeCaptcha ? ALT_CAPTCHA_HOST : CAPTCHA_HOST; | ||
String url = URL_HTTPS_PREFIX + host + SLASH + config.getAppId() + CAPTCHA_FIRST_PARTY_FILE_PATH; | ||
|
||
if (!isBlank(params)) { | ||
url += QUESTION_MARK + params; | ||
} | ||
return url; | ||
} | ||
|
||
public static String getPxSensorURL(PXConfiguration config) { | ||
final String path = String.format("/%s%s", config.getAppId(), SENSOR_FIRST_PARTY_PATH); | ||
return URL_HTTPS_PREFIX + config.getClientHost() + path; | ||
} | ||
|
||
public static String getPxXhrUrl(PXConfiguration config, String requestURI) { | ||
if (isBlank(requestURI)) { | ||
return null; | ||
} | ||
final String firstPartyAppIdForm = config.getAppId().substring(2); | ||
final String xhrPrefix = String.format("/%s/%s", firstPartyAppIdForm, XHR_PATH); | ||
final String path = requestURI.substring(xhrPrefix.length()); | ||
|
||
return config.getCollectorUrl() + path; | ||
} | ||
} |
Oops, something went wrong.