@Override public void hastaLaVistaAppLinks() { for (ApplicationLink applicationLink : applicationLinkService.getApplicationLinks()) { applicationLinkService.deleteApplicationLink(applicationLink); } } }
@AnonymousAllowed @GET public Response all() { final Iterable<ApplicationLink> links = linkService.getApplicationLinks(); return Response.ok(Iterables.transform(links, new Function<ApplicationLink, ApplinkEntity>() { public ApplinkEntity apply(ApplicationLink link) { return new ApplinkEntity(link); } })).build(); }
private boolean applicationLinkWithRpcUrlAlreadyExists(final URI rpcURl) { return stream(applicationLinkService.getApplicationLinks().spliterator(), false) .anyMatch(input -> (input.getRpcUrl().equals(rpcURl))); }
protected List<LinkAndAuthProviderEntity> retrieveLinkAndAuthProviderEntityList() throws Exception { final List<LinkAndAuthProviderEntity> links = new ArrayList<LinkAndAuthProviderEntity>(); for (final Future<LinkAndAuthProviderEntity> future : executor.invokeAll(createJobs(applicationLinkService.getApplicationLinks()))) { links.add(future.get()); } return Lists.newArrayList(Iterables.filter(links, Predicates.notNull())); }
@GET public Response getAll(@QueryParam("property") final Set<String> propertyKeys, @QueryParam("data") final Set<String> dataKeys) throws ServiceException { permissionValidationService.validateAdmin(); Iterable<ApplicationLink> links = applicationLinkService.getApplicationLinks(); ImmutableList.Builder<RestExtendedApplicationLink> restApplinks = ImmutableList.builder(); for (ApplicationLink applink : links) { restApplinks.add(new RestExtendedApplicationLink(applink, propertyKeys, getData(applink, dataKeys))); } return Response.ok(restApplinks.build()).build(); }
@GET public Response getApplicationLinks() { final List<ApplicationLinkEntity> applicationLinks = new ArrayList<ApplicationLinkEntity>(); for (final ApplicationLink application : applicationLinkService.getApplicationLinks()) { applicationLinks.add(toApplicationLinkEntity(application)); } return ok(new ApplicationLinkListEntity(applicationLinks)); }
@GET @ApiResponse(code = 200, message = "Successful") @ApiOperation(value = "Returns a list of all Application Links on this server", response = ApplicationLinkListEntity.class, authorizations = @Authorization("Admin"), responseContainer = "Object") public Response getApplicationLinks() { final List<ApplicationLinkEntity> applicationLinks = new ArrayList<ApplicationLinkEntity>(); for (final ApplicationLink application : applicationLinkService.getApplicationLinks()) { applicationLinks.add(toApplicationLinkEntity(application)); } return ok(new ApplicationLinkListEntity(applicationLinks)); }
@GET @Path("type/{type}") public Response getApplicationLinks(@PathParam("type") final TypeId typeId) { final ApplicationType type = typeAccessor.loadApplicationType(typeId); if (type == null) { return typeNotInstalled(typeId); } final List<ApplicationLinkEntity> applicationLinks = new ArrayList<ApplicationLinkEntity>(); for (final ApplicationLink application : applicationLinkService.getApplicationLinks(type.getClass())) { applicationLinks.add(toApplicationLinkEntity(application)); } return ok(new ApplicationLinkListEntity(applicationLinks)); }
@GET @Path ("type/{type}") public Response getApplicationLinks(@PathParam ("type") final TypeId typeId) { final ApplicationType type = typeAccessor.loadApplicationType(typeId); if (type == null) { return typeNotInstalled(typeId); } final List<ApplicationLinkEntity> applicationLinks = new ArrayList<ApplicationLinkEntity>(); for (final ApplicationLink application : applicationLinkService.getApplicationLinks(type.getClass())) { applicationLinks.add(toApplicationLinkEntity(application)); } return ok(new ApplicationLinkListEntity(applicationLinks)); }
@Override public ApplicationLink getAppLink(String key) throws NotConnectAddonException { for (ApplicationLink link : applicationLinkService.getApplicationLinks()) { if (key.equals(link.getProperty(PLUGIN_KEY_PROPERTY))) { if (link.getType() instanceof RemotePluginContainerApplicationType) { return link; } else { throw new NotConnectAddonException("Plugin " + key + " does not seem to be a Connect add-on. It's type is: " + link.getType().getClass().getSimpleName()); } } } return null; }
private void cleanTrustedApplications() { for (final TrustedApplication ta : ImmutableList.copyOf( trustedApplicationsConfigurationManager.getTrustedApplications())) { trustedApplicationsConfigurationManager.deleteApplication(ta.getID()); } for (final ApplicationLink link : ImmutableList.copyOf(linkService.getApplicationLinks())) { authenticationConfigurationManager.unregisterProvider(link.getId(), TrustedAppsAuthenticationProvider.class); } }
/** * Deletes all local applinks and stored trusted apps certificates. * Does not require login. * Not very RESTful with a GET, but easier to get to with selenium. */ @GET public Response execute() { /** * {@link MutatingApplicationLinkService#deleteApplicationLink(com.atlassian.applinks.api.ApplicationLink)} * deletes all Trusted Apps and OAuth related state for its applink, * but let's also make sure we remove any orphaned state. */ cleanTrustedApplications(); // Do the same for any left-over OAuth state. cleanOAuth(); for (final ApplicationLink link : ImmutableList.copyOf(linkService.getApplicationLinks())) { linkService.deleteApplicationLink(link); } // delete all charlies: pluginSettingsFactory.createGlobalSettings().remove(CHARLIE_KEYS); return Response.ok().build(); }
@DELETE @WebSudoNotRequired public Response cleanAll(DeleteAllRequestEntity request) { int count = 0; for (ApplicationLink link : linkService.getApplicationLinks()) { if (request.reciprocal) { try { linkService.deleteReciprocatedApplicationLink(link); } catch (Exception e) { linkService.deleteApplicationLink(link); } } else { linkService.deleteApplicationLink(link); } count++; } return Response.ok(new DeleteAllResponseEntity(count)).build(); }
private void deleteOldAppLinks(String pluginKey, ApplicationId appId) { ApplicationLink link; try { link = applicationLinkService.getApplicationLink(appId); } catch (TypeNotInstalledException ex) { log.warn("Link found for '{}' but the type cannot be found, deleting...", pluginKey); manuallyDeleteApplicationId(appId); return; } if (null != link) { if (pluginKey.equals(link.getProperty(PLUGIN_KEY_PROPERTY))) { // This shouldn't happen in normal operation as we delete the applink when we uninstall an addon // and we uninstall the old addon when we install a new version log.warn("Application link for remote plugin container '{}' already exists. Deleting", pluginKey); applicationLinkService.deleteApplicationLink(link); } else { throw new IllegalStateException("Application link already exists for id '" + appId + "' but it isn't the target " + " plugin '" + pluginKey + "': unexpected plugin key is: " + link.getProperty(PLUGIN_KEY_PROPERTY)); } } else { // try to find link with old display url for (final ApplicationLink otherLink : applicationLinkService.getApplicationLinks(RemotePluginContainerApplicationType.class)) { if (pluginKey.equals(otherLink.getProperty(PLUGIN_KEY_PROPERTY))) { log.debug("Old application link for this plugin '{}' found with different display url '{}', removing", pluginKey, otherLink.getDisplayUrl()); applicationLinkService.deleteApplicationLink(otherLink); } } } }
private void cleanOAuth() { String consumerKey = consumerService.getConsumer().getKey(); final Map<ConsumerTokenStore.Key, ConsumerToken> consumerTokens = consumerTokenStore.getConsumerTokens(consumerKey); for (ConsumerTokenStore.Key key : consumerTokens.keySet()) { consumerTokenStore.remove(key); } for (final ApplicationLink link : ImmutableList.copyOf(linkService.getApplicationLinks())) { Map<String, String> config = authenticationConfigurationManager.getConfiguration(link.getId(), OAuthAuthenticationProvider.class); if (config != null && config.containsKey(AUTH_CONFIG_CONSUMER_KEY_OUTBOUND)) { final String key = config.get(AUTH_CONFIG_CONSUMER_KEY_OUTBOUND); consumerTokenStore.removeTokensForConsumer(key); } authenticationConfigurationManager.unregisterProvider(link.getId(), OAuthAuthenticationProvider.class); } // as a service provider (inbound): get rid of all the consumers for (final Consumer consumer : serviceProviderConsumerStore.getAll()) { serviceProviderTokenStore.removeByConsumer(consumer.getKey()); serviceProviderConsumerStore.remove(consumer.getKey()); } // as a consumer (outbound): get rid of all the service providers we talked to for (final Consumer consumer : consumerService.getAllServiceProviders()) { consumerService.removeConsumerByKey(consumer.getKey()); } } }