Java Code Examples for javax.ws.rs.core.UriBuilder#queryParam()
The following examples show how to use
javax.ws.rs.core.UriBuilder#queryParam() .
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: PetApi.java From openapi-generator with Apache License 2.0 | 6 votes |
public HttpResponse findPetsByStatusForHttpResponse(List<String> status) throws IOException { // verify the required parameter 'status' is set if (status == null) { throw new IllegalArgumentException("Missing the required parameter 'status' when calling findPetsByStatus"); } UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + "/pet/findByStatus"); if (status != null) { String key = "status"; Object value = status; if (value instanceof Collection) { uriBuilder = uriBuilder.queryParam(key, ((Collection) value).toArray()); } else if (value instanceof Object[]) { uriBuilder = uriBuilder.queryParam(key, (Object[]) value); } else { uriBuilder = uriBuilder.queryParam(key, value); } } String localVarUrl = uriBuilder.build().toString(); GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = null; return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.GET, genericUrl, content).execute(); }
Example 2
Source File: CompactionControlClient.java From emodb with Apache License 2.0 | 6 votes |
@Override public void updateStashTime(String id, long timestamp, List<String> placements, long expiredTimestamp, String dataCenter) { checkNotNull(id, "id"); checkNotNull(placements, "placements"); checkNotNull(dataCenter, "dataCenter"); try { UriBuilder uriBuilder = _compactionControlSource.clone() .segment("_compcontrol", "stash-time", id) .queryParam("timestamp", timestamp) .queryParam("expiredTimestamp", expiredTimestamp) .queryParam("dataCenter", dataCenter); for (String placement : placements) { uriBuilder.queryParam("placement", placement); } URI uri = uriBuilder.build(); _client.resource(uri) .type(MediaType.APPLICATION_JSON_TYPE) .header(ApiKeyRequest.AUTHENTICATION_HEADER, _apiKey) .post(); } catch (UniformInterfaceException e) { throw convertException(e); } }
Example 3
Source File: RedirectScopeManager.java From krazo with Apache License 2.0 | 6 votes |
/** * Upon detecting a redirect, either add cookie to response or re-write URL of new * location to co-relate next request. * * @param event the event. */ public void controllerRedirectEvent(@Observes ControllerRedirectEvent event) { if (request.getAttribute(SCOPE_ID) != null) { if (usingCookies()) { Cookie cookie = new Cookie(COOKIE_NAME, request.getAttribute(SCOPE_ID).toString()); cookie.setPath(request.getContextPath()); cookie.setMaxAge(600); cookie.setHttpOnly(true); response.addCookie(cookie); } else { final ContainerResponseContext crc = ((ControllerRedirectEventImpl) event).getContainerResponseContext(); final UriBuilder builder = UriBuilder.fromUri(crc.getStringHeaders().getFirst(HttpHeaders.LOCATION)); builder.queryParam(SCOPE_ID, request.getAttribute(SCOPE_ID).toString()); crc.getHeaders().putSingle(HttpHeaders.LOCATION, builder.build()); } } }
Example 4
Source File: ApplicationsResource.java From gravitee-management-rest-api with Apache License 2.0 | 5 votes |
private void addPictureUrl(ApplicationListItem application) { final UriBuilder ub = uriInfo.getBaseUriBuilder(); final UriBuilder uriBuilder = ub.path("organizations").path(GraviteeContext.getCurrentOrganization()) .path("environments").path(GraviteeContext.getCurrentEnvironment()) .path("applications").path(application.getId()).path("picture"); if (application.getPicture() != null) { // force browser to get if updated uriBuilder.queryParam("hash", application.getPicture().hashCode()); application.setPicture(null); } application.setPictureUrl(uriBuilder.build().toString()); }
Example 5
Source File: PetApi.java From openapi-generator with Apache License 2.0 | 5 votes |
public HttpResponse uploadFileForHttpResponse(Long petId, Map<String, Object> params) throws IOException { // verify the required parameter 'petId' is set if (petId == null) { throw new IllegalArgumentException("Missing the required parameter 'petId' when calling uploadFile"); } // create a map of path variables final Map<String, Object> uriVariables = new HashMap<String, Object>(); uriVariables.put("petId", petId); UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + "/pet/{petId}/uploadImage"); // Copy the params argument if present, to allow passing in immutable maps Map<String, Object> allParams = params == null ? new HashMap<String, Object>() : new HashMap<String, Object>(params); for (Map.Entry<String, Object> entry: allParams.entrySet()) { String key = entry.getKey(); Object value = entry.getValue(); if (key != null && value != null) { if (value instanceof Collection) { uriBuilder = uriBuilder.queryParam(key, ((Collection) value).toArray()); } else if (value instanceof Object[]) { uriBuilder = uriBuilder.queryParam(key, (Object[]) value); } else { uriBuilder = uriBuilder.queryParam(key, value); } } } String localVarUrl = uriBuilder.buildFromMap(uriVariables).toString(); GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = new EmptyContent(); return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content).execute(); }
Example 6
Source File: SamlRedirectBindingFilter.java From cxf with Apache License 2.0 | 5 votes |
@Override public void filter(ContainerRequestContext context) { Message m = JAXRSUtils.getCurrentMessage(); if (checkSecurityContext(m)) { return; } try { SamlRequestInfo info = createSamlRequestInfo(m); String urlEncodedRequest = URLEncoder.encode(info.getSamlRequest(), StandardCharsets.UTF_8.name()); UriBuilder ub = UriBuilder.fromUri(getIdpServiceAddress()); ub.queryParam(SSOConstants.SAML_REQUEST, urlEncodedRequest); ub.queryParam(SSOConstants.RELAY_STATE, info.getRelayState()); if (isSignRequest()) { signRequest(urlEncodedRequest, info.getRelayState(), ub); } String contextCookie = createCookie(SSOConstants.RELAY_STATE, info.getRelayState(), info.getWebAppContext(), info.getWebAppDomain()); context.abortWith(Response.seeOther(ub.build()) .header(HttpHeaders.CACHE_CONTROL, "no-cache, no-store") .header("Pragma", "no-cache") .header(HttpHeaders.SET_COOKIE, contextCookie) .build()); } catch (Exception ex) { LOG.log(Level.FINE, ex.getMessage(), ex); throw ExceptionUtils.toInternalServerErrorException(ex, null); } }
Example 7
Source File: FakeApi.java From openapi-generator with Apache License 2.0 | 5 votes |
public HttpResponse testBodyWithQueryParamsForHttpResponse(String query, java.io.InputStream body, String mediaType) throws IOException { // verify the required parameter 'query' is set if (query == null) { throw new IllegalArgumentException("Missing the required parameter 'query' when calling testBodyWithQueryParams"); }// verify the required parameter 'body' is set if (body == null) { throw new IllegalArgumentException("Missing the required parameter 'body' when calling testBodyWithQueryParams"); } UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + "/fake/body-with-query-params"); if (query != null) { String key = "query"; Object value = query; if (value instanceof Collection) { uriBuilder = uriBuilder.queryParam(key, ((Collection) value).toArray()); } else if (value instanceof Object[]) { uriBuilder = uriBuilder.queryParam(key, (Object[]) value); } else { uriBuilder = uriBuilder.queryParam(key, value); } } String localVarUrl = uriBuilder.build().toString(); GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = body == null ? apiClient.new JacksonJsonHttpContent(null) : new InputStreamContent(mediaType == null ? Json.MEDIA_TYPE : mediaType, body); return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.PUT, genericUrl, content).execute(); }
Example 8
Source File: OAuthClient.java From keycloak with Apache License 2.0 | 5 votes |
public void openLogout() { UriBuilder b = OIDCLoginProtocolService.logoutUrl(UriBuilder.fromUri(baseUrl)); if (redirectUri != null) { b.queryParam(OAuth2Constants.REDIRECT_URI, redirectUri); } driver.navigate().to(b.build(realm).toString()); }
Example 9
Source File: Service.java From che with Eclipse Public License 2.0 | 5 votes |
/** * This method is the same to {@link #createLinkHeader(Page, String, Map, Object...)} except of * receiving multivalued query parameters. */ protected String createLinkHeader( Page<?> page, String method, ListMultimap<String, Object> queryParams, Object... pathParams) { final UriBuilder ub = getServiceContext().getServiceUriBuilder().path(getClass(), method); for (Map.Entry<String, Object> queryParam : queryParams.entries()) { ub.queryParam(queryParam.getKey(), queryParam.getValue()); } return PagingUtil.createLinkHeader(page, ub.build(pathParams)); }
Example 10
Source File: CustomerPortal.java From keycloak with Apache License 2.0 | 5 votes |
public URI callCustomerDbAudienceRequiredUrl(boolean attachAudienceScope) { UriBuilder builder = getUriBuilder().clone().path("call-customer-db-audience-required"); if (attachAudienceScope) { builder.queryParam("scope", "customer-db-audience-required"); } return builder.build(); }
Example 11
Source File: UserApi.java From openapi-generator with Apache License 2.0 | 5 votes |
public HttpResponse createUsersWithListInputForHttpResponse(List<User> body, Map<String, Object> params) throws IOException { // verify the required parameter 'body' is set if (body == null) { throw new IllegalArgumentException("Missing the required parameter 'body' when calling createUsersWithListInput"); } UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + "/user/createWithList"); // Copy the params argument if present, to allow passing in immutable maps Map<String, Object> allParams = params == null ? new HashMap<String, Object>() : new HashMap<String, Object>(params); for (Map.Entry<String, Object> entry: allParams.entrySet()) { String key = entry.getKey(); Object value = entry.getValue(); if (key != null && value != null) { if (value instanceof Collection) { uriBuilder = uriBuilder.queryParam(key, ((Collection) value).toArray()); } else if (value instanceof Object[]) { uriBuilder = uriBuilder.queryParam(key, (Object[]) value); } else { uriBuilder = uriBuilder.queryParam(key, value); } } } String localVarUrl = uriBuilder.build().toString(); GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = apiClient.new JacksonJsonHttpContent(body); return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content).execute(); }
Example 12
Source File: UserApi.java From openapi-generator with Apache License 2.0 | 5 votes |
public HttpResponse createUsersWithArrayInputForHttpResponse(List<User> body, Map<String, Object> params) throws IOException { // verify the required parameter 'body' is set if (body == null) { throw new IllegalArgumentException("Missing the required parameter 'body' when calling createUsersWithArrayInput"); } UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + "/user/createWithArray"); // Copy the params argument if present, to allow passing in immutable maps Map<String, Object> allParams = params == null ? new HashMap<String, Object>() : new HashMap<String, Object>(params); for (Map.Entry<String, Object> entry: allParams.entrySet()) { String key = entry.getKey(); Object value = entry.getValue(); if (key != null && value != null) { if (value instanceof Collection) { uriBuilder = uriBuilder.queryParam(key, ((Collection) value).toArray()); } else if (value instanceof Object[]) { uriBuilder = uriBuilder.queryParam(key, (Object[]) value); } else { uriBuilder = uriBuilder.queryParam(key, value); } } } String localVarUrl = uriBuilder.build().toString(); GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = apiClient.new JacksonJsonHttpContent(body); return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content).execute(); }
Example 13
Source File: UserApi.java From openapi-generator with Apache License 2.0 | 5 votes |
public HttpResponse createUserForHttpResponse(User body, Map<String, Object> params) throws IOException { // verify the required parameter 'body' is set if (body == null) { throw new IllegalArgumentException("Missing the required parameter 'body' when calling createUser"); } UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + "/user"); // Copy the params argument if present, to allow passing in immutable maps Map<String, Object> allParams = params == null ? new HashMap<String, Object>() : new HashMap<String, Object>(params); for (Map.Entry<String, Object> entry: allParams.entrySet()) { String key = entry.getKey(); Object value = entry.getValue(); if (key != null && value != null) { if (value instanceof Collection) { uriBuilder = uriBuilder.queryParam(key, ((Collection) value).toArray()); } else if (value instanceof Object[]) { uriBuilder = uriBuilder.queryParam(key, (Object[]) value); } else { uriBuilder = uriBuilder.queryParam(key, value); } } } String localVarUrl = uriBuilder.build().toString(); GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = apiClient.new JacksonJsonHttpContent(body); return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content).execute(); }
Example 14
Source File: AuthenticationProcessor.java From keycloak with Apache License 2.0 | 5 votes |
@Override public URI getActionUrl(String code) { UriBuilder uriBuilder = LoginActionsService.loginActionsBaseUrl(getUriInfo()) .path(AuthenticationProcessor.this.flowPath) .queryParam(LoginActionsService.SESSION_CODE, code) .queryParam(Constants.EXECUTION, getExecution().getId()) .queryParam(Constants.CLIENT_ID, getAuthenticationSession().getClient().getClientId()) .queryParam(Constants.TAB_ID, getAuthenticationSession().getTabId()); if (getUriInfo().getQueryParameters().containsKey(LoginActionsService.AUTH_SESSION_ID)) { uriBuilder.queryParam(LoginActionsService.AUTH_SESSION_ID, getAuthenticationSession().getParentSession().getId()); } return uriBuilder .build(getRealm().getName()); }
Example 15
Source File: StoreApi.java From openapi-generator with Apache License 2.0 | 5 votes |
public HttpResponse placeOrderForHttpResponse(Order body, Map<String, Object> params) throws IOException { // verify the required parameter 'body' is set if (body == null) { throw new IllegalArgumentException("Missing the required parameter 'body' when calling placeOrder"); } UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + "/store/order"); // Copy the params argument if present, to allow passing in immutable maps Map<String, Object> allParams = params == null ? new HashMap<String, Object>() : new HashMap<String, Object>(params); for (Map.Entry<String, Object> entry: allParams.entrySet()) { String key = entry.getKey(); Object value = entry.getValue(); if (key != null && value != null) { if (value instanceof Collection) { uriBuilder = uriBuilder.queryParam(key, ((Collection) value).toArray()); } else if (value instanceof Object[]) { uriBuilder = uriBuilder.queryParam(key, (Object[]) value); } else { uriBuilder = uriBuilder.queryParam(key, value); } } } String localVarUrl = uriBuilder.build().toString(); GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = apiClient.new JacksonJsonHttpContent(body); return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content).execute(); }
Example 16
Source File: FakeApi.java From openapi-generator with Apache License 2.0 | 5 votes |
public HttpResponse testEndpointParametersForHttpResponse(BigDecimal number, Double _double, String patternWithoutDelimiter, byte[] _byte, Map<String, Object> params) throws IOException { // verify the required parameter 'number' is set if (number == null) { throw new IllegalArgumentException("Missing the required parameter 'number' when calling testEndpointParameters"); }// verify the required parameter '_double' is set if (_double == null) { throw new IllegalArgumentException("Missing the required parameter '_double' when calling testEndpointParameters"); }// verify the required parameter 'patternWithoutDelimiter' is set if (patternWithoutDelimiter == null) { throw new IllegalArgumentException("Missing the required parameter 'patternWithoutDelimiter' when calling testEndpointParameters"); }// verify the required parameter '_byte' is set if (_byte == null) { throw new IllegalArgumentException("Missing the required parameter '_byte' when calling testEndpointParameters"); } UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + "/fake"); // Copy the params argument if present, to allow passing in immutable maps Map<String, Object> allParams = params == null ? new HashMap<String, Object>() : new HashMap<String, Object>(params); for (Map.Entry<String, Object> entry: allParams.entrySet()) { String key = entry.getKey(); Object value = entry.getValue(); if (key != null && value != null) { if (value instanceof Collection) { uriBuilder = uriBuilder.queryParam(key, ((Collection) value).toArray()); } else if (value instanceof Object[]) { uriBuilder = uriBuilder.queryParam(key, (Object[]) value); } else { uriBuilder = uriBuilder.queryParam(key, value); } } } String localVarUrl = uriBuilder.build().toString(); GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = new EmptyContent(); return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content).execute(); }
Example 17
Source File: AuthenticationProcessor.java From keycloak with Apache License 2.0 | 5 votes |
public URI getRefreshUrl(boolean authSessionIdParam) { UriBuilder uriBuilder = LoginActionsService.loginActionsBaseUrl(getUriInfo()) .path(AuthenticationProcessor.this.flowPath) .queryParam(Constants.CLIENT_ID, getAuthenticationSession().getClient().getClientId()) .queryParam(Constants.TAB_ID, getAuthenticationSession().getTabId()); if (authSessionIdParam) { uriBuilder.queryParam(LoginActionsService.AUTH_SESSION_ID, getAuthenticationSession().getParentSession().getId()); } return uriBuilder .build(getRealm().getName()); }
Example 18
Source File: SamlRedirectBindingFilter.java From cxf with Apache License 2.0 | 4 votes |
/** * Sign a request according to the redirect binding spec for Web SSO */ private void signRequest( String authnRequest, String relayState, UriBuilder ub ) throws Exception { Crypto crypto = getSignatureCrypto(); if (crypto == null) { LOG.warning("No crypto instance of properties file configured for signature"); throw ExceptionUtils.toInternalServerErrorException(null, null); } String signatureUser = getSignatureUsername(); if (signatureUser == null) { LOG.warning("No user configured for signature"); throw ExceptionUtils.toInternalServerErrorException(null, null); } CallbackHandler callbackHandler = getCallbackHandler(); if (callbackHandler == null) { LOG.warning("No CallbackHandler configured to supply a password for signature"); throw ExceptionUtils.toInternalServerErrorException(null, null); } CryptoType cryptoType = new CryptoType(CryptoType.TYPE.ALIAS); cryptoType.setAlias(signatureUser); X509Certificate[] issuerCerts = crypto.getX509Certificates(cryptoType); if (issuerCerts == null) { throw new Exception( "No issuer certs were found to sign the request using name: " + signatureUser ); } String sigAlgo = getSignatureAlgorithm(); String pubKeyAlgo = issuerCerts[0].getPublicKey().getAlgorithm(); LOG.fine("automatic sig algo detection: " + pubKeyAlgo); if ("DSA".equalsIgnoreCase(pubKeyAlgo)) { sigAlgo = SSOConstants.DSA_SHA1; } LOG.fine("Using Signature algorithm " + sigAlgo); ub.queryParam(SSOConstants.SIG_ALG, URLEncoder.encode(sigAlgo, StandardCharsets.UTF_8.name())); // Get the password WSPasswordCallback[] cb = {new WSPasswordCallback(signatureUser, WSPasswordCallback.SIGNATURE)}; callbackHandler.handle(cb); String password = cb[0].getPassword(); // Get the private key PrivateKey privateKey = crypto.getPrivateKey(signatureUser, password); // Sign the request String jceSigAlgo = JCEMapper.translateURItoJCEID(sigAlgo); Signature signature = Signature.getInstance(jceSigAlgo); signature.initSign(privateKey); String requestToSign = SSOConstants.SAML_REQUEST + "=" + authnRequest + "&" + SSOConstants.RELAY_STATE + "=" + relayState + "&" + SSOConstants.SIG_ALG + "=" + URLEncoder.encode(sigAlgo, StandardCharsets.UTF_8.name()); signature.update(requestToSign.getBytes(StandardCharsets.UTF_8)); byte[] signBytes = signature.sign(); String encodedSignature = Base64.getEncoder().encodeToString(signBytes); // Clean the private key from memory when we're done try { privateKey.destroy(); } catch (DestroyFailedException ex) { // ignore } ub.queryParam(SSOConstants.SIGNATURE, URLEncoder.encode(encodedSignature, StandardCharsets.UTF_8.name())); }
Example 19
Source File: PortalApisResource.java From gravitee-management-rest-api with Apache License 2.0 | 4 votes |
private ApiListItem convert(ApiEntity api) { final ApiListItem apiItem = new ApiListItem(); apiItem.setId(api.getId()); apiItem.setName(api.getName()); apiItem.setVersion(api.getVersion()); apiItem.setDescription(api.getDescription()); final UriBuilder ub = uriInfo.getBaseUriBuilder(); final UriBuilder uriBuilder = ub.path("apis").path(api.getId()).path("picture"); if (api.getPicture() != null) { // force browser to get if updated uriBuilder.queryParam("hash", api.getPicture().hashCode()); } apiItem.setPictureUrl(uriBuilder.build().toString()); apiItem.setCategories(api.getCategories()); apiItem.setCreatedAt(api.getCreatedAt()); apiItem.setUpdatedAt(api.getUpdatedAt()); apiItem.setLabels(api.getLabels()); apiItem.setCategories(api.getCategories()); apiItem.setPrimaryOwner(api.getPrimaryOwner()); if (api.getVisibility() != null) { apiItem.setVisibility(io.gravitee.rest.api.model.Visibility.valueOf(api.getVisibility().toString())); } if (api.getState() != null) { apiItem.setState(Lifecycle.State.valueOf(api.getState().toString())); } if (api.getProxy() != null) { apiItem.setVirtualHosts(api.getProxy().getVirtualHosts()); } if (ratingService.isEnabled()) { final RatingSummaryEntity ratingSummary = ratingService.findSummaryByApi(api.getId()); apiItem.setRate(ratingSummary.getAverageRate()); apiItem.setNumberOfRatings(ratingSummary.getNumberOfRatings()); } apiItem.setTags(api.getTags()); if (api.getLifecycleState() != null) { apiItem.setLifecycleState(ApiLifecycleState.valueOf(api.getLifecycleState().toString())); } return apiItem; }
Example 20
Source File: UserResource.java From keycloak with Apache License 2.0 | 4 votes |
/** * Send a update account email to the user * * An email contains a link the user can click to perform a set of required actions. * The redirectUri and clientId parameters are optional. If no redirect is given, then there will * be no link back to click after actions have completed. Redirect uri must be a valid uri for the * particular clientId. * * @param redirectUri Redirect uri * @param clientId Client id * @param lifespan Number of seconds after which the generated token expires * @param actions required actions the user needs to complete * @return */ @Path("execute-actions-email") @PUT @Consumes(MediaType.APPLICATION_JSON) public Response executeActionsEmail(@QueryParam(OIDCLoginProtocol.REDIRECT_URI_PARAM) String redirectUri, @QueryParam(OIDCLoginProtocol.CLIENT_ID_PARAM) String clientId, @QueryParam("lifespan") Integer lifespan, List<String> actions) { auth.users().requireManage(user); if (user.getEmail() == null) { return ErrorResponse.error("User email missing", Status.BAD_REQUEST); } if (!user.isEnabled()) { throw new WebApplicationException( ErrorResponse.error("User is disabled", Status.BAD_REQUEST)); } if (redirectUri != null && clientId == null) { throw new WebApplicationException( ErrorResponse.error("Client id missing", Status.BAD_REQUEST)); } if (clientId == null) { clientId = Constants.ACCOUNT_MANAGEMENT_CLIENT_ID; } ClientModel client = realm.getClientByClientId(clientId); if (client == null) { logger.debugf("Client %s doesn't exist", clientId); throw new WebApplicationException( ErrorResponse.error("Client doesn't exist", Status.BAD_REQUEST)); } if (!client.isEnabled()) { logger.debugf("Client %s is not enabled", clientId); throw new WebApplicationException( ErrorResponse.error("Client is not enabled", Status.BAD_REQUEST)); } String redirect; if (redirectUri != null) { redirect = RedirectUtils.verifyRedirectUri(session, redirectUri, client); if (redirect == null) { throw new WebApplicationException( ErrorResponse.error("Invalid redirect uri.", Status.BAD_REQUEST)); } } if (lifespan == null) { lifespan = realm.getActionTokenGeneratedByAdminLifespan(); } int expiration = Time.currentTime() + lifespan; ExecuteActionsActionToken token = new ExecuteActionsActionToken(user.getId(), expiration, actions, redirectUri, clientId); try { UriBuilder builder = LoginActionsService.actionTokenProcessor(session.getContext().getUri()); builder.queryParam("key", token.serialize(session, realm, session.getContext().getUri())); String link = builder.build(realm.getName()).toString(); this.session.getProvider(EmailTemplateProvider.class) .setAttribute(Constants.TEMPLATE_ATTR_REQUIRED_ACTIONS, token.getRequiredActions()) .setRealm(realm) .setUser(user) .sendExecuteActions(link, TimeUnit.SECONDS.toMinutes(lifespan)); //audit.user(user).detail(Details.EMAIL, user.getEmail()).detail(Details.CODE_ID, accessCode.getCodeId()).success(); adminEvent.operation(OperationType.ACTION).resourcePath(session.getContext().getUri()).success(); return Response.noContent().build(); } catch (EmailException e) { ServicesLogger.LOGGER.failedToSendActionsEmail(e); return ErrorResponse.error("Failed to send execute actions email", Status.INTERNAL_SERVER_ERROR); } }