@Test public void testLoadConsumerByConsumerKey() { final OAuthConsumer consumer = new OAuthConsumer("", "KEY", "SECRET", null); context.checking(new Expectations() { { oneOf(actionController).execute(with(new EasyMatcher<ServiceActionContext>() { @Override protected boolean isMatch(final ServiceActionContext inTestObject) { return "KEY".equals(inTestObject.getParams()); } }), with(same(getOAuthConsumerByConsumerKeyAction))); will(returnValue(consumer)); } }); ConsumerDetails result = sut.loadConsumerByConsumerKey("KEY"); context.assertIsSatisfied(); assertEquals("KEY", result.getConsumerKey()); assertNotNull(result.getConsumerName()); assertEquals("SECRET", ((SharedConsumerSecret) result.getSignatureSecret()).getConsumerSecret()); GrantedAuthority[] auths = result.getAuthorities(); assertEquals(2, auths.length); assertEquals("ROLE1", auths[0].getAuthority()); assertEquals("ROLE2", auths[1].getAuthority()); }
@Override public ConsumerDetails loadConsumerByConsumerKey(final String inConsumerKey) throws OAuthException { try { ServiceActionContext currentContext = new ServiceActionContext(inConsumerKey, null); OAuthConsumer consumer = (OAuthConsumer) actionController.execute(currentContext, getOAuthConsumerByConsumerKeyAction); BaseConsumerDetails details = new BaseConsumerDetails(); details.setConsumerKey(inConsumerKey); details.setConsumerName(inConsumerKey); details.setSignatureSecret(new SharedConsumerSecret(consumer.consumerSecret)); details.setAuthorities(grantedAuthorities); details.setRequiredToObtainAuthenticatedToken(false); return details; } catch (Exception ex) { log.error("Error occurred retrieving consumer with provided key.", ex); throw new OAuthException("Unable to retrieve consumer with provided information."); } }
ConsumerDetailsServiceImpl implements ConsumerDetailsService { @Override public ConsumerDetails loadConsumerByConsumerKey(final String inConsumerKey) throws OAuthException { try { ServiceActionContext currentContext = new ServiceActionContext(inConsumerKey, null); OAuthConsumer consumer = (OAuthConsumer) actionController.execute(currentContext, getOAuthConsumerByConsumerKeyAction); BaseConsumerDetails details = new BaseConsumerDetails(); details.setConsumerKey(inConsumerKey); details.setConsumerName(inConsumerKey); details.setSignatureSecret(new SharedConsumerSecret(consumer.consumerSecret)); details.setAuthorities(grantedAuthorities); details.setRequiredToObtainAuthenticatedToken(false); return details; } catch (Exception ex) { log.error("Error occurred retrieving consumer with provided key.", ex); throw new OAuthException("Unable to retrieve consumer with provided information."); } } }
ConsumerDetailsServiceImpl implements ConsumerDetailsService { @Override public ConsumerDetails loadConsumerByConsumerKey(final String inConsumerKey) throws OAuthException { try { ServiceActionContext currentContext = new ServiceActionContext(inConsumerKey, null); OAuthConsumer consumer = (OAuthConsumer) actionController.execute(currentContext, getOAuthConsumerByConsumerKeyAction); BaseConsumerDetails details = new BaseConsumerDetails(); details.setConsumerKey(inConsumerKey); details.setConsumerName(inConsumerKey); details.setSignatureSecret(new SharedConsumerSecret(consumer.consumerSecret)); details.setAuthorities(grantedAuthorities); details.setRequiredToObtainAuthenticatedToken(false); return details; } catch (Exception ex) { log.error("Error occurred retrieving consumer with provided key.", ex); throw new OAuthException("Unable to retrieve consumer with provided information."); } } ConsumerDetailsServiceImpl(final ActionController inActionController,
            final ServiceAction inGetOAuthConsumerByConsumerKeyAction, final String inGrantedAuthorities); }
ConsumerDetailsServiceImpl implements ConsumerDetailsService { @Override public ConsumerDetails loadConsumerByConsumerKey(final String inConsumerKey) throws OAuthException { try { ServiceActionContext currentContext = new ServiceActionContext(inConsumerKey, null); OAuthConsumer consumer = (OAuthConsumer) actionController.execute(currentContext, getOAuthConsumerByConsumerKeyAction); BaseConsumerDetails details = new BaseConsumerDetails(); details.setConsumerKey(inConsumerKey); details.setConsumerName(inConsumerKey); details.setSignatureSecret(new SharedConsumerSecret(consumer.consumerSecret)); details.setAuthorities(grantedAuthorities); details.setRequiredToObtainAuthenticatedToken(false); return details; } catch (Exception ex) { log.error("Error occurred retrieving consumer with provided key.", ex); throw new OAuthException("Unable to retrieve consumer with provided information."); } } ConsumerDetailsServiceImpl(final ActionController inActionController,
            final ServiceAction inGetOAuthConsumerByConsumerKeyAction, final String inGrantedAuthorities); @Override ConsumerDetails loadConsumerByConsumerKey(final String inConsumerKey); }
ConsumerDetailsServiceImpl implements ConsumerDetailsService { @Override public ConsumerDetails loadConsumerByConsumerKey(final String inConsumerKey) throws OAuthException { try { ServiceActionContext currentContext = new ServiceActionContext(inConsumerKey, null); OAuthConsumer consumer = (OAuthConsumer) actionController.execute(currentContext, getOAuthConsumerByConsumerKeyAction); BaseConsumerDetails details = new BaseConsumerDetails(); details.setConsumerKey(inConsumerKey); details.setConsumerName(inConsumerKey); details.setSignatureSecret(new SharedConsumerSecret(consumer.consumerSecret)); details.setAuthorities(grantedAuthorities); details.setRequiredToObtainAuthenticatedToken(false); return details; } catch (Exception ex) { log.error("Error occurred retrieving consumer with provided key.", ex); throw new OAuthException("Unable to retrieve consumer with provided information."); } } ConsumerDetailsServiceImpl(final ActionController inActionController,
            final ServiceAction inGetOAuthConsumerByConsumerKeyAction, final String inGrantedAuthorities); @Override ConsumerDetails loadConsumerByConsumerKey(final String inConsumerKey);  }