@Test public void removeConnections() throws Exception { ConnectionFactoryRegistry connectionFactoryLocator = new ConnectionFactoryRegistry(); ConnectionFactory<TestApi2> connectionFactory = new StubOAuth2ConnectionFactory("clientId", "clientSecret", THROW_EXCEPTION); connectionFactoryLocator.addConnectionFactory(connectionFactory); StubConnectionRepository connectionRepository = new StubConnectionRepository(); connectionRepository.addConnection(connectionFactory.createConnection(new ConnectionData("provider1", "provider1User1", null, null, null, null, null, null, null))); connectionRepository.addConnection(connectionFactory.createConnection(new ConnectionData("provider1", "provider1User2", null, null, null, null, null, null, null))); connectionRepository.addConnection(connectionFactory.createConnection(new ConnectionData("oauth2Provider", "provider2User1", null, null, null, null, null, null, null))); connectionRepository.addConnection(connectionFactory.createConnection(new ConnectionData("oauth2Provider", "provider2User2", null, null, null, null, null, null, null))); assertEquals(2, connectionRepository.findConnections("provider1").size()); assertEquals(2, connectionRepository.findConnections("oauth2Provider").size()); ConnectController connectController = new ConnectController(connectionFactoryLocator, connectionRepository); List<DisconnectInterceptor<?>> interceptors = getDisconnectInterceptor(); connectController.setDisconnectInterceptors(interceptors); MockMvc mockMvc = standaloneSetup(connectController).build(); mockMvc.perform(delete("/connect/oauth2Provider")) .andExpect(redirectedUrl("/connect/oauth2Provider")); assertEquals(2, connectionRepository.findConnections("provider1").size()); assertEquals(0, connectionRepository.findConnections("oauth2Provider").size()); assertFalse(((TestConnectInterceptor<?>)(interceptors.get(0))).preDisconnectInvoked); assertFalse(((TestConnectInterceptor<?>)(interceptors.get(0))).postDisconnectInvoked); assertNull(((TestConnectInterceptor<?>)(interceptors.get(0))).connectionFactory); assertTrue(((TestConnectInterceptor<?>)(interceptors.get(1))).preDisconnectInvoked); assertTrue(((TestConnectInterceptor<?>)(interceptors.get(1))).postDisconnectInvoked); assertSame(connectionFactory, ((TestConnectInterceptor<?>)(interceptors.get(1))).connectionFactory); }
@RequestMapping(value="/{providerId}", method=RequestMethod.DELETE) public RedirectView removeConnections(@PathVariable String providerId, NativeWebRequest request) { ConnectionFactory<?> connectionFactory = connectionFactoryLocator.getConnectionFactory(providerId); preDisconnect(connectionFactory, request); connectionRepository.removeConnections(providerId); postDisconnect(connectionFactory, request); return connectionStatusRedirect(providerId, request); }
ConnectController implements InitializingBean { @RequestMapping(value="/{providerId}", method=RequestMethod.DELETE) public RedirectView removeConnections(@PathVariable String providerId, NativeWebRequest request) { ConnectionFactory<?> connectionFactory = connectionFactoryLocator.getConnectionFactory(providerId); preDisconnect(connectionFactory, request); connectionRepository.removeConnections(providerId); postDisconnect(connectionFactory, request); return connectionStatusRedirect(providerId, request); } }
ConnectController implements InitializingBean { @RequestMapping(value="/{providerId}", method=RequestMethod.DELETE) public RedirectView removeConnections(@PathVariable String providerId, NativeWebRequest request) { ConnectionFactory<?> connectionFactory = connectionFactoryLocator.getConnectionFactory(providerId); preDisconnect(connectionFactory, request); connectionRepository.removeConnections(providerId); postDisconnect(connectionFactory, request); return connectionStatusRedirect(providerId, request); } @Inject  ConnectController(ConnectionFactoryLocator connectionFactoryLocator, ConnectionRepository connectionRepository); }
ConnectController implements InitializingBean { @RequestMapping(value="/{providerId}", method=RequestMethod.DELETE) public RedirectView removeConnections(@PathVariable String providerId, NativeWebRequest request) { ConnectionFactory<?> connectionFactory = connectionFactoryLocator.getConnectionFactory(providerId); preDisconnect(connectionFactory, request); connectionRepository.removeConnections(providerId); postDisconnect(connectionFactory, request); return connectionStatusRedirect(providerId, request); } @Inject  ConnectController(ConnectionFactoryLocator connectionFactoryLocator, ConnectionRepository connectionRepository); @Deprecated void setInterceptors(List<ConnectInterceptor<?>> interceptors); void setConnectInterceptors(List<ConnectInterceptor<?>> interceptors); void setDisconnectInterceptors(List<DisconnectInterceptor<?>> interceptors); void setApplicationUrl(String applicationUrl); void setViewPath(String viewPath); void setConnectionStatusUrlPath(String connectionStatusUrlPath); void setSessionStrategy(SessionStrategy sessionStrategy); void addInterceptor(ConnectInterceptor<?> interceptor); void addDisconnectInterceptor(DisconnectInterceptor<?> interceptor); @RequestMapping(method=RequestMethod.GET) String connectionStatus(NativeWebRequest request, Model model); @RequestMapping(value="/{providerId}", method=RequestMethod.GET) String connectionStatus(@PathVariable String providerId, NativeWebRequest request, Model model); @RequestMapping(value="/{providerId}", method=RequestMethod.POST) RedirectView connect(@PathVariable String providerId, NativeWebRequest request); @RequestMapping(value="/{providerId}", method=RequestMethod.GET, params="oauth_token") RedirectView oauth1Callback(@PathVariable String providerId, NativeWebRequest request); @RequestMapping(value="/{providerId}", method=RequestMethod.GET, params="code") RedirectView oauth2Callback(@PathVariable String providerId, NativeWebRequest request); @RequestMapping(value="/{providerId}", method=RequestMethod.GET, params="error") RedirectView oauth2ErrorCallback(@PathVariable String providerId, 
			@RequestParam("error") String error, 
			@RequestParam(value="error_description", required=false) String errorDescription,
			@RequestParam(value="error_uri", required=false) String errorUri,
			NativeWebRequest request); @RequestMapping(value="/{providerId}", method=RequestMethod.DELETE) RedirectView removeConnections(@PathVariable String providerId, NativeWebRequest request); @RequestMapping(value="/{providerId}/{providerUserId}", method=RequestMethod.DELETE) RedirectView removeConnection(@PathVariable String providerId, @PathVariable String providerUserId, NativeWebRequest request); void afterPropertiesSet(); }
ConnectController implements InitializingBean { @RequestMapping(value="/{providerId}", method=RequestMethod.DELETE) public RedirectView removeConnections(@PathVariable String providerId, NativeWebRequest request) { ConnectionFactory<?> connectionFactory = connectionFactoryLocator.getConnectionFactory(providerId); preDisconnect(connectionFactory, request); connectionRepository.removeConnections(providerId); postDisconnect(connectionFactory, request); return connectionStatusRedirect(providerId, request); } @Inject  ConnectController(ConnectionFactoryLocator connectionFactoryLocator, ConnectionRepository connectionRepository); @Deprecated void setInterceptors(List<ConnectInterceptor<?>> interceptors); void setConnectInterceptors(List<ConnectInterceptor<?>> interceptors); void setDisconnectInterceptors(List<DisconnectInterceptor<?>> interceptors); void setApplicationUrl(String applicationUrl); void setViewPath(String viewPath); void setConnectionStatusUrlPath(String connectionStatusUrlPath); void setSessionStrategy(SessionStrategy sessionStrategy); void addInterceptor(ConnectInterceptor<?> interceptor); void addDisconnectInterceptor(DisconnectInterceptor<?> interceptor); @RequestMapping(method=RequestMethod.GET) String connectionStatus(NativeWebRequest request, Model model); @RequestMapping(value="/{providerId}", method=RequestMethod.GET) String connectionStatus(@PathVariable String providerId, NativeWebRequest request, Model model); @RequestMapping(value="/{providerId}", method=RequestMethod.POST) RedirectView connect(@PathVariable String providerId, NativeWebRequest request); @RequestMapping(value="/{providerId}", method=RequestMethod.GET, params="oauth_token") RedirectView oauth1Callback(@PathVariable String providerId, NativeWebRequest request); @RequestMapping(value="/{providerId}", method=RequestMethod.GET, params="code") RedirectView oauth2Callback(@PathVariable String providerId, NativeWebRequest request); @RequestMapping(value="/{providerId}", method=RequestMethod.GET, params="error") RedirectView oauth2ErrorCallback(@PathVariable String providerId, 
			@RequestParam("error") String error, 
			@RequestParam(value="error_description", required=false) String errorDescription,
			@RequestParam(value="error_uri", required=false) String errorUri,
			NativeWebRequest request); @RequestMapping(value="/{providerId}", method=RequestMethod.DELETE) RedirectView removeConnections(@PathVariable String providerId, NativeWebRequest request); @RequestMapping(value="/{providerId}/{providerUserId}", method=RequestMethod.DELETE) RedirectView removeConnection(@PathVariable String providerId, @PathVariable String providerUserId, NativeWebRequest request); void afterPropertiesSet();  }