List of usage examples for java.net URISyntaxException getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:org.apache.manifoldcf.agents.output.hdfs.HDFSOutputConnector.java
/** Remove a document using the connector. * Note that the last outputDescription is included, since it may be necessary for the connector to use such information to know how to properly remove the document. *@param documentURI is the URI of the document. The URI is presumed to be the unique identifier which the output data store will use to process * and serve the document. This URI is constructed by the repository connector which fetches the document, and is thus universal across all output connectors. *@param outputDescription is the last description string that was constructed for this document by the getOutputDescription() method above. *@param activities is the handle to an object that the implementer of an output connector may use to perform operations, such as logging processing activity. *///w w w. j a v a2s. co m @Override public void removeDocument(String documentURI, String outputDescription, IOutputRemoveActivity activities) throws ManifoldCFException, ServiceInterruption { try { HDFSOutputSpecs specs = new HDFSOutputSpecs(outputDescription); /* * make path */ StringBuffer strBuff = new StringBuffer(); if (specs.getRootPath() != null) { strBuff.append(specs.getRootPath()); } strBuff.append("/"); strBuff.append(documentURItoFilePath(documentURI)); Path path = new Path(strBuff.toString()); Long startTime = new Long(System.currentTimeMillis()); deleteFile(path, activities, documentURI); activities.recordActivity(startTime, REMOVE_ACTIVITY, null, documentURI, "OK", null); } catch (URISyntaxException e) { activities.recordActivity(null, REMOVE_ACTIVITY, null, documentURI, e.getClass().getSimpleName().toUpperCase(Locale.ROOT), "Failed to delete document due to: " + e.getMessage()); handleURISyntaxException(e); } }
From source file:org.apache.manifoldcf.agents.output.hdfs.HDFSOutputConnector.java
/** Add (or replace) a document in the output data store using the connector. * This method presumes that the connector object has been configured, and it is thus able to communicate with the output data store should that be * necessary./*from w ww. j a v a 2 s . c o m*/ *@param documentURI is the URI of the document. The URI is presumed to be the unique identifier which the output data store will use to process * and serve the document. This URI is constructed by the repository connector which fetches the document, and is thus universal across all output connectors. *@param pipelineDescription includes the description string that was constructed for this document by the getOutputDescription() method. *@param document is the document data to be processed (handed to the output data store). *@param authorityNameString is the name of the authority responsible for authorizing any access tokens passed in with the repository document. May be null. *@param activities is the handle to an object that the implementer of a pipeline connector may use to perform operations, such as logging processing activity, * or sending a modified document to the next stage in the pipeline. *@return the document status (accepted or permanently rejected). *@throws IOException only if there's a stream error reading the document data. */ @Override public int addOrReplaceDocumentWithException(String documentURI, VersionContext pipelineDescription, RepositoryDocument document, String authorityNameString, IOutputAddActivity activities) throws ManifoldCFException, ServiceInterruption, IOException { HDFSOutputSpecs specs = new HDFSOutputSpecs(getSpecNode(pipelineDescription.getSpecification())); try { /* * make file path */ StringBuffer strBuff = new StringBuffer(); if (specs.getRootPath() != null) { strBuff.append(specs.getRootPath()); } strBuff.append("/"); strBuff.append(documentURItoFilePath(documentURI)); Path path = new Path(strBuff.toString()); Long startTime = new Long(System.currentTimeMillis()); createFile(path, document.getBinaryStream(), activities, documentURI); activities.recordActivity(startTime, INGEST_ACTIVITY, new Long(document.getBinaryLength()), documentURI, "OK", null); return DOCUMENTSTATUS_ACCEPTED; } catch (URISyntaxException e) { activities.recordActivity(null, INGEST_ACTIVITY, new Long(document.getBinaryLength()), documentURI, e.getClass().getSimpleName().toUpperCase(Locale.ROOT), "Failed to write document due to: " + e.getMessage()); handleURISyntaxException(e); return DOCUMENTSTATUS_REJECTED; } }
From source file:org.rssowl.core.internal.connection.DefaultProtocolHandler.java
byte[] loadFavicon(URI link, boolean isFavicon, boolean rewriteHost, IProgressMonitor monitor) { InputStream inS = null;// w ww . java 2 s . c o m boolean isError = false; try { /* Define Properties for Connection */ Map<Object, Object> properties = new HashMap<Object, Object>(); properties.put(IConnectionPropertyConstants.CON_TIMEOUT, FAVICON_CON_TIMEOUT); properties.put(IConnectionPropertyConstants.PROGRESS_MONITOR, monitor); /* Load Favicon */ URI faviconLink = isFavicon ? link : URIUtils.toFaviconUrl(link, rewriteHost); if (faviconLink == null) return null; inS = openStream(faviconLink, properties); ByteArrayOutputStream fos = new ByteArrayOutputStream(); byte buffer[] = new byte[0xffff]; int nbytes; while ((nbytes = inS.read(buffer)) != -1) fos.write(buffer, 0, nbytes); return fos.toByteArray(); } catch (URISyntaxException e) { /* Ignore */ } catch (ConnectionException e) { isError = true; /* Try rewriting the Host to obtain the Favicon */ if (!rewriteHost && !isFavicon) { String exceptionName = e.getClass().getName(); /* Only retry in case this is a generic ConnectionException */ if (ConnectionException.class.getName().equals(exceptionName)) return loadFavicon(link, false, true, monitor); } } catch (IOException e) { /* Ignore */ } finally { closeStream(inS, isError); } return null; }
From source file:com.algolia.search.saas.APIClient.java
private JSONObject _requestByHost(HttpRequestBase req, String host, String url, String json, HashMap<String, String> errors) throws AlgoliaException { req.reset();/*from w w w .jav a 2 s .com*/ // set URL try { req.setURI(new URI("https://" + host + url)); } catch (URISyntaxException e) { // never reached throw new IllegalStateException(e); } // set auth headers req.setHeader("X-Algolia-Application-Id", this.applicationID); if (forwardAdminAPIKey == null) { req.setHeader("X-Algolia-API-Key", this.apiKey); } else { req.setHeader("X-Algolia-API-Key", this.forwardAdminAPIKey); req.setHeader("X-Forwarded-For", this.forwardEndUserIP); req.setHeader("X-Forwarded-API-Key", this.forwardRateLimitAPIKey); } for (Entry<String, String> entry : headers.entrySet()) { req.setHeader(entry.getKey(), entry.getValue()); } // set user agent req.setHeader("User-Agent", "Algolia for Java " + version); // set JSON entity if (json != null) { if (!(req instanceof HttpEntityEnclosingRequestBase)) { throw new IllegalArgumentException("Method " + req.getMethod() + " cannot enclose entity"); } req.setHeader("Content-type", "application/json"); try { StringEntity se = new StringEntity(json, "UTF-8"); se.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/json")); ((HttpEntityEnclosingRequestBase) req).setEntity(se); } catch (UnsupportedEncodingException e) { throw new AlgoliaException("Invalid JSON Object: " + json); // $COVERAGE-IGNORE$ } } RequestConfig config = RequestConfig.custom().setSocketTimeout(httpSocketTimeoutMS) .setConnectTimeout(httpConnectTimeoutMS).setConnectionRequestTimeout(httpConnectTimeoutMS).build(); req.setConfig(config); HttpResponse response; try { response = httpClient.execute(req); } catch (IOException e) { // on error continue on the next host errors.put(host, String.format("%s=%s", e.getClass().getName(), e.getMessage())); return null; } try { int code = response.getStatusLine().getStatusCode(); if (code / 100 == 4) { String message = ""; try { message = EntityUtils.toString(response.getEntity()); } catch (ParseException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } if (code == 400) { throw new AlgoliaException(code, message.length() > 0 ? message : "Bad request"); } else if (code == 403) { throw new AlgoliaException(code, message.length() > 0 ? message : "Invalid Application-ID or API-Key"); } else if (code == 404) { throw new AlgoliaException(code, message.length() > 0 ? message : "Resource does not exist"); } else { throw new AlgoliaException(code, message.length() > 0 ? message : "Error"); } } if (code / 100 != 2) { try { errors.put(host, EntityUtils.toString(response.getEntity())); } catch (IOException e) { errors.put(host, String.valueOf(code)); } // KO, continue return null; } try { InputStream istream = response.getEntity().getContent(); InputStreamReader is = new InputStreamReader(istream, "UTF-8"); JSONTokener tokener = new JSONTokener(is); JSONObject res = new JSONObject(tokener); is.close(); return res; } catch (IOException e) { return null; } catch (JSONException e) { throw new AlgoliaException("JSON decode error:" + e.getMessage()); } } finally { req.releaseConnection(); } }
From source file:microsoft.exchange.webservices.data.AutodiscoverService.java
/** * Tries to get Autodiscover settings using redirection Url. * * @param <TSettings> the generic type * @param cls the cls/* ww w. ja va2 s . co m*/ * @param emailAddress The email address. * @param redirectionUrl Redirection Url. * @param settings The settings. * @return boolean The boolean. * @throws AutodiscoverLocalException the autodiscover local exception * @throws AutodiscoverRemoteException the autodiscover remote exception * @throws Exception the exception */ private <TSettings extends ConfigurationSettingsBase> boolean tryLastChanceHostRedirection(Class<TSettings> cls, String emailAddress, URI redirectionUrl, OutParam<TSettings> settings) throws AutodiscoverLocalException, AutodiscoverRemoteException, Exception { List<String> redirectionEmailAddresses = new ArrayList<String>(); // Bug 60274: Performing a non-SSL HTTP GET to retrieve a redirection // URL is potentially unsafe. We allow the caller // to specify delegate to be called to determine whether we are allowed // to use the redirection URL. if (this.callRedirectionUrlValidationCallback(redirectionUrl.toString())) { for (int currentHop = 0; currentHop < AutodiscoverService.AutodiscoverMaxRedirections; currentHop++) { try { settings.setParam(this.getLegacyUserSettingsAtUrl(cls, emailAddress, redirectionUrl)); switch (settings.getParam().getResponseType()) { case Success: return true; case Error: throw new AutodiscoverRemoteException(Strings.AutodiscoverError, settings.getParam().getError()); case RedirectAddress: // If this email address was already tried, //we may have a loop // in SCP lookups. Disable consideration of SCP records. this.disableScpLookupIfDuplicateRedirection(settings.getParam().getRedirectTarget(), redirectionEmailAddresses); OutParam<Integer> outParam = new OutParam<Integer>(); outParam.setParam(currentHop); settings.setParam(this.internalGetLegacyUserSettings(cls, emailAddress, redirectionEmailAddresses, outParam)); currentHop = outParam.getParam(); return true; case RedirectUrl: try { redirectionUrl = new URI(settings.getParam().getRedirectTarget()); } catch (URISyntaxException ex) { this.traceMessage(TraceFlags.AutodiscoverConfiguration, String.format("Service " + "returned " + "invalid " + "redirection " + "URL %s", settings.getParam().getRedirectTarget())); return false; } break; default: String failureMessage = String.format( "Autodiscover call at %s failed with error %s, target %s", redirectionUrl, settings.getParam().getResponseType(), settings.getParam().getRedirectTarget()); this.traceMessage(TraceFlags.AutodiscoverConfiguration, failureMessage); return false; } } catch (XMLStreamException ex) { // If the response is malformed, it wasn't a valid // Autodiscover endpoint. this.traceMessage(TraceFlags.AutodiscoverConfiguration, String.format( "%s failed: XML parsing error: %s", redirectionUrl.toString(), ex.getMessage())); return false; } catch (IOException ex) { this.traceMessage(TraceFlags.AutodiscoverConfiguration, String.format("%s failed: I/O error: %s", redirectionUrl, ex.getMessage())); return false; } catch (Exception ex) { // TODO: BUG response is always null HttpWebRequest response = null; OutParam<URI> outParam = new OutParam<URI>(); if ((response != null) && this.tryGetRedirectionResponse(response, outParam)) { redirectionUrl = outParam.getParam(); this.traceMessage(TraceFlags.AutodiscoverConfiguration, String.format("Host returned a " + "redirection" + " to url %s", redirectionUrl)); } else { if (response != null) { this.processHttpErrorResponse(response, ex); } this.traceMessage(TraceFlags.AutodiscoverConfiguration, String.format("%s failed: %s (%s)", url, ex.getClass().getName(), ex.getMessage())); return false; } } } } return false; }
From source file:microsoft.exchange.webservices.data.autodiscover.AutodiscoverService.java
/** * Tries to get Autodiscover settings using redirection Url. * * @param <TSettings> the generic type * @param cls the cls//from w ww.j a v a 2s . co m * @param emailAddress The email address. * @param redirectionUrl Redirection Url. * @param settings The settings. * @return boolean The boolean. * @throws AutodiscoverLocalException the autodiscover local exception * @throws AutodiscoverRemoteException the autodiscover remote exception * @throws Exception the exception */ private <TSettings extends ConfigurationSettingsBase> boolean tryLastChanceHostRedirection(Class<TSettings> cls, String emailAddress, URI redirectionUrl, OutParam<TSettings> settings) throws AutodiscoverLocalException, AutodiscoverRemoteException, Exception { List<String> redirectionEmailAddresses = new ArrayList<String>(); // Bug 60274: Performing a non-SSL HTTP GET to retrieve a redirection // URL is potentially unsafe. We allow the caller // to specify delegate to be called to determine whether we are allowed // to use the redirection URL. if (this.callRedirectionUrlValidationCallback(redirectionUrl.toString())) { for (int currentHop = 0; currentHop < AutodiscoverService.AutodiscoverMaxRedirections; currentHop++) { try { settings.setParam(this.getLegacyUserSettingsAtUrl(cls, emailAddress, redirectionUrl)); switch (settings.getParam().getResponseType()) { case Success: return true; case Error: throw new AutodiscoverRemoteException("The Autodiscover service returned an error.", settings.getParam().getError()); case RedirectAddress: // If this email address was already tried, //we may have a loop // in SCP lookups. Disable consideration of SCP records. this.disableScpLookupIfDuplicateRedirection(settings.getParam().getRedirectTarget(), redirectionEmailAddresses); OutParam<Integer> outParam = new OutParam<Integer>(); outParam.setParam(currentHop); settings.setParam(this.internalGetLegacyUserSettings(cls, emailAddress, redirectionEmailAddresses, outParam)); currentHop = outParam.getParam(); return true; case RedirectUrl: try { redirectionUrl = new URI(settings.getParam().getRedirectTarget()); } catch (URISyntaxException ex) { this.traceMessage(TraceFlags.AutodiscoverConfiguration, String.format("Service " + "returned " + "invalid " + "redirection " + "URL %s", settings.getParam().getRedirectTarget())); return false; } break; default: String failureMessage = String.format( "Autodiscover call at %s failed with error %s, target %s", redirectionUrl, settings.getParam().getResponseType(), settings.getParam().getRedirectTarget()); this.traceMessage(TraceFlags.AutodiscoverConfiguration, failureMessage); return false; } } catch (XMLStreamException ex) { // If the response is malformed, it wasn't a valid // Autodiscover endpoint. this.traceMessage(TraceFlags.AutodiscoverConfiguration, String.format( "%s failed: XML parsing error: %s", redirectionUrl.toString(), ex.getMessage())); return false; } catch (IOException ex) { this.traceMessage(TraceFlags.AutodiscoverConfiguration, String.format("%s failed: I/O error: %s", redirectionUrl, ex.getMessage())); return false; } catch (Exception ex) { // TODO: BUG response is always null HttpWebRequest response = null; OutParam<URI> outParam = new OutParam<URI>(); if ((response != null) && this.tryGetRedirectionResponse(response, outParam)) { redirectionUrl = outParam.getParam(); this.traceMessage(TraceFlags.AutodiscoverConfiguration, String.format("Host returned a " + "redirection" + " to url %s", redirectionUrl)); } else { if (response != null) { this.processHttpErrorResponse(response, ex); } this.traceMessage(TraceFlags.AutodiscoverConfiguration, String.format("%s failed: %s (%s)", url, ex.getClass().getName(), ex.getMessage())); return false; } } } } return false; }
From source file:org.xdi.oxauth.authorize.ws.rs.AuthorizeRestWebServiceImpl.java
public Response requestAuthorization(String scope, String responseType, String clientId, String redirectUri, String state, String respMode, String nonce, String display, String prompt, Integer maxAge, String uiLocalesStr, String idTokenHint, String loginHint, String acrValuesStr, String amrValuesStr, String request, String requestUri, String requestSessionId, String sessionId, String accessToken, String method, String originHeaders, HttpServletRequest httpRequest, HttpServletResponse httpResponse, SecurityContext securityContext) { scope = ServerUtil.urlDecode(scope); // it may be encoded in uma case // ATTENTION : please do not add more parameter in this debug method because it will not work with Seam 2.2.2.Final , // there is limit of 10 parameters (hardcoded), see: org.jboss.seam.core.Interpolator#interpolate log.debug(// w w w .ja v a 2 s .c om "Attempting to request authorization: " + "responseType = {0}, clientId = {1}, scope = {2}, redirectUri = {3}, nonce = {4}, " + "state = {5}, request = {6}, isSecure = {7}, requestSessionId = {8}, sessionId = {9}", responseType, clientId, scope, redirectUri, nonce, state, request, securityContext.isSecure(), requestSessionId, sessionId); log.debug("Attempting to request authorization: " + "acrValues = {0}, amrValues = {1}, originHeaders = {4}", acrValuesStr, amrValuesStr, originHeaders); ResponseBuilder builder = Response.ok(); List<String> uiLocales = null; if (StringUtils.isNotBlank(uiLocalesStr)) { uiLocales = Util.splittedStringAsList(uiLocalesStr, " "); } List<ResponseType> responseTypes = ResponseType.fromString(responseType, " "); List<Prompt> prompts = Prompt.fromString(prompt, " "); List<String> acrValues = Util.splittedStringAsList(acrValuesStr, " "); List<String> amrValues = Util.splittedStringAsList(amrValuesStr, " "); ResponseMode responseMode = ResponseMode.getByValue(respMode); User user = sessionUser != null && StringUtils.isNotBlank(sessionUser.getUserDn()) ? userService.getUserByDn(sessionUser.getUserDn()) : null; try { sessionIdService.updateSessionIfNeeded(sessionUser, redirectUri, acrValuesStr); if (!AuthorizeParamsValidator.validateParams(responseType, clientId, prompts, nonce, request, requestUri)) { if (clientId != null && redirectUri != null && redirectionUriService.validateRedirectionUri(clientId, redirectUri) != null) { RedirectUri redirectUriResponse = new RedirectUri(redirectUri, responseTypes, responseMode); redirectUriResponse.parseQueryString(errorResponseFactory .getErrorAsQueryString(AuthorizeErrorResponseType.INVALID_REQUEST, state)); builder = RedirectUtil.getRedirectResponseBuilder(redirectUriResponse, httpRequest); } else { builder = Response.status(Response.Status.BAD_REQUEST.getStatusCode()); // 400 builder.entity( errorResponseFactory.getErrorAsJson(AuthorizeErrorResponseType.INVALID_REQUEST, state)); } } else { Client client = clientService.getClient(clientId); JwtAuthorizationRequest jwtAuthorizationRequest = null; if (client != null) { List<String> scopes = new ArrayList<String>(); if (StringHelper.isNotEmpty(scope)) { Set<String> grantedScopes = scopeChecker.checkScopesPolicy(client, scope); scopes.addAll(grantedScopes); } // Validate redirectUri redirectUri = redirectionUriService.validateRedirectionUri(clientId, redirectUri); boolean validRedirectUri = redirectUri != null; if (AuthorizeParamsValidator.validateResponseTypes(responseTypes, client)) { if (validRedirectUri) { if (ConfigurationFactory.instance().getConfiguration().getFederationEnabled()) { if (!federationDataService.hasAnyActiveTrust(client)) { log.debug( "Forbid authorization. Client is not in any trust relationship however federation is enabled for server. Client id: {0}, client redirectUris: {1}", client.getClientId(), client.getRedirectUris()); return error(Response.Status.UNAUTHORIZED, AuthorizeErrorResponseType.UNAUTHORIZED_CLIENT, state).build(); } } if (StringUtils.isNotBlank(accessToken)) { AuthorizationGrant authorizationGrant = authorizationGrantList .getAuthorizationGrantByAccessToken(accessToken); if (authorizationGrant == null) { RedirectUri redirectUriResponse = new RedirectUri(redirectUri, responseTypes, responseMode); redirectUriResponse.parseQueryString(errorResponseFactory.getErrorAsQueryString( AuthorizeErrorResponseType.ACCESS_DENIED, state)); builder = RedirectUtil.getRedirectResponseBuilder(redirectUriResponse, httpRequest); return builder.build(); } else { user = userService.getUser(authorizationGrant.getUserId()); sessionUser = sessionIdService.generateAuthenticatedSessionId(user.getDn(), prompt); } } if (StringUtils.isNotBlank(requestUri)) { boolean validRequestUri = false; try { URI reqUri = new URI(requestUri); String reqUriHash = reqUri.getFragment(); String reqUriWithoutFragment = reqUri.getScheme() + ":" + reqUri.getSchemeSpecificPart(); ClientRequest clientRequest = new ClientRequest(reqUriWithoutFragment); clientRequest.setHttpMethod(HttpMethod.GET); ClientResponse<String> clientResponse = clientRequest.get(String.class); int status = clientResponse.getStatus(); if (status == 200) { request = clientResponse.getEntity(String.class); if (StringUtils.isBlank(reqUriHash)) { validRequestUri = true; } else { String hash = JwtUtil .base64urlencode(JwtUtil.getMessageDigestSHA256(request)); validRequestUri = StringUtils.equals(reqUriHash, hash); } } if (validRequestUri) { requestUri = null; } else { RedirectUri redirectUriResponse = new RedirectUri(redirectUri, responseTypes, responseMode); redirectUriResponse .parseQueryString(errorResponseFactory.getErrorAsQueryString( AuthorizeErrorResponseType.INVALID_REQUEST_URI, state)); builder = RedirectUtil.getRedirectResponseBuilder(redirectUriResponse, httpRequest); return builder.build(); } } catch (URISyntaxException e) { log.error(e.getMessage(), e); } catch (UnknownHostException e) { log.error(e.getMessage(), e); } catch (ConnectException e) { log.error(e.getMessage(), e); } catch (Exception e) { log.error(e.getMessage(), e); } } boolean invalidOpenidRequestObject = false; if (StringUtils.isNotBlank(request)) { try { jwtAuthorizationRequest = new JwtAuthorizationRequest(request, client); if (!jwtAuthorizationRequest.getResponseTypes().containsAll(responseTypes) || !responseTypes .containsAll(jwtAuthorizationRequest.getResponseTypes())) { throw new InvalidJwtException( "The responseType parameter is not the same in the JWT"); } else if (jwtAuthorizationRequest.getClientId() != null && !jwtAuthorizationRequest.getClientId().equals(clientId)) { throw new InvalidJwtException( "The clientId parameter is not the same in the JWT"); } else if (!jwtAuthorizationRequest.getScopes().containsAll(scopes) || !scopes.containsAll(jwtAuthorizationRequest.getScopes())) { throw new InvalidJwtException( "The scope parameter is not the same in the JWT"); } else if (jwtAuthorizationRequest.getRedirectUri() != null && !jwtAuthorizationRequest.getRedirectUri().equals(redirectUri)) { throw new InvalidJwtException( "The redirectUri parameter is not the same in the JWT"); } else if (jwtAuthorizationRequest.getState() != null && StringUtils.isNotBlank(state) && !jwtAuthorizationRequest.getState().equals(state)) { throw new InvalidJwtException( "The state parameter is not the same in the JWT"); } else if (jwtAuthorizationRequest.getNonce() != null && StringUtils.isNotBlank(nonce) && !jwtAuthorizationRequest.getNonce().equals(nonce)) { throw new InvalidJwtException( "The nonce parameter is not the same in the JWT"); } else if (jwtAuthorizationRequest.getDisplay() != null && StringUtils.isNotBlank(display) && !jwtAuthorizationRequest .getDisplay().getParamName().equals(display)) { throw new InvalidJwtException( "The display parameter is not the same in the JWT"); } else if (!jwtAuthorizationRequest.getPrompts().isEmpty() && !prompts.isEmpty() && !jwtAuthorizationRequest.getPrompts().containsAll(prompts)) { throw new InvalidJwtException( "The prompt parameter is not the same in the JWT"); } else if (jwtAuthorizationRequest.getIdTokenMember() != null && jwtAuthorizationRequest.getIdTokenMember().getMaxAge() != null && maxAge != null && !jwtAuthorizationRequest.getIdTokenMember() .getMaxAge().equals(maxAge)) { throw new InvalidJwtException( "The maxAge parameter is not the same in the JWT"); } } catch (InvalidJwtException e) { invalidOpenidRequestObject = true; log.debug("Invalid JWT authorization request. Exception = {0}, Message = {1}", e, e.getClass().getName(), e.getMessage()); } catch (Exception e) { invalidOpenidRequestObject = true; log.debug("Invalid JWT authorization request. Exception = {0}, Message = {1}", e, e.getClass().getName(), e.getMessage()); } } if (invalidOpenidRequestObject) { RedirectUri redirectUriResponse = new RedirectUri(redirectUri, responseTypes, responseMode); redirectUriResponse.parseQueryString(errorResponseFactory.getErrorAsQueryString( AuthorizeErrorResponseType.INVALID_OPENID_REQUEST_OBJECT, state)); builder = RedirectUtil.getRedirectResponseBuilder(redirectUriResponse, httpRequest); } else { AuthorizationGrant authorizationGrant = null; RedirectUri redirectUriResponse = new RedirectUri(redirectUri, responseTypes, responseMode); if (jwtAuthorizationRequest != null && jwtAuthorizationRequest.getIdTokenMember() != null) { Claim userIdClaim = jwtAuthorizationRequest.getIdTokenMember() .getClaim(JwtClaimName.SUBJECT_IDENTIFIER); if (userIdClaim != null && userIdClaim.getClaimValue() != null && userIdClaim.getClaimValue().getValue() != null) { String userIdClaimValue = userIdClaim.getClaimValue().getValue(); if (user != null) { String userId = user.getUserId(); if (!userId.equalsIgnoreCase(userIdClaimValue)) { redirectUriResponse.parseQueryString( errorResponseFactory.getErrorAsQueryString( AuthorizeErrorResponseType.USER_MISMATCHED, state)); builder = RedirectUtil.getRedirectResponseBuilder( redirectUriResponse, httpRequest); return builder.build(); } } } } if (user == null) { identity.logout(); if (prompts.contains(Prompt.NONE)) { if (authenticationFilterService.isEnabled()) { Map<String, String> params = new HashMap<String, String>(); if (method.equals(HttpMethod.GET)) { params = QueryStringDecoder.decode(httpRequest.getQueryString()); } else { params = httpRequest.getParameterMap(); } String userDn = authenticationFilterService .processAuthenticationFilters(params); if (userDn != null) { sessionUser = sessionIdService .generateAuthenticatedSessionId(userDn, prompt); user = userService.getUserByDn(sessionUser.getUserDn()); Authenticator authenticator = (Authenticator) Component .getInstance(Authenticator.class, true); authenticator.authenticateExternallyWebService(user.getUserId()); identity.addRole("user"); } else { redirectUriResponse.parseQueryString( errorResponseFactory.getErrorAsQueryString( AuthorizeErrorResponseType.LOGIN_REQUIRED, state)); builder = RedirectUtil.getRedirectResponseBuilder( redirectUriResponse, httpRequest); return builder.build(); } } else { redirectUriResponse .parseQueryString(errorResponseFactory.getErrorAsQueryString( AuthorizeErrorResponseType.LOGIN_REQUIRED, state)); builder = RedirectUtil.getRedirectResponseBuilder(redirectUriResponse, httpRequest); return builder.build(); } } else { if (prompts.contains(Prompt.LOGIN)) { endSession(sessionId, httpRequest, httpResponse); prompts.remove(Prompt.LOGIN); } redirectToAuthorizationPage(redirectUriResponse, responseTypes, scope, clientId, redirectUri, state, responseMode, nonce, display, prompts, maxAge, uiLocales, idTokenHint, loginHint, acrValues, amrValues, request, requestUri, originHeaders); builder = RedirectUtil.getRedirectResponseBuilder(redirectUriResponse, httpRequest); return builder.build(); } } ClientAuthorizations clientAuthorizations = clientAuthorizationsService .findClientAuthorizations(user.getAttribute("inum"), client.getClientId()); if (clientAuthorizations != null && clientAuthorizations.getScopes() != null && Arrays.asList(clientAuthorizations.getScopes()).containsAll(scopes)) { sessionUser.addPermission(clientId, true); } if (prompts.contains(Prompt.NONE) && Boolean.parseBoolean(client.getTrustedClient())) { sessionUser.addPermission(clientId, true); } if (prompts.contains(Prompt.LOGIN)) { endSession(sessionId, httpRequest, httpResponse); prompts.remove(Prompt.LOGIN); redirectToAuthorizationPage(redirectUriResponse, responseTypes, scope, clientId, redirectUri, state, responseMode, nonce, display, prompts, maxAge, uiLocales, idTokenHint, loginHint, acrValues, amrValues, request, requestUri, originHeaders); builder = RedirectUtil.getRedirectResponseBuilder(redirectUriResponse, httpRequest); return builder.build(); } if (prompts.contains(Prompt.CONSENT) && !sessionUser.isPermissionGrantedForClient(clientId)) { prompts.remove(Prompt.CONSENT); redirectToAuthorizationPage(redirectUriResponse, responseTypes, scope, clientId, redirectUri, state, responseMode, nonce, display, prompts, maxAge, uiLocales, idTokenHint, loginHint, acrValues, amrValues, request, requestUri, originHeaders); builder = RedirectUtil.getRedirectResponseBuilder(redirectUriResponse, httpRequest); return builder.build(); } // OXAUTH-37 : Validate authentication max age boolean validAuthenticationMaxAge = true; Integer authenticationMaxAge = null; if (maxAge != null) { authenticationMaxAge = maxAge; } else if (!invalidOpenidRequestObject && jwtAuthorizationRequest != null && jwtAuthorizationRequest.getIdTokenMember() != null && jwtAuthorizationRequest.getIdTokenMember().getMaxAge() != null) { authenticationMaxAge = jwtAuthorizationRequest.getIdTokenMember().getMaxAge(); } GregorianCalendar now = new GregorianCalendar(TimeZone.getTimeZone("UTC")); GregorianCalendar userAuthenticationTime = new GregorianCalendar( TimeZone.getTimeZone("UTC")); userAuthenticationTime.setTime(sessionUser.getAuthenticationTime()); if (authenticationMaxAge != null) { userAuthenticationTime.add(Calendar.SECOND, authenticationMaxAge); validAuthenticationMaxAge = userAuthenticationTime.after(now); } else if (client.getDefaultMaxAge() != null) { userAuthenticationTime.add(Calendar.SECOND, client.getDefaultMaxAge()); validAuthenticationMaxAge = userAuthenticationTime.after(now); } if (!validAuthenticationMaxAge) { endSession(sessionId, httpRequest, httpResponse); redirectToAuthorizationPage(redirectUriResponse, responseTypes, scope, clientId, redirectUri, state, responseMode, nonce, display, prompts, maxAge, uiLocales, idTokenHint, loginHint, acrValues, amrValues, request, requestUri, originHeaders); builder = RedirectUtil.getRedirectResponseBuilder(redirectUriResponse, httpRequest); return builder.build(); } // OXAUTH-87 : Checks whether client has groups. If yes then user must be in one of these groups otherwise forbid authorization. if (checkUserGroups(user, client)) { AuthorizationCode authorizationCode = null; if (responseTypes.contains(ResponseType.CODE)) { authorizationGrant = authorizationGrantList.createAuthorizationCodeGrant( user, client, sessionUser.getAuthenticationTime()); authorizationGrant.setNonce(nonce); authorizationGrant.setJwtAuthorizationRequest(jwtAuthorizationRequest); authorizationGrant.setScopes(scopes); // Store acr_values authorizationGrant.setAcrValues(acrValuesStr); authorizationGrant.save(); // call save after object modification!!! authorizationCode = authorizationGrant.getAuthorizationCode(); redirectUriResponse.addResponseParameter("code", authorizationCode.getCode()); } AccessToken newAccessToken = null; if (responseTypes.contains(ResponseType.TOKEN)) { if (authorizationGrant == null) { authorizationGrant = authorizationGrantList.createImplicitGrant(user, client, sessionUser.getAuthenticationTime()); authorizationGrant.setNonce(nonce); authorizationGrant.setJwtAuthorizationRequest(jwtAuthorizationRequest); authorizationGrant.setScopes(scopes); // Store acr_values authorizationGrant.setAcrValues(acrValuesStr); authorizationGrant.save(); // call save after object modification!!! } newAccessToken = authorizationGrant.createAccessToken(); redirectUriResponse.addResponseParameter("access_token", newAccessToken.getCode()); redirectUriResponse.addResponseParameter("token_type", newAccessToken.getTokenType().toString()); redirectUriResponse.addResponseParameter("expires_in", newAccessToken.getExpiresIn() + ""); } if (responseTypes.contains(ResponseType.ID_TOKEN)) { if (authorizationGrant == null) { authorizationGrant = authorizationGrantList.createAuthorizationGrant( user, client, sessionUser.getAuthenticationTime()); authorizationGrant.setNonce(nonce); authorizationGrant.setJwtAuthorizationRequest(jwtAuthorizationRequest); authorizationGrant.setScopes(scopes); // Store authentication acr values authorizationGrant.setAcrValues(acrValuesStr); authorizationGrant.save(); // call save after object modification, call is asynchronous!!! } //Map<String, String> idTokenClaims = getClaims(user, authorizationGrant, scopes); IdToken idToken = authorizationGrant.createIdToken(nonce, authorizationCode, newAccessToken, authorizationGrant.getAcrValues()); redirectUriResponse.addResponseParameter("id_token", idToken.getCode()); } if (authorizationGrant != null && StringHelper.isNotEmpty(acrValuesStr)) { redirectUriResponse.addResponseParameter("acr_values", acrValuesStr); } //if (Boolean.valueOf(requestSessionId) && StringUtils.isBlank(sessionId) && if (sessionUser.getId() == null) { final SessionId newSessionUser = sessionIdService .generateAuthenticatedSessionId(sessionUser.getUserDn(), prompt); String newSessionId = newSessionUser.getId(); sessionUser.setId(newSessionId); log.trace("newSessionId = {0}", newSessionId); } redirectUriResponse.addResponseParameter(Parameters.SESSION_ID.getParamName(), sessionUser.getId()); redirectUriResponse.addResponseParameter("state", state); if (scope != null && !scope.isEmpty()) { scope = authorizationGrant.checkScopesPolicy(scope); redirectUriResponse.addResponseParameter("scope", scope); } clientService.updatAccessTime(client, false); builder = RedirectUtil.getRedirectResponseBuilder(redirectUriResponse, httpRequest); } else { redirectUriResponse.parseQueryString(errorResponseFactory.getErrorAsQueryString( AuthorizeErrorResponseType.UNAUTHORIZED_CLIENT, state)); builder = RedirectUtil.getRedirectResponseBuilder(redirectUriResponse, httpRequest); } } } else { // Invalid redirectUri builder = error(Response.Status.BAD_REQUEST, AuthorizeErrorResponseType.INVALID_REQUEST_REDIRECT_URI, state); // 400 } } else { // Invalid responseTypes builder = Response.status(Response.Status.BAD_REQUEST.getStatusCode()); // 400 builder.entity(errorResponseFactory .getErrorAsJson(AuthorizeErrorResponseType.UNSUPPORTED_RESPONSE_TYPE, state)); } } else { builder = error(Response.Status.UNAUTHORIZED, AuthorizeErrorResponseType.UNAUTHORIZED_CLIENT, state); } } } catch (AcrChangedException e) { builder = Response.status(Response.Status.UNAUTHORIZED) .entity("Session already exist with ACR that is different " + "than the one send with this authorization request. Please perform logout in order to login with another ACR. ACR: " + acrValuesStr); log.error(e.getMessage(), e); } catch (EntryPersistenceException e) { // Invalid clientId builder = error(Response.Status.UNAUTHORIZED, AuthorizeErrorResponseType.UNAUTHORIZED_CLIENT, state); log.error(e.getMessage(), e); } catch (SignatureException e) { builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); // 500 log.error(e.getMessage(), e); } catch (StringEncrypter.EncryptionException e) { builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); // 500 log.error(e.getMessage(), e); } catch (InvalidJwtException e) { builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); // 500 log.error(e.getMessage(), e); } catch (Exception e) { builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); // 500 log.error(e.getMessage(), e); } return builder.build(); }
From source file:com.clustercontrol.http.factory.RunMonitorHttpScenario.java
/** * HTTP ?//ww w .j av a2 s. c o m * * @param facilityId ID * @return ???????true */ public List<MonitorRunResultInfo> collectList(String facilityId) { // ??????? if (!m_isMonitorJob && (!m_httpScenarioCheckInfo.getMonitorInfo().getMonitorFlg() && !m_httpScenarioCheckInfo.getMonitorInfo().getCollectorFlg())) { if (m_log.isDebugEnabled()) { m_log.debug("http scenario monitor " + m_httpScenarioCheckInfo.getMonitorId() + " is not enabled, skip filtering."); } return Collections.emptyList(); } if (m_now != null) { m_nodeDate = m_now.getTime(); } m_value = 0; GetHttpResponse.GetHttpResponseBuilder builder = null; try { builder = GetHttpResponse.custom() .setAuthType(m_httpScenarioCheckInfo.getAuthType() == null ? GetHttpResponse.AuthType.NONE : AuthType.valueOf(m_httpScenarioCheckInfo.getAuthType())) .setAuthUser(m_httpScenarioCheckInfo.getAuthUser()) .setAuthPassword(m_httpScenarioCheckInfo.getAuthPassword()) .setUserAgent(m_httpScenarioCheckInfo.getUserAgent()) .setConnectTimeout(m_httpScenarioCheckInfo.getConnectTimeout() == null ? 0 : m_httpScenarioCheckInfo.getConnectTimeout()) .setRequestTimeout(m_httpScenarioCheckInfo.getRequestTimeout() == null ? 0 : m_httpScenarioCheckInfo.getRequestTimeout()) .setCancelProxyCache(HinemosPropertyUtil .getHinemosPropertyBool("monitor.http.scenario.disable.proxy.cache", true)) .setKeepAlive(true).setNeedAuthSSLCert( !HinemosPropertyUtil.getHinemosPropertyBool("monitor.http.ssl.trustall", true)); if (m_httpScenarioCheckInfo.getProxyFlg()) { builder.setProxyURL(m_httpScenarioCheckInfo.getProxyUrl()) .setProxyPort(m_httpScenarioCheckInfo.getProxyPort() == null ? 0 : m_httpScenarioCheckInfo.getProxyPort()) .setProxyUser(m_httpScenarioCheckInfo.getProxyUser()) .setProxyPassword(m_httpScenarioCheckInfo.getProxyPassword()); } } catch (URISyntaxException e) { m_log.warn("fail to initialize GetHttpResponse : " + e.getMessage(), e); MonitorRunResultInfo info = new MonitorRunResultInfo(); info.setFacilityId(facilityId); info.setMonitorFlg(m_httpScenarioCheckInfo.getMonitorInfo().getMonitorFlg()); info.setCollectorFlg(false); info.setCollectorResult(false); info.setCheckResult(-1); info.setPriority(PriorityConstant.TYPE_UNKNOWN); info.setMessage(MessageConstant.MESSAGE_FAIL_TO_ANALYZE_PROXY_URL.getMessage()); StringBuffer messageOrg = new StringBuffer(); messageOrg.append(e.getMessage()); messageOrg.append("\n"); messageOrg.append(MessageConstant.MONITOR_HTTP_SCENARIO_PROXYURL.getMessage()); messageOrg.append(" : "); messageOrg.append(m_httpScenarioCheckInfo.getProxyUrl()); info.setMessageOrg(messageOrg.toString()); info.setNodeDate(m_nodeDate); info.setProcessType(true); info.setNotifyGroupId(m_httpScenarioCheckInfo.getMonitorInfo().getNotifyGroupId()); return Arrays.asList(info); } int responseTime = 0; ResultType endResultType = ResultType.SUCCESS; MonitorRunResultInfo errorResultInfo = null; List<PageResponse> responses = new ArrayList<PageResponse>(); try (GetHttpResponse m_request = builder.build()) { Map<String, String> variables = RepositoryUtil.createNodeParameter(nodeInfo.get(facilityId)); List<Page> pages = new ArrayList<>(m_httpScenarioCheckInfo.getPages()); Collections.sort(pages, new Comparator<Page>() { @Override public int compare(Page o1, Page o2) { return o1.getId().getPageOrderNo().compareTo(o2.getId().getPageOrderNo()); } }); loopEnd: for (Page page : pages) { ResultType resultType = ResultType.SUCCESS; MonitorRunResultInfo resultInfo = null; StringBinder strbinder = new StringBinder(variables); String url = page.getUrl(); url = strbinder.bindParam(url); String post = page.getPost(); if (post != null && !post.isEmpty()) post = strbinder.bindParam(post); if (m_log.isTraceEnabled()) m_log.trace("http request. (nodeInfo = " + nodeInfo + ", facilityId = " + facilityId + ", url = " + url + ")"); PageResponse response = null; List<String> rurls = new ArrayList<>(); String nextUrl = url; String nextPost = post; while (true) { m_request.execute(nextUrl, nextPost); response = new PageResponse(page, m_request.getResult()); if (response.response.exception == null) { // ?????? if (response.response.statusCode == 301 || response.response.statusCode == 302 || response.response.statusCode == 303 || response.response.statusCode == 307) { for (Header h : response.response.headers) { if (h.getName().equals("Location")) { nextUrl = h.getValue(); nextPost = null; break; } } if (nextUrl != null) { rurls.add(nextUrl); } else { // ????? resultType = ResultType.NOT_FOUND_URL_FOR_REDIRECT; break; } } else { break; } } else { break; } } if (ResultType.NOT_FOUND_URL_FOR_REDIRECT.equals(resultType)) { resultInfo = createNotFoundUrlForRedirectMonitorRunResultInfo(page, response.response, url, rurls); resultInfo.setFacilityId(facilityId); } if (ResultType.SUCCESS.equals(resultType) && response.response.exception != null) { if (SocketTimeoutException.class.equals(response.response.exception.getClass())) { resultType = ResultType.TIMEOUT; resultInfo = createTimeoutMonitorRunResultInfo(page, response.response, url, rurls); resultInfo.setFacilityId(facilityId); } else { resultType = ResultType.UNEXPECTED; resultInfo = createUnexpectedMonitorRunResultInfo(page, response.response, url, rurls); resultInfo.setFacilityId(facilityId); } } if (ResultType.SUCCESS.equals(resultType) && !(page.getStatusCode() == null || Pattern.matches("(\\s*|.*,\\s*)" + response.response.statusCode + "(\\s*,.*|\\s*)", page.getStatusCode()))) { resultType = ResultType.NOT_MATCH_EXPECTED_STATUS_CODES; resultInfo = createUnmatchedStatusCodeMonitorRunResultInfo(page, m_request.getResult(), url); resultInfo.setFacilityId(facilityId); } if (ResultType.SUCCESS.equals(resultType) && !page.getPatterns().isEmpty()) { List<com.clustercontrol.http.model.Pattern> patterns = new ArrayList<>(page.getPatterns()); Collections.sort(patterns, new Comparator<com.clustercontrol.http.model.Pattern>() { @Override public int compare(com.clustercontrol.http.model.Pattern o1, com.clustercontrol.http.model.Pattern o2) { return o1.getId().getPatternOrderNo().compareTo(o2.getId().getPatternOrderNo()); } }); com.clustercontrol.http.model.Pattern matchedPattern = null; Boolean exceptionProcessType = null; for (int i = 0; i < patterns.size(); ++i) { com.clustercontrol.http.model.Pattern pe = patterns.get(i); if (!pe.getValidFlg() || pe.getPattern() == null) continue; try { // ????? Pattern pattern = null; if (pe.getCaseSensitivityFlg()) { pattern = Pattern.compile(pe.getPattern(), Pattern.DOTALL | Pattern.CASE_INSENSITIVE); } // ??? else { pattern = Pattern.compile(pe.getPattern(), Pattern.DOTALL); } // ???? String body = response.response.responseBody; if (body == null) { body = ""; } ; // 404?????body?null??????? Matcher matcher = pattern.matcher(body); if (matcher.matches()) { matchedPattern = pe; break; } } catch (PatternSyntaxException e) { m_log.info("collectList(): PatternSyntax is not valid." + " description=" + pe.getDescription() + ", patternSyntax=" + pe.getPattern() + ", value=" + response.response.responseBody + " : " + e.getClass().getSimpleName() + ", " + e.getMessage()); exceptionProcessType = pe.getProcessType(); } catch (Exception e) { m_log.warn("collectList(): PatternSyntax is not valid." + " description=" + pe.getDescription() + ", patternSyntax=" + pe.getPattern() + ", value=" + response.response.responseBody + " : " + e.getClass().getSimpleName() + ", " + e.getMessage(), e); exceptionProcessType = pe.getProcessType(); } } if (matchedPattern != null) { resultType = ResultType.MATCH_PATTERN; resultInfo = createMatchedPatternMonitorRunResultInfo(page, matchedPattern, response.response, url); resultInfo.setFacilityId(facilityId); } else { resultType = ResultType.NOT_MATCH_PATTERNS; resultInfo = createNotmatchedPatternsMonitorRunResultInfo(page, response.response, url, exceptionProcessType); resultInfo.setFacilityId(facilityId); } } // ??? switch (resultType) { case NOT_MATCH_EXPECTED_STATUS_CODES: case NOT_MATCH_PATTERNS: case TIMEOUT: case UNEXPECTED: case NOT_FOUND_URL_FOR_REDIRECT: errorResultInfo = resultInfo; endResultType = resultType; break loopEnd; case MATCH_PATTERN: if (resultInfo.getProcessType().booleanValue()) { endResultType = resultType; errorResultInfo = resultInfo; break loopEnd; } break; default: // SUCCESS break; } // ?? for (Variable variable : page.getVariables()) { String value = null; if (variable.getMatchingWithResponseFlg()) { if (response.response.responseBody != null) { Matcher m = Pattern.compile(variable.getValue(), Pattern.DOTALL) .matcher(response.response.responseBody); if (m.matches()) { try { value = m.group(1); } catch (IndexOutOfBoundsException e) { m_log.warn(String.format( "not contain group paragraph in pattern for variable. facilityId=%s, monitorId=%s, pageNo=%d, variableName=%s, value=%s", facilityId, m_httpScenarioCheckInfo.getMonitorId(), page.getId().getPageOrderNo(), variable.getId().getName(), variable.getValue())); } } else { // ???? m_log.debug(String.format( "variable not match. facilityId=%s, monitorId=%s, pageNo=%d, variableName=%s, value=%s", facilityId, m_httpScenarioCheckInfo.getMonitorId(), page.getId().getPageOrderNo(), variable.getId().getName(), variable.getValue())); } } else { // ???? m_log.warn(String.format( "Not foudnd previous post. facilityId=%s, monitorId=%s, pageNo=%d, variableName=%s, value=%s", facilityId, m_httpScenarioCheckInfo.getMonitorId(), page.getId().getPageOrderNo(), variable.getId().getName(), variable.getValue())); } } else { value = variable.getValue(); } if (value != null) { variables.put(variable.getId().getName(), value); } } responses.add(response); responseTime += m_request.getResult().responseTime; } } catch (IOException e) { m_log.warn("fail to close HttpClient : " + e.getMessage(), e); } List<MonitorRunResultInfo> resultInfos = new ArrayList<>(); if (ResultType.SUCCESS.equals(endResultType)) { MonitorRunResultInfo info = new MonitorRunResultInfo(); info.setFacilityId(facilityId); info.setMonitorFlg(m_httpScenarioCheckInfo.getMonitorInfo().getMonitorFlg()); info.setCollectorFlg(m_httpScenarioCheckInfo.getMonitorInfo().getCollectorFlg()); info.setCollectorResult(true); info.setCheckResult(0); info.setItemCode("0"); info.setItemName(m_httpScenarioCheckInfo.getMonitorInfo().getItemName()); info.setDisplayName(""); info.setPriority(PriorityConstant.TYPE_INFO); info.setMessage(String.format("%s : %s", MessageConstant.MONITOR_HTTP_SCENARIO_TOTAL_RESPONSETIME_MS.getMessage(), NumberFormat.getNumberInstance().format(responseTime))); int pageOrderNo = 1; StringBuffer messageOrg = new StringBuffer(); messageOrg.append(MessageConstant.MONITOR_HTTP_SCENARIO_TOTAL_RESPONSETIME.getMessage()); messageOrg.append(" : "); messageOrg.append(responseTime); messageOrg.append("\n"); for (PageResponse pr : responses) { messageOrg.append(MessageConstant.MONITOR_HTTP_SCENARIO_PAGE_ORDERNO.getMessage()); messageOrg.append(" : "); messageOrg.append(pageOrderNo++); messageOrg.append("\n"); messageOrg.append(MessageConstant.MONITOR_HTTP_SCENARIO_PAGE_URL.getMessage()); messageOrg.append(" : "); messageOrg.append(pr.response.url); messageOrg.append("\n"); messageOrg.append(MessageConstant.MONITOR_HTTP_SCENARIO_PAGE_STATUSCODE.getMessage()); messageOrg.append(" : "); messageOrg.append(pr.response.statusCode); messageOrg.append("\n"); messageOrg.append(MessageConstant.RESPONSE_TIME_MILLI_SEC.getMessage()); messageOrg.append(" : "); messageOrg.append(pr.response.responseTime); messageOrg.append("\n"); } info.setMessageOrg(messageOrg.toString()); info.setNodeDate(m_nodeDate); info.setValue((double) responseTime); info.setProcessType(true); info.setNotifyGroupId(m_httpScenarioCheckInfo.getMonitorInfo().getNotifyGroupId()); resultInfos.add(info); // ??? if (!m_isMonitorJob && m_httpScenarioCheckInfo.getMonitoringPerPageFlg() && m_httpScenarioCheckInfo.getMonitorInfo().getCollectorFlg()) { Map<String, Integer> map = new HashMap<String, Integer>(); for (PageResponse pr : responses) { Integer count = map.get(pr.page.getUrl()); if (count == null) { count = 1; map.put(pr.page.getUrl(), count); } else { map.put(pr.page.getUrl(), ++count); } MonitorRunResultInfo pagetResultInfo = new MonitorRunResultInfo(); pagetResultInfo.setFacilityId(facilityId); pagetResultInfo.setMonitorFlg(false); pagetResultInfo.setCollectorFlg(true); pagetResultInfo.setCollectorResult(true); pagetResultInfo.setItemCode(Integer.toString(pr.page.getId().getPageOrderNo() + 1)); pagetResultInfo.setDisplayName(pr.page.getUrl() + " (" + count + ")"); pagetResultInfo.setPriority(pr.page.getPriority()); pagetResultInfo.setNodeDate(m_nodeDate); pagetResultInfo.setValue((double) pr.response.responseTime); pagetResultInfo.setNotifyGroupId(m_httpScenarioCheckInfo.getMonitorInfo().getNotifyGroupId()); resultInfos.add(pagetResultInfo); } } } else { resultInfos.add(errorResultInfo); } return resultInfos; }