@GET @Path("getNonImpersonatingRequestType") public Response getNonImpersonatingRequestType(@QueryParam("rpc-url") String rpcurl) { ApplicationLink applicationLink = getApplicationLinkByRpcUrl(rpcurl); ApplicationLinkRequestFactory factory = applicationLink.createNonImpersonatingAuthenticatedRequestFactory(); return ok(getRequestType(factory)).build(); }
public PermissionCode handle(final com.atlassian.sal.api.net.Response response) throws ResponseException { if (response.getStatusCode() == 200) { try { return response.getEntity(PermissionCodeEntity.class).getCode(); } catch (Exception e) { throw new ResponseException( String.format("Permission check failed, exception " + "encountered processing response: %s", e)); } } else if (response.getStatusCode() == 401) { ApplicationLinkRequestFactory authenticatedRequestFactory = applicationLink.createImpersonatingAuthenticatedRequestFactory(); if (authenticatedRequestFactory == null) { authenticatedRequestFactory = applicationLink.createNonImpersonatingAuthenticatedRequestFactory(); } if (authenticatedRequestFactory != null) { LOG.warn("Authentication failed for application link " + applicationLink + ". Response headers: " + response.getHeaders().toString() + " body: " + response.getResponseBodyAsString()); } else if (LOG.isDebugEnabled()) { LOG.debug("Authentication failed for application link " + applicationLink + ". Response headers: " + response.getHeaders().toString() + " body: " + response.getResponseBodyAsString()); } return AUTHENTICATION_FAILED; } else { throw new ResponseException(String.format("Permission check failed, received %s", response.getStatusCode())); } } });
/** * Getter for the {@link ApplicationLinkRequestFactory} * * @return the {@link ApplicationLinkRequestFactory} */ private ApplicationLinkRequestFactory getApplicationLinkRequestFactory() { ApplicationLinkRequestFactory factory = applicationLink.createNonImpersonatingAuthenticatedRequestFactory(); if (factory == null) { factory = applicationLink.createAuthenticatedRequestFactory(Anonymous.class); // IMPORTANT: Both the Impersonating and NonImpersonating Auth Provider require a Remote User Context, breaking the sync job if (authenticationConfigurationManager.isConfigured(applicationLink.getId(), BasicAuthenticationProvider.class)) { factory = new BasicAuthApplicationLinkRequestFactory(factory, authenticationConfigurationManager.getConfiguration( applicationLink.getId(), BasicAuthenticationProvider.class)); } } return factory; }