@Override public String marshal(final ApplicationId v) throws Exception { return v.toString(); } }
@Override public String marshal(final ApplicationId v) throws Exception { return v.toString(); } }
private String formatDeprecatedKey(final ApplicationId id, final String originalProviderKey) { return String.format("applinks.admin.%s.auth.%s", id.toString(), originalProviderKey); }
@Nonnull public RestUrlBuilder addApplicationId(@Nonnull ApplicationId applicationId) { return addPath(checkNotNull(applicationId, "applicationId").toString()); }
@Override public String apply(@Nullable ApplicationLink input) { return input.getId().toString(); } });
private String renderChart(String jql, String statisticType, ReadOnlyApplicationLink appLink, String titleType, String totalIssues) { HashMap<String, Object> piechartContext = Maps.newHashMap(); piechartContext.put("totalIssues", totalIssues); piechartContext.put("titleType", titleType); piechartContext.put("serverId", appLink.getId().toString()); piechartContext.put("server", appLink.getName()); piechartContext.put("jql", jql); piechartContext.put("statType", statisticType); piechartContext.put("width", ""); piechartContext.put("border", true); return helper.renderFromSoy(SoftwareBlueprintsContextProviderHelper.PLUGIN_KEY, SOY_PIE_CHART_MACRO_TEMPLATE, piechartContext); }
private String getJiraIssuesMacro(String keyJQL, Object valJQL, ReadOnlyApplicationLink appLink, boolean isCount) { HashMap<String, Object> jiraIssuesMacroContext = Maps.newHashMap(); jiraIssuesMacroContext.put("serverId", appLink.getId().toString()); jiraIssuesMacroContext.put("server", appLink.getName()); jiraIssuesMacroContext.put("keyJQL", keyJQL); jiraIssuesMacroContext.put("valJQL", valJQL); jiraIssuesMacroContext.put("isCount", isCount); return helper.renderFromSoy(SoftwareBlueprintsContextProviderHelper.PLUGIN_KEY, SOY_JIRAISSUES_MACRO_TEMPLATE, jiraIssuesMacroContext); }
private void addHostApplication(ImmutableMap.Builder<String, Object> contextMapBuilder) { contextMapBuilder.put(HOST_APPLICATION_KEY, ImmutableMap.of( HOST_APPLICATION_ID_KEY, hostApplication.getId().toString(), HOST_APPLICATION_TYPE_KEY, resolveApplicationTypeId(hostApplication.getType()) )); } }
private String buildRetrieverUrl(Collection<ColumnInfo> columns, String url, ApplicationLink applink, boolean forceAnonymous) { HttpServletRequest req = httpContext.getRequest(); String baseUrl = req.getContextPath(); StringBuffer retrieverUrl = new StringBuffer(baseUrl); retrieverUrl.append("/plugins/servlet/issue-retriever?"); retrieverUrl.append("url=").append(utf8Encode(url)); if (applink != null) { retrieverUrl.append("&appId=").append(utf8Encode(applink.getId().toString())); } for (ColumnInfo columnInfo : columns) { retrieverUrl.append("&columns=").append(utf8Encode(columnInfo.toString())); } retrieverUrl.append("&forceAnonymous=").append(forceAnonymous); retrieverUrl.append("&flexigrid=true"); return retrieverUrl.toString(); }
/** * Get Configured providers for the current ApplicationLink. */ private List<AuthenticationProviderEntity> getConfiguredProviders(ApplicationLink applicationLink, Iterable<AuthenticationProviderPluginModule> pluginModules) throws URISyntaxException { // get the providers configured for this link final List<AuthenticationProviderEntity> configuredAuthProviders = new ArrayList<AuthenticationProviderEntity>(); for (AuthenticationProviderPluginModule authenticationProviderPluginModule : pluginModules) { final AuthenticationProvider authenticationProvider = authenticationProviderPluginModule.getAuthenticationProvider(applicationLink); if (authenticationProvider != null) { Map<String, String> config = authenticationConfigurationManager.getConfiguration(applicationLink.getId(), authenticationProviderPluginModule.getAuthenticationProviderClass()); configuredAuthProviders.add(new AuthenticationProviderEntity( Link.self(new URI(ApplicationLinkResource.CONTEXT + "/" + applicationLink.getId().toString() + "/authentication/provider")), authenticationProviderPluginModule.getClass().getName(), authenticationProviderPluginModule.getAuthenticationProviderClass().getName(), config)); } } return configuredAuthProviders; }
/** * Get Configured providers for the current ApplicationLink. */ private List<AuthenticationProviderEntity> getConfiguredProviders(ApplicationLink applicationLink, Iterable<AuthenticationProviderPluginModule> pluginModules) throws URISyntaxException { // get the providers configured for this link final List<AuthenticationProviderEntity> configuredAuthProviders = new ArrayList<AuthenticationProviderEntity>(); for (AuthenticationProviderPluginModule authenticationProviderPluginModule : pluginModules) { final AuthenticationProvider authenticationProvider = authenticationProviderPluginModule.getAuthenticationProvider(applicationLink); if (authenticationProvider != null) { Map<String, String> config = authenticationConfigurationManager.getConfiguration(applicationLink.getId(), authenticationProviderPluginModule.getAuthenticationProviderClass()); configuredAuthProviders.add(new AuthenticationProviderEntity( Link.self(new URI(OAuthApplicationLinkResource.CONTEXT + "/" + applicationLink.getId().toString() + "/authentication/provider")), authenticationProviderPluginModule.getClass().getName(), authenticationProviderPluginModule.getAuthenticationProviderClass().getName(), config)); } } return configuredAuthProviders; }
@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(); } }
@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); } }
oldId.toString() + " does not exist."); } else { final ApplicationLinkProperties oldProperties = propertyService.getApplicationLinkProperties(oldId);
public String getConfigUrl(ApplicationLink link, Version applicationLinksVersion, AuthenticationDirection direction, HttpServletRequest request) { final boolean supportsAppLinks = applicationLinksVersion != null; //If the application is has the OAuth Plugin installed, we can use the same screen as for applications that have UAL installed. final boolean oAuthPluginInstalled = OAuthHelper.isOAuthPluginInstalled(link); if (direction == AuthenticationDirection.INBOUND) { if (supportsAppLinks || oAuthPluginInstalled) { return RequestUtil.getBaseURLFromRequest(request, hostApplication.getBaseUrl()) + OAuthAuthenticatorProviderPluginModule.ADD_CONSUMER_BY_URL_SERVLET_LOCATION + link.getId().toString() + "?" + AddConsumerByUrlServlet.UI_POSITION + "=local"; } else { return RequestUtil.getBaseURLFromRequest(request, hostApplication.getBaseUrl()) + OAuthAuthenticatorProviderPluginModule.ADD_CONSUMER_MANUALLY_SERVLET_LOCATION + link.getId().toString(); } } return null; }
public String getConfigUrl(final ApplicationLink link, final Version applicationLinksVersion, AuthenticationDirection direction, final HttpServletRequest request) { final String configUri; final boolean supportsAppLinks = applicationLinksVersion != null; // TODO: maybe safer to check for < 3.0 //If the application is has the OAuth Plugin installed, we can use the same screen as for applications that have UAL installed. final boolean oAuthPluginInstalled = OAuthHelper.isOAuthPluginInstalled(link); if (direction == AuthenticationDirection.OUTBOUND) { // This servlet takes care of redirecting to the appropriate url. This is required because the query string // passed to the remote {@link AddConsumerByUrlServlet} needs to be updated over time while this url here // won't be reloaded by {@link AuthenticatorContainerServlet). configUri = RequestUtil.getBaseURLFromRequest(request, hostApplication.getBaseUrl()) + OUTBOUND_ATLASSIAN_REDIRECT_LOCATION + link.getId().toString() + "?" + OutboundRedirectServlet.SUPPORT_APPLINK_PARAM + "=" + supportsAppLinks; } else { if (supportsAppLinks || oAuthPluginInstalled) { configUri = RequestUtil.getBaseURLFromRequest(request, hostApplication.getBaseUrl()) + ADD_CONSUMER_BY_URL_SERVLET_LOCATION + link.getId().toString() + "?" + AddConsumerByUrlServlet.UI_POSITION + "=local"; } else { configUri = RequestUtil.getBaseURLFromRequest(request, hostApplication.getBaseUrl()) + ADD_CONSUMER_MANUALLY_SERVLET_LOCATION + link.getId().toString(); } } return configUri; }
private String getAutoConfigServletUrl(ApplicationLink applink) { return RestUrl.forPath(applink.getRpcUrl().toASCIIString()) .add(ServletPathConstants.APPLINKS_CONFIG_SERVLET_URL) .add("oauth") .add("autoconfig") .add(internalHostApplication.getId().toString()) .toString(); }
appProjectMap.put(applicationLink.getId().toString(), keysForLink);
} else if (oAuthPluginInstalled) { configUri = RequestUtil.getBaseURLFromRequest(request, hostApplication.getBaseUrl()) + OUTBOUND_ATLASSIAN_SERVLET_LOCATION + link.getId().toString(); } else { configUri = RequestUtil.getBaseURLFromRequest(request, hostApplication.getBaseUrl()) + OUTBOUND_NON_APPLINKS_SERVLET_LOCATION + link.getId().toString();
@Override public ApplicationLinkState callWithContext() throws Exception { if (manifestRetriever.getApplicationStatus(applicationLink.getRpcUrl(), applicationLink.getType()) == ApplicationStatus.UNAVAILABLE) { return ApplicationLinkState.OFFLINE; } else { try { final Manifest manifest = manifestRetriever.getManifest(applicationLink.getRpcUrl(), applicationLink.getType()); if (!applicationLink.getId().equals(manifest.getId())) { if (manifest.getAppLinksVersion() != null && manifest.getAppLinksVersion().getMajor() >= 3) { return ApplicationLinkState.UPGRADED_TO_UAL; } else { return ApplicationLinkState.UPGRADED; } } } catch (ManifestNotFoundException e) { // unknown application type LOG.error("The {} application type failed to produce a " + "Manifest for Application Link {}, so we cannot " + "determine the link status.", TypeId.getTypeId( applicationLink.getType()).toString(), applicationLink.getId().toString()); } return ApplicationLinkState.OK; } } });