private static boolean isOptions(HttpServletRequest request) { return Request.MethodType.OPTIONS.name().equalsIgnoreCase(request.getMethod()); } }
private static boolean isOptions(HttpServletRequest request) { return Request.MethodType.OPTIONS.name().equalsIgnoreCase(request.getMethod()); } }
private static boolean isOptions(HttpServletRequest request) { return Request.MethodType.OPTIONS.name().equalsIgnoreCase(request.getMethod()); } }
@Override public boolean execute(@Nonnull final ApplicationLink applicationLink, @Nonnull final ApplicationId applicationId, @Nonnull final Class<? extends AuthenticationProvider> providerClass) throws IOException, CredentialsRequiredException, ResponseException { final RestUrlBuilder restUrlBuilder = new RestUrlBuilder() .module("applinks") .version(RestVersion.LATEST) .addPath("applicationlink") .addApplicationId(applicationId) .addPath("authentication/provider"); final Optional<AuthorisationUriAwareRequest> request = new RestRequestBuilder(applicationLink) .authentication(providerClass) .methodType(Request.MethodType.GET) .url(restUrlBuilder) .buildOptional(); if (!request.isPresent()) { return false; } final QueryLegacyAuthenticationHandler handler = new QueryLegacyAuthenticationHandler(); if (LOGGER.isDebugEnabled()) { LOGGER.debug(Request.MethodType.GET.name() + " " + applicationLink.getRpcUrl() + restUrlBuilder.toString()); } request.get().execute(handler); return handler.isSuccessful(); }
@Override public boolean execute(@Nonnull final ApplicationLink applicationLink, @Nonnull final ApplicationId applicationId, @Nonnull final ApplicationLinkRequestFactory factory) throws IOException, CredentialsRequiredException, ResponseException { final String url = TRUSTED_AUTOCONFIG_PATH + applicationId.toString(); final ApplicationLinkRequest request = factory.createRequest(Request.MethodType.DELETE, url); request.setHeader("X-Atlassian-Token", "no-check"); RemoteActionHandler handler = new RemoteActionHandler(); request.setConnectionTimeout((int) TimeUnit.SECONDS.toMillis(TryWithAuthentication.TIME_OUT_IN_SECONDS)); request.setSoTimeout((int) TimeUnit.SECONDS.toMillis(TryWithAuthentication.TIME_OUT_IN_SECONDS)); if (LOGGER.isDebugEnabled()) { LOGGER.debug(Request.MethodType.DELETE.name() + " " + applicationLink.getRpcUrl() + url); } request.execute(handler); /* * Empty response from this resource indicates that we successfully removed Trusted Authentication remotely. * We cannot rely solely on the status code due to redirection proxy or websudo, neither of which actually removes Trusted Authentication remotely */ return handler.isSuccessful() && handler.getResponse().map(String::isEmpty).orElse(false); } }
@Override public boolean execute(@Nonnull final ApplicationLink applicationLink, @Nonnull final ApplicationId localApplicationId, @Nonnull final ApplicationLinkRequestFactory factory) throws IOException, CredentialsRequiredException, ResponseException { final String url = SYS_ADMIN_ACCESS_PATH + localApplicationId.toString(); final ApplicationLinkRequest request = factory.createRequest(Request.MethodType.HEAD, url); request.setHeader("X-Atlassian-Token", "no-check"); RemoteActionHandler handler = new RemoteActionHandler(); request.setConnectionTimeout((int) TimeUnit.SECONDS.toMillis(TryWithAuthentication.TIME_OUT_IN_SECONDS)); request.setSoTimeout((int) TimeUnit.SECONDS.toMillis(TryWithAuthentication.TIME_OUT_IN_SECONDS)); if (LOGGER.isDebugEnabled()) { LOGGER.debug(Request.MethodType.HEAD.name() + " " + applicationLink.getRpcUrl() + url); } request.execute(handler); return handler.isSuccessful(); } }