Refine search
private URL getYahooGeocoderUrl(String address) throws IOException { UriBuilder uriBuilder = UriBuilder.fromUri("http://where.yahooapis.com/geocode"); uriBuilder.queryParam("location", address); uriBuilder.queryParam("flags", "J"); uriBuilder.queryParam("appid", appId); if (locale != null) { uriBuilder.queryParam("locale", locale); uriBuilder.queryParam("gflags", "L"); } URI uri = uriBuilder.build(); return new URL(uri.toString()); }
private String rewriteUri(UriInfo uriInfo, String uri) { return uriInfo.getAbsolutePathBuilder() .replacePath("/v1/proxy") .queryParam("uri", uri) .queryParam("hmac", hmac.hashString(uri, UTF_8)) .build() .toString(); }
private URL getGoogleGeocoderUrl(String address) throws IOException { UriBuilder uriBuilder = UriBuilder.fromUri("http://maps.google.com/maps/api/geocode/json"); uriBuilder.queryParam("sensor", false); uriBuilder.queryParam("address", address); URI uri = uriBuilder.build(); return new URL(uri.toString()); }
@Override public String start() { final UriBuilder uriBuilder = UriBuilder.fromUri(authorizationUri); for (final Map.Entry<String, String> entry : authorizationProperties.entrySet()) { uriBuilder.queryParam(entry.getKey(), entry.getValue()); } return uriBuilder.build().toString(); }
private URL getGeocoderURL(String geocoderBaseUrl, String address) throws MalformedURLException { UriBuilder builder = UriBuilder.fromUri(geocoderBaseUrl); builder.queryParam("address", address); URI uri = builder.build(); return new URL(uri.toString()); }
private URL getBanoGeocoderUrl(String address, Envelope bbox) throws IOException { UriBuilder uriBuilder = UriBuilder.fromUri(BANO_URL); uriBuilder.queryParam("q", address); uriBuilder.queryParam("limit", CLAMP_RESULTS); if (bbox != null) { uriBuilder.queryParam("lat", bbox.centre().y); uriBuilder.queryParam("lon", bbox.centre().x); } URI uri = uriBuilder.build(); return new URL(uri.toString()); } }
private URL getNominatimGeocoderUrl(String address, Envelope bbox) throws IOException { UriBuilder uriBuilder = UriBuilder.fromUri(nominatimUrl); uriBuilder.queryParam("q", address); uriBuilder.queryParam("format", "json"); if (bbox != null) { uriBuilder.queryParam("viewbox", bbox.getMinX() + "," + bbox.getMinY() + "," + bbox.getMaxX() + "," + bbox.getMaxY()); uriBuilder.queryParam("bounded", 1); } else if (viewBox != null) { uriBuilder.queryParam("viewbox", viewBox); uriBuilder.queryParam("bounded", 1); } if (resultLimit != null) { uriBuilder.queryParam("limit", resultLimit); } if (emailAddress != null) { uriBuilder.queryParam("email", emailAddress); } URI uri = uriBuilder.build(); return new URL(uri.toString()); }
@GET public ItemsRepresentation query( @Context javax.ws.rs.core.UriInfo info, @QueryParam("offset") @DefaultValue("-1") int offset, @DefaultValue("-1") @QueryParam("limit") int limit) { if (offset == -1 || limit == -1) { offset = offset == -1 ? 0 : offset; limit = limit == -1 ? 10 : limit; throw new WebApplicationException( Response.seeOther(info.getRequestUriBuilder().queryParam("offset", offset) .queryParam("limit", limit).build()) .build() ); } return new ItemsRepresentation(itemsModel, offset, limit); }
public String start() { final Response response = addProperties(client.target(requestTokenUri).request()) .post(null); if (response.getStatus() != 200) { throw new RuntimeException(LocalizationMessages.ERROR_REQUEST_REQUEST_TOKEN(response.getStatus())); } final MultivaluedMap<String, String> formParams = response.readEntity(Form.class).asMap(); parameters.token(formParams.getFirst(OAuth1Parameters.TOKEN)); secrets.tokenSecret(formParams.getFirst(OAuth1Parameters.TOKEN_SECRET)); return UriBuilder.fromUri(authorizationUri).queryParam(OAuth1Parameters.TOKEN, parameters.getToken()) .build().toString(); }
private void addHint(Application wadlApplication) { // TODO: this not-null check is here only because of unit tests if (uriInfo != null) { Doc d = new Doc(); String message; if (detailedWadl) { final String uriWithoutQueryParam = UriBuilder.fromUri(uriInfo.getRequestUri()).replaceQuery("").build() .toString(); message = LocalizationMessages.WADL_DOC_EXTENDED_WADL(WadlUtils.DETAILED_WADL_QUERY_PARAM, uriWithoutQueryParam); } else { final String uriWithQueryParam = UriBuilder.fromUri(uriInfo.getRequestUri()) .queryParam(WadlUtils.DETAILED_WADL_QUERY_PARAM, "true").build().toString(); message = LocalizationMessages.WADL_DOC_SIMPLE_WADL(WadlUtils.DETAILED_WADL_QUERY_PARAM, uriWithQueryParam); } d.getOtherAttributes().put(new QName(WadlApplicationContextImpl.WADL_JERSEY_NAMESPACE, "hint", "jersey"), message); wadlApplication.getDoc().add(d); } }
private void addHint(Application wadlApplication) { // TODO: this not-null check is here only because of unit tests if (uriInfo != null) { Doc d = new Doc(); String message; if (detailedWadl) { final String uriWithoutQueryParam = UriBuilder.fromUri(uriInfo.getRequestUri()).replaceQuery("").build() .toString(); message = LocalizationMessages.WADL_DOC_EXTENDED_WADL(WadlUtils.DETAILED_WADL_QUERY_PARAM, uriWithoutQueryParam); } else { final String uriWithQueryParam = UriBuilder.fromUri(uriInfo.getRequestUri()) .queryParam(WadlUtils.DETAILED_WADL_QUERY_PARAM, "true").build().toString(); message = LocalizationMessages.WADL_DOC_SIMPLE_WADL(WadlUtils.DETAILED_WADL_QUERY_PARAM, uriWithQueryParam); } d.getOtherAttributes().put(new QName(WadlApplicationContextImpl.WADL_JERSEY_NAMESPACE, "hint", "jersey"), message); wadlApplication.getDoc().add(d); } }
@GET @Consumes(MediaType.WILDCARD) @Produces(MediaType.WILDCARD) @Path("oidc/logout") @ApiOperation( value = "Performs a logout in the OpenId Provider.", notes = NON_GUARANTEED_ENDPOINT ) public void oidcLogout(@Context HttpServletRequest httpServletRequest, @Context HttpServletResponse httpServletResponse) throws Exception { if (!httpServletRequest.isSecure()) { throw new IllegalStateException("User authentication/authorization is only supported when running over HTTPS."); } if (!oidcService.isOidcEnabled()) { throw new IllegalStateException("OpenId Connect is not configured."); } URI endSessionEndpoint = oidcService.getEndSessionEndpoint(); String postLogoutRedirectUri = generateResourceUri("..", "nifi"); if (endSessionEndpoint == null) { // handle the case, where the OpenID Provider does not have an end session endpoint httpServletResponse.sendRedirect(postLogoutRedirectUri); } else { URI logoutUri = UriBuilder.fromUri(endSessionEndpoint) .queryParam("post_logout_redirect_uri", postLogoutRedirectUri) .build(); httpServletResponse.sendRedirect(logoutUri.toString()); } }
/** * Returns the "otpauth" URI for the secret key used to generate TOTP codes * for the current user. If the secret key is not being exposed to * facilitate enrollment, null is returned. * * @return * The "otpauth" URI for the secret key used to generate TOTP codes * for the current user, or null is the secret ket is not being exposed * to facilitate enrollment. * * @throws GuacamoleException * If the configuration information required for generating the key URI * cannot be read from guacamole.properties. */ @JsonProperty("keyUri") public URI getKeyURI() throws GuacamoleException { // Do not generate a key URI if no key is being exposed if (key == null) return null; // Format "otpauth" URL (see https://github.com/google/google-authenticator/wiki/Key-Uri-Format) String issuer = confService.getIssuer(); return UriBuilder.fromUri("otpauth://totp/") .path(issuer + ":" + key.getUsername()) .queryParam("secret", BASE32.encode(key.getSecret())) .queryParam("issuer", issuer) .queryParam("algorithm", confService.getMode()) .queryParam("digits", confService.getDigits()) .queryParam("period", confService.getPeriod()) .build(); }
@GET @Consumes(MediaType.WILDCARD) @Produces(MediaType.WILDCARD) @Path("knox/request") @ApiOperation( value = "Initiates a request to authenticate through Apache Knox.", notes = NON_GUARANTEED_ENDPOINT ) public void knoxRequest(@Context HttpServletRequest httpServletRequest, @Context HttpServletResponse httpServletResponse) throws Exception { // only consider user specific access over https if (!httpServletRequest.isSecure()) { forwardToMessagePage(httpServletRequest, httpServletResponse, "User authentication/authorization is only supported when running over HTTPS."); return; } // ensure knox is enabled if (!knoxService.isKnoxEnabled()) { forwardToMessagePage(httpServletRequest, httpServletResponse, "Apache Knox SSO support is not configured."); return; } // build the originalUri, and direct back to the ui final String originalUri = generateResourceUri("access", "knox", "callback"); // build the authorization uri final URI authorizationUri = UriBuilder.fromUri(knoxService.getKnoxUrl()) .queryParam("originalUrl", originalUri.toString()) .build(); // generate the response httpServletResponse.sendRedirect(authorizationUri.toString()); }
.queryParam("client_id", oidcService.getClientId()) .queryParam("response_type", "code") .queryParam("scope", oidcService.getScope().toString()) .queryParam("state", state.getValue()) .queryParam("redirect_uri", getOidcCallback()) .build();
@Override public void filter(ContainerRequestContext requestContext) throws IOException { final SecurityContext sc = requestContext.getSecurityContext(); if (!isUserLoggedIn(sc)) { try { final String destResource = URLEncoder.encode( requestContext.getUriInfo().getRequestUri().toString(), "UTF-8"); final URI loginURI = requestContext.getUriInfo().getBaseUriBuilder() .path(LogInLogOutPages.LOGIN_RESOURCE) .queryParam(LogInLogOutPages.REDIRECT_QUERY_PARM, destResource) .build(); requestContext .abortWith(Response.temporaryRedirect(loginURI).build()); } catch (final Exception ex) { final String errMsg = String.format( "Failed to forward the request to login page: %s", ex.getMessage()); LOG.error(errMsg, ex); requestContext .abortWith(Response.serverError().entity(errMsg).build()); } } } }
Form f = request.getFormParameters(); for (Map.Entry<String, List<String>> param : f.entrySet()) { ub.queryParam(param.getKey(), param.getValue().toArray()); request.setUris(request.getBaseUri(), ub.build());
final Form f = ((ContainerRequest) request).readEntity(Form.class); for (final Map.Entry<String, List<String>> param : f.asMap().entrySet()) { ub.queryParam(param.getKey(), param.getValue().toArray()); request.setRequestUri(request.getUriInfo().getBaseUri(), ub.build());
final Form f = ((ContainerRequest) request).readEntity(Form.class); for (final Map.Entry<String, List<String>> param : f.asMap().entrySet()) { ub.queryParam(param.getKey(), param.getValue().toArray()); request.setRequestUri(request.getUriInfo().getBaseUri(), ub.build());
private URI getRequestUri(String absoluteUriWithoutExtension, Map<String, List<String>> queryParams) { final UriBuilder requestUriBuilder = UriBuilder.fromUri(absoluteUriWithoutExtension); for (Map.Entry<String, List<String>> queryParamEntry : queryParams.entrySet()) { for (String value : queryParamEntry.getValue()) { requestUriBuilder.queryParam(queryParamEntry.getKey(), value); } } return requestUriBuilder.build(); }