public void removeByConsumer(String consumerKey) { store.removeByConsumer(consumerKey); } }
@Override protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { ApplicationLink applicationLink; try { applicationLink = Iterables.get(applicationLinkService.getApplicationLinks(), 0); } catch (IndexOutOfBoundsException iobe) { throw new RuntimeException("Need one application link to perform the test"); } serviceProviderTokenStore.removeByConsumer(getConsumerKey(applicationLink)); resp.setContentType("text/plain"); PrintWriter out = resp.getWriter(); out.println("done"); out.close(); }
public void removeConsumer(final ApplicationLink applicationLink) { final String consumerKey = getConsumerKey(applicationLink); if (consumerKey == null) { throw new IllegalStateException("No consumer configured for application link '" + applicationLink + "'."); } serviceProviderTokenStore.removeByConsumer(consumerKey); serviceProviderConsumerStore.remove(consumerKey); if (applicationLink.removeProperty(PROPERTY_INCOMING_CONSUMER_KEY) == null) { throw new IllegalStateException("Failed to remove consumer with key '" + consumerKey + "' from application link '" + applicationLink + "'"); } }
@EventListener public void onApplicationLinkDeleted(BeforeApplicationLinkDeletedEvent beforeApplicationLinkDeletedEvent) { final ApplicationLink applicationLink = beforeApplicationLinkDeletedEvent.getApplicationLink(); final Object oConsumerKey = applicationLink.getProperty(OAUTH_INCOMING_CONSUMER_KEY); if (oConsumerKey != null) { final String consumerKey = oConsumerKey.toString(); serviceProviderTokenStore.removeByConsumer(consumerKey); serviceProviderConsumerStore.remove(consumerKey); logger.debug("Unregistered consumer with key '{}' for deleted application link {}", oConsumerKey, applicationLink); } if (configurationManager.isConfigured(applicationLink.getId(), OAuthAuthenticationProvider.class)) { final Map<String, String> configuration = configurationManager.getConfiguration(applicationLink.getId(), OAuthAuthenticationProvider.class); final String consumerKey = configuration.get(AddServiceProviderManuallyServlet.CONSUMER_KEY_OUTBOUND); if (!StringUtils.isEmpty(consumerKey)) { consumerService.removeConsumerByKey(consumerKey); logger.debug("Unregistered service provider with consumer key '{}' for deleted application link {}", consumerKey, applicationLink); } consumerTokenStoreService.removeAllConsumerTokens(applicationLink); logger.debug("Removed token for deleted application link {}", applicationLink); } }
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()); } } }