-
- if (connected) {
- //Read the Response
- LOGGER.debug("connected to the PAP : " + getPAP());
- LOGGER.debug("--- Response: ---");
- Map<String, List<String>> headers = connection.getHeaderFields();
- for (String key : headers.keySet()) {
- LOGGER.debug("Header :" + key + " Value: " + headers.get(key));
- }
- try {
- if (connection.getResponseCode() == 200) {
- // Check for successful creation of policy
- version = connection.getHeaderField("version");
- LOGGER.debug("ActiveVersion from the Header: " + version);
- } else if (connection.getResponseCode() == 403) {
- LOGGER.error(XACMLErrorConstants.ERROR_PERMISSIONS + "response code of the URL is "
- + connection.getResponseCode() + ". PEP is not Authorized for making this Request!! \n Contact Administrator for this Scope. ");
- version = "pe100";
- } else if (connection.getResponseCode() == 404) {
- LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "response code of the URL is "
- + connection.getResponseCode() + ". This indicates a problem with getting the version from the PAP");
- version = "pe300";
- } else {
- LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "BAD REQUEST: Error occured while getting the version from the PAP. The request may be incorrect.");
- }
- } catch (IOException e) {
- LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + e);
- try {
- throw new Exception(XACMLErrorConstants.ERROR_DATA_ISSUE +"ERROR in connecting to the PAP ", e);
- } catch (Exception e1) {
- LOGGER.error(e1.getMessage() + e1);
- }
- }
-
- } else {
- LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Unable to get valid response from PAP(s) " + paps);
- try {
- throw new Exception(XACMLErrorConstants.ERROR_DATA_ISSUE +"ERROR in connecting to the PAP ");
- } catch (Exception e) {
- LOGGER.error(e.getMessage() + e);
- }
- }