javax.ws.rs.core.UriInfo Java Examples
The following examples show how to use
javax.ws.rs.core.UriInfo.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractOAuth2IdentityProvider.java From keycloak with Apache License 2.0 | 6 votes |
protected Response exchangeSessionToken(UriInfo uriInfo, EventBuilder event, ClientModel authorizedClient, UserSessionModel tokenUserSession, UserModel tokenSubject) { String accessToken = tokenUserSession.getNote(FEDERATED_ACCESS_TOKEN); if (accessToken == null) { event.detail(Details.REASON, "requested_issuer is not linked"); event.error(Errors.INVALID_TOKEN); return exchangeTokenExpired(uriInfo, authorizedClient, tokenUserSession, tokenSubject); } AccessTokenResponse tokenResponse = new AccessTokenResponse(); tokenResponse.setToken(accessToken); tokenResponse.setIdToken(null); tokenResponse.setRefreshToken(null); tokenResponse.setRefreshExpiresIn(0); tokenResponse.getOtherClaims().clear(); tokenResponse.getOtherClaims().put(OAuth2Constants.ISSUED_TOKEN_TYPE, OAuth2Constants.ACCESS_TOKEN_TYPE); tokenResponse.getOtherClaims().put(ACCOUNT_LINK_URL, getLinkingUrl(uriInfo, authorizedClient, tokenUserSession)); event.success(); return Response.ok(tokenResponse).type(MediaType.APPLICATION_JSON_TYPE).build(); }
Example #2
Source File: UserOperationLogRestServiceImpl.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Override public List<UserOperationLogEntryDto> queryUserOperationEntries(UriInfo uriInfo, Integer firstResult, Integer maxResults) { UserOperationLogQueryDto queryDto = new UserOperationLogQueryDto(objectMapper, uriInfo.getQueryParameters()); UserOperationLogQuery query = queryDto.toQuery(processEngine); if (firstResult == null && maxResults == null) { return UserOperationLogEntryDto.map(query.list()); } else { if (firstResult == null) { firstResult = 0; } if (maxResults == null) { maxResults = Integer.MAX_VALUE; } return UserOperationLogEntryDto.map(query.listPage(firstResult, maxResults)); } }
Example #3
Source File: TrellisHttpResource.java From trellis with Apache License 2.0 | 6 votes |
/** * Perform a POST operation on a LDP Resource. * * @param uriInfo the URI info * @param secContext the security context * @param headers the HTTP headers * @param request the request * @param body the body * @return the async response */ @POST @Timed @Operation(summary = "Create a linked data resource") public CompletionStage<Response> createResource(@Context final Request request, @Context final UriInfo uriInfo, @Context final HttpHeaders headers, @Context final SecurityContext secContext, @RequestBody(description = "The new resource") final InputStream body) { final TrellisRequest req = new TrellisRequest(request, uriInfo, headers, secContext); final String urlBase = getBaseUrl(req); final String path = req.getPath(); final String identifier = getIdentifier(req); final String separator = path.isEmpty() ? "" : "/"; final IRI parent = buildTrellisIdentifier(path); final IRI child = buildTrellisIdentifier(path + separator + identifier); final PostHandler postHandler = new PostHandler(req, parent, identifier, body, trellis, extensions, urlBase); return trellis.getResourceService().get(parent) .thenCombine(trellis.getResourceService().get(child), postHandler::initialize) .thenCompose(postHandler::createResource).thenCompose(postHandler::updateMemento) .thenApply(ResponseBuilder::build).exceptionally(this::handleException); }
Example #4
Source File: AbstractODataResource.java From io with Apache License 2.0 | 6 votes |
/** * レスポンスボディを作成する. * @param uriInfo UriInfo * @param resp レスポンス * @param format レスポンスボディのフォーマット * @param acceptableMediaTypes 許可するMediaTypeのリスト * @return レスポンスボディ */ protected String renderEntityResponse( final UriInfo uriInfo, final EntityResponse resp, final String format, final List<MediaType> acceptableMediaTypes) { StringWriter w = new StringWriter(); try { FormatWriter<EntityResponse> fw = DcFormatWriterFactory.getFormatWriter(EntityResponse.class, acceptableMediaTypes, format, null); // UriInfo uriInfo2 = DcCoreUtils.createUriInfo(uriInfo, 1); fw.write(uriInfo, w, resp); } catch (UnsupportedOperationException e) { throw DcCoreException.OData.FORMAT_INVALID_ERROR.params(format); } String responseStr = w.toString(); return responseStr; }
Example #5
Source File: SchemaRegistryResource.java From registry with Apache License 2.0 | 6 votes |
@GET @Path("/search/schemas") @ApiOperation(value = "Search for schemas containing the given name and description", notes = "Search the schemas for given name and description, return a list of schemas that contain the field.", response = SchemaMetadataInfo.class, responseContainer = "List", tags = OPERATION_GROUP_SCHEMA) @Timed @UnitOfWork public Response findSchemas(@Context UriInfo uriInfo, @Context SecurityContext securityContext) { MultivaluedMap<String, String> queryParameters = uriInfo.getQueryParameters(); try { Collection<SchemaMetadataInfo> schemaMetadataInfos = authorizationAgent .authorizeFindSchemas(AuthorizationUtils.getUserAndGroups(securityContext), findSchemaMetadataInfos(queryParameters)); return WSUtils.respondEntities(schemaMetadataInfos, Response.Status.OK); } catch (Exception ex) { LOG.error("Encountered error while finding schemas for given fields [{}]", queryParameters, ex); return WSUtils.respond(Response.Status.INTERNAL_SERVER_ERROR, CatalogResponse.ResponseMessage.EXCEPTION, ex.getMessage()); } }
Example #6
Source File: DigitalObjectResource.java From proarc with GNU General Public License v3.0 | 6 votes |
public DigitalObjectResource( @Context Request request, @Context SecurityContext securityCtx, @Context HttpHeaders httpHeaders, @Context UriInfo uriInfo, @Context HttpServletRequest httpRequest ) throws AppConfigurationException { this.httpRequest = request; this.httpHeaders = httpHeaders; this.appConfig = AppConfigurationFactory.getInstance().defaultInstance(); this.importManager = ImportBatchManager.getInstance(appConfig); session = SessionContext.from(httpRequest); user = session.getUser(); LOG.fine(user.toString()); }
Example #7
Source File: ODataLinksResource.java From io with Apache License 2.0 | 6 votes |
QueryInfo queryInfo(UriInfo uriInfo) { MultivaluedMap<String, String> mm = uriInfo.getQueryParameters(true); Integer top = QueryParser.parseTopQuery(mm.getFirst("$top")); Integer skip = QueryParser.parseSkipQuery(mm.getFirst("$skip")); return new QueryInfo( null, top, skip, null, null, null, null, null, null); }
Example #8
Source File: ProfiloController.java From govpay with GNU General Public License v3.0 | 6 votes |
public Response profiloGET(Authentication user, UriInfo uriInfo, HttpHeaders httpHeaders) { String methodName = "profiloGET"; String transactionId = ContextThreadLocal.get().getTransactionId(); this.log.debug(MessageFormat.format(BaseController.LOG_MSG_ESECUZIONE_METODO_IN_CORSO, methodName)); try{ UtentiDAO utentiDAO = new UtentiDAO(); LeggiProfiloDTOResponse leggiProfilo = utentiDAO.getProfilo(user); Profilo profilo = ProfiloConverter.getProfilo(leggiProfilo); this.log.debug(MessageFormat.format(BaseController.LOG_MSG_ESECUZIONE_METODO_COMPLETATA, methodName)); return this.handleResponseOk(Response.status(Status.OK).entity(profilo.toJSON(null)),transactionId).build(); }catch (Exception e) { return this.handleException(uriInfo, httpHeaders, methodName, e, transactionId); } finally { this.log(ContextThreadLocal.get()); } }
Example #9
Source File: CrnkFilterTest.java From crnk-framework with Apache License 2.0 | 6 votes |
@Test public void checkWebPathPrefixWrongNoFilter() throws IOException { CrnkFeature feature = Mockito.mock(CrnkFeature.class); Mockito.when(feature.getWebPathPrefix()).thenReturn("api"); Mockito.when(feature.getBoot()).thenThrow(new WebApplicationException("test")); CrnkFilter filter = new CrnkFilter(feature); UriInfo uriInfo = Mockito.mock(UriInfo.class); Mockito.when(uriInfo.getPath()).thenReturn("/api2/tasks"); Mockito.when(uriInfo.getQueryParameters()).thenReturn(Mockito.mock(MultivaluedMap.class)); ContainerRequestContext requestContext = Mockito.mock(ContainerRequestContext.class); Mockito.when(requestContext.getUriInfo()).thenReturn(uriInfo); try { filter.filter(requestContext); } catch (WebApplicationException e) { Assert.fail(); } }
Example #10
Source File: ApplicationResource.java From usergrid with Apache License 2.0 | 6 votes |
@RequireOrganizationAccess @GET @JSONP @Produces({MediaType.APPLICATION_JSON, "application/javascript"}) public ApiResponse getApplication( @Context UriInfo ui, @QueryParam("callback") @DefaultValue("callback") String callback ) throws Exception { ApiResponse response = createApiResponse(); ServiceManager sm = smf.getServiceManager( applicationId ); response.setAction( "get" ); response.setApplication( sm.getApplication() ); response.setParams( ui.getQueryParameters() ); response.setResults( management.getApplicationMetadata( applicationId ) ); return response; }
Example #11
Source File: ConfigurazioniController.java From govpay with GNU General Public License v3.0 | 5 votes |
public Response addConfigurazioni(Authentication user, UriInfo uriInfo, HttpHeaders httpHeaders , java.io.InputStream is) { String methodName = "addConfigurazioni"; String transactionId = ContextThreadLocal.get().getTransactionId(); this.log.debug(MessageFormat.format(BaseController.LOG_MSG_ESECUZIONE_METODO_IN_CORSO, methodName)); try(ByteArrayOutputStream baos= new ByteArrayOutputStream();){ // salvo il json ricevuto IOUtils.copy(is, baos); // autorizzazione sulla API this.isAuthorized(user, Arrays.asList(TIPO_UTENZA.OPERATORE, TIPO_UTENZA.APPLICAZIONE), Arrays.asList(Servizio.CONFIGURAZIONE_E_MANUTENZIONE), Arrays.asList(Diritti.SCRITTURA)); String jsonRequest = baos.toString(); Configurazione giornaleRequest= JSONSerializable.parse(jsonRequest, Configurazione.class); giornaleRequest.validate(); PutConfigurazioneDTO putConfigurazioneDTO = ConfigurazioniConverter.getPutConfigurazioneDTO(giornaleRequest, user); ConfigurazioneDAO configurazioneDAO = new ConfigurazioneDAO(false); PutConfigurazioneDTOResponse putConfigurazioneDTOResponse = configurazioneDAO.salvaConfigurazione(putConfigurazioneDTO); Status responseStatus = putConfigurazioneDTOResponse.isCreated() ? Status.CREATED : Status.OK; this.log.debug(MessageFormat.format(BaseController.LOG_MSG_ESECUZIONE_METODO_COMPLETATA, methodName)); return this.handleResponseOk(Response.status(responseStatus),transactionId).build(); }catch (Exception e) { return this.handleException(uriInfo, httpHeaders, methodName, e, transactionId); } finally { this.log(ContextThreadLocal.get()); } }
Example #12
Source File: EntityBuilder.java From jaxrs-hypermedia with Apache License 2.0 | 5 votes |
public Entity buildOrders(List<Order> orders, UriInfo uriInfo) { final List<Entity> orderEntities = orders.stream().map(o -> buildOrderTeaser(o, uriInfo)).collect(Collectors.toList()); return createEntityBuilder().setComponentClass("orders") .addLink(linkBuilder.forOrders(uriInfo)) .addSubEntities(orderEntities).build(); }
Example #13
Source File: Tracciati.java From govpay with GNU General Public License v3.0 | 5 votes |
@GET @Path("/{id}/richiesta") @Produces({ "application/octet-stream" }) public Response getMessaggioRichiestaTracciato(@Context UriInfo uriInfo, @Context HttpHeaders httpHeaders, @PathParam("id") Long id){ this.buildContext(); return this.controller.getMessaggioRichiestaTracciato(this.getUser(), uriInfo, httpHeaders, id); }
Example #14
Source File: ConsumersResource.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Path("attributes-{attributes}/{consumer-id}") @DELETE public void closeSession(@PathParam("consumer-id") String consumerId, @Context UriInfo uriInfo) { ActiveMQRestLogger.LOGGER.debug("Handling DELETE request for \"" + uriInfo.getPath() + "\""); QueueConsumer consumer = queueConsumers.remove(consumerId); if (consumer == null) { throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND).entity("Failed to match a consumer to URL" + consumerId).type("text/plain").build()); } consumer.shutdown(); }
Example #15
Source File: Services.java From olingo-odata4 with Apache License 2.0 | 5 votes |
@GET @Path("/Boss") public Response getSingletonBoss( @Context final UriInfo uriInfo, @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept, @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) { return getEntityInternal( uriInfo.getRequestUri().toASCIIString(), accept, "Boss", StringUtils.EMPTY, format, null, null); }
Example #16
Source File: ResponseBuilderImpl.java From cxf with Apache License 2.0 | 5 votes |
public ResponseBuilder location(URI loc) { if (!loc.isAbsolute()) { Message currentMessage = PhaseInterceptorChain.getCurrentMessage(); if (currentMessage != null) { UriInfo ui = new UriInfoImpl(currentMessage.getExchange().getInMessage(), null); loc = ui.getBaseUriBuilder() .path(loc.getRawPath()) .replaceQuery(loc.getRawQuery()) .fragment(loc.getRawFragment()).buildFromEncoded(); } } return setHeader(HttpHeaders.LOCATION, loc); }
Example #17
Source File: AuthenticationManager.java From keycloak with Apache License 2.0 | 5 votes |
public static String nextRequiredAction(final KeycloakSession session, final AuthenticationSessionModel authSession, final ClientConnection clientConnection, final HttpRequest request, final UriInfo uriInfo, final EventBuilder event) { final RealmModel realm = authSession.getRealm(); final UserModel user = authSession.getAuthenticatedUser(); final ClientModel client = authSession.getClient(); evaluateRequiredActionTriggers(session, authSession, clientConnection, request, uriInfo, event, realm, user); if (!user.getRequiredActions().isEmpty()) { return user.getRequiredActions().iterator().next(); } if (!authSession.getRequiredActions().isEmpty()) { return authSession.getRequiredActions().iterator().next(); } String kcAction = authSession.getClientNote(Constants.KC_ACTION); if (kcAction != null) { return kcAction; } if (client.isConsentRequired()) { UserConsentModel grantedConsent = getEffectiveGrantedConsent(session, authSession); // See if any clientScopes need to be approved on consent screen List<ClientScopeModel> clientScopesToApprove = getClientScopesToApproveOnConsentScreen(realm, grantedConsent, authSession); if (!clientScopesToApprove.isEmpty()) { return CommonClientSessionModel.Action.OAUTH_GRANT.name(); } String consentDetail = (grantedConsent != null) ? Details.CONSENT_VALUE_PERSISTED_CONSENT : Details.CONSENT_VALUE_NO_CONSENT_REQUIRED; event.detail(Details.CONSENT, consentDetail); } else { event.detail(Details.CONSENT, Details.CONSENT_VALUE_NO_CONSENT_REQUIRED); } return null; }
Example #18
Source File: GET_ConstraintsIT.java From agrest with Apache License 2.0 | 5 votes |
@GET @Path("e4/limit_attributes") public DataResponse<E4> getObjects_LimitAttributes(@Context UriInfo uriInfo) { return Ag.select(E4.class, config).uri(uriInfo) .constraint(Constraint.idOnly(E4.class).attributes(E4.C_INT)) .get(); }
Example #19
Source File: ComponentCatalogResource.java From streamline with Apache License 2.0 | 5 votes |
private List<QueryParam> buildServiceIdAwareQueryParams(Long serviceId, UriInfo uriInfo) { List<QueryParam> queryParams = new ArrayList<>(); queryParams.add(new QueryParam("serviceId", serviceId.toString())); if (uriInfo != null) { MultivaluedMap<String, String> params = uriInfo.getQueryParameters(); if (!params.isEmpty()) { queryParams.addAll(WSUtils.buildQueryParameters(params)); } } return queryParams; }
Example #20
Source File: DominiController.java From govpay with GNU General Public License v3.0 | 5 votes |
public Response dominiIdDominioGET(Authentication user, UriInfo uriInfo, HttpHeaders httpHeaders , String idDominio) { String methodName = "dominiIdDominioGET"; String transactionId = ContextThreadLocal.get().getTransactionId(); this.log.debug(MessageFormat.format(BaseController.LOG_MSG_ESECUZIONE_METODO_IN_CORSO, methodName)); try{ // autorizzazione sulla API this.isAuthorized(user, Arrays.asList(TIPO_UTENZA.ANONIMO, TIPO_UTENZA.CITTADINO, TIPO_UTENZA.APPLICAZIONE), Arrays.asList(Servizio.API_PAGAMENTI), Arrays.asList(Diritti.LETTURA)); ValidatoreIdentificativi validatoreId = ValidatoreIdentificativi.newInstance(); validatoreId.validaIdDominio("idDominio", idDominio); // Parametri - > DTO Input GetDominioDTO getDominioDTO = new GetDominioDTO(user, idDominio); // INIT DAO DominiDAO dominiDAO = new DominiDAO(); // CHIAMATA AL DAO GetDominioDTOResponse listaDominiDTOResponse = dominiDAO.getDominio(getDominioDTO); // CONVERT TO JSON DELLA RISPOSTA it.govpay.pagamento.v2.beans.Dominio response = DominiConverter.toRsModel(listaDominiDTOResponse.getDominio(), listaDominiDTOResponse.getUo(), listaDominiDTOResponse.getTributi(), listaDominiDTOResponse.getIban()); this.log.debug(MessageFormat.format(BaseController.LOG_MSG_ESECUZIONE_METODO_COMPLETATA, methodName)); return this.handleResponseOk(Response.status(Status.OK).entity(response.toJSON(null)),transactionId).build(); }catch (Exception e) { return this.handleException(uriInfo, httpHeaders, methodName, e, transactionId); } finally { this.log(ContextThreadLocal.get()); } }
Example #21
Source File: Intermediari.java From govpay with GNU General Public License v3.0 | 5 votes |
@PUT @Path("/{idIntermediario}") @Consumes({ "application/json" }) public Response addIntermediario(@Context UriInfo uriInfo, @Context HttpHeaders httpHeaders, @PathParam("idIntermediario") String idIntermediario, java.io.InputStream is){ this.buildContext(); return this.controller.addIntermediario(this.getUser(), uriInfo, httpHeaders, idIntermediario, is); }
Example #22
Source File: TopologyEdgeCatalogResource.java From streamline with Apache License 2.0 | 5 votes |
@GET @Path("/topologies/{topologyId}/versions/{versionId}/edges") @Timed public Response listTopologyEdgesForVersion(@PathParam("topologyId") Long topologyId, @PathParam("versionId") Long versionId, @Context UriInfo uriInfo, @Context SecurityContext securityContext) throws Exception { return listTopologyEdges( buildTopologyIdAndVersionIdAwareQueryParams(topologyId, versionId, uriInfo), topologyId, securityContext); }
Example #23
Source File: ManagementResource.java From usergrid with Apache License 2.0 | 5 votes |
@POST @Path( "me" ) @Consumes( APPLICATION_JSON ) public Response getAccessTokenMePostJson( @Context UriInfo ui, Map<String, Object> json, @QueryParam( "callback" ) @DefaultValue( "" ) String callback, @HeaderParam( "Authorization" ) String authorization ) throws Exception { ValidateJson(json); String grant_type = ( String ) json.get( "grant_type" ); String username = ( String ) json.get( "username" ); String password = ( String ) json.get( "password" ); String client_id = ( String ) json.get( "client_id" ); String client_secret = ( String ) json.get( "client_secret" ); long ttl = 0; if ( json.get( "ttl" ) != null ) { try { ttl = Long.parseLong( json.get( "ttl" ).toString() ); } catch ( NumberFormatException nfe ) { throw new IllegalArgumentException( "ttl must be a number >= 0" ); } } return getAccessTokenInternal( ui, authorization, grant_type, username, password, client_id, client_secret, ttl, callback, false, false ); }
Example #24
Source File: Riscossioni.java From govpay with GNU General Public License v3.0 | 5 votes |
@GET @Path("/{idDominio}/{iuv}/{iur}/{indice}") @Produces({ "application/json" }) public Response getRiscossione(@Context UriInfo uriInfo, @Context HttpHeaders httpHeaders, @PathParam("idDominio") String idDominio, @PathParam("iuv") String iuv, @PathParam("iur") String iur, @PathParam("indice") Integer indice){ this.buildContext(); return this.controller.riscossioniIdDominioIuvIurIndiceGET(this.getUser(), uriInfo, httpHeaders, idDominio, iuv, iur, indice); }
Example #25
Source File: GatewayBaseResource.java From datacollector with Apache License 2.0 | 5 votes |
@Path("/{subResources: .*}") @GET public Response handleGetRequests( @PathParam("subResources") String subResources, @Context UriInfo uriInfo, @Context HttpHeaders httpheaders ) throws PipelineException { return proxyRequest(subResources, uriInfo, HttpMethod.GET, httpheaders, null); }
Example #26
Source File: Rpp.java From govpay with GNU General Public License v3.0 | 5 votes |
@PATCH @Path("/{idDominio}/{iuv}/n/a") @Consumes({ "application/json" }) @Produces({ "application/json" }) public Response updateRpp(@Context UriInfo uriInfo, @Context HttpHeaders httpHeaders, java.io.InputStream is, @PathParam("idDominio") String idDominio, @PathParam("iuv") String iuv){ this.buildContext(); return this.controller.updateRpp(this.getUser(), uriInfo, httpHeaders, is, idDominio, iuv, "n/a"); }
Example #27
Source File: OpenType.java From olingo-odata4 with Apache License 2.0 | 5 votes |
@POST @Path("/{entitySetName}") @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON }) @Consumes({ MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_OCTET_STREAM }) @Override public Response postNewEntity( @Context final UriInfo uriInfo, @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept, @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType, @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer, @PathParam("entitySetName") final String entitySetName, final String entity) { return replaceServiceName(super.postNewEntity(uriInfo, accept, contentType, prefer, entitySetName, entity)); }
Example #28
Source File: Customer.java From cxf with Apache License 2.0 | 5 votes |
public void testParams(@Context UriInfo info, @Context HttpHeaders hs, @Context Request r, @Context SecurityContext s, @Context Providers workers, @HeaderParam("Foo") String h, @HeaderParam("Foo") List<String> l) { // complete }
Example #29
Source File: AuthenticationFilter.java From hugegraph with Apache License 2.0 | 5 votes |
public Authorizer(final User user, final UriInfo uri) { E.checkNotNull(user, "user"); E.checkNotNull(uri, "uri"); this.uri = uri; this.user = user; this.principal = new UserPrincipal(); }
Example #30
Source File: RestService.java From dexter with Apache License 2.0 | 5 votes |
private DexterLocalParams getLocalParams(UriInfo ui) { MultivaluedMap<String, String> queryParams = ui.getQueryParameters(); DexterLocalParams params = new DexterLocalParams(); for (String key : queryParams.keySet()) { params.addParam(key, queryParams.getFirst(key)); } return params; }