@Test public void testSuccessfulTokenCreationWithNullCallback() { final CreateOAuthRequestTokenRequest request = new CreateOAuthRequestTokenRequest(TEST_CONSUMER_KEY, TEST_OAUTH_VERSION, null); context.checking(new Expectations() { { oneOf(actionContext).getParams(); will(returnValue(request)); oneOf(oauthConversionStrat).convertToEntryDTO(with(any(OAuthEntry.class))); oneOf(insertMapper).execute(with(any(PersistenceRequest.class))); } }); OAuthEntry results = sut.execute(actionContext); assertNotNull(results); assertEquals(results.getCallbackUrl(), null); assertEquals(results.getConsumerKey(), TEST_CONSUMER_KEY); assertEquals(results.getOauthVersion(), TEST_OAUTH_VERSION); assertEquals(results.getType(), OAuthEntry.Type.REQUEST); assertNotNull(results.getToken()); assertNotNull(results.getTokenSecret()); assertEquals(results.getContainer(), TEST_OAUTH_CONTAINER); assertEquals(results.getDomain(), TEST_OAUTH_DOMAIN); assertEquals(results.getCallbackUrl(), null); assertEquals(results.isCallbackUrlSigned(), false); context.assertIsSatisfied(); }
@Override public OAuthEntry execute(final PrincipalActionContext inActionContext) throws ExecutionException { CreateOAuthRequestTokenRequest currentRequest = (CreateOAuthRequestTokenRequest) inActionContext.getParams(); OAuthEntry entry = new OAuthEntry(); entry.setAppId(currentRequest.getConsumerKey()); entry.setConsumerKey(currentRequest.getConsumerKey()); entry.setDomain(oauthDomain); entry.setContainer(oauthContainer); entry.setToken(UUID.randomUUID().toString()); entry.setTokenSecret(UUID.randomUUID().toString()); entry.setType(OAuthEntry.Type.REQUEST); entry.setIssueTime(new Date()); entry.setOauthVersion(currentRequest.getOauthVersion()); if (currentRequest.getSignedCallbackUrl() != null) { entry.setCallbackUrlSigned(true); entry.setCallbackUrl(currentRequest.getSignedCallbackUrl()); } OAuthDomainEntry dto = oauthConversionStrat.convertToEntryDTO(entry); insertMapper.execute(new PersistenceRequest<OAuthDomainEntry>(dto)); return entry; }
CreateOAuthRequestTokenExecution implements ExecutionStrategy<PrincipalActionContext> { @Override public OAuthEntry execute(final PrincipalActionContext inActionContext) throws ExecutionException { CreateOAuthRequestTokenRequest currentRequest = (CreateOAuthRequestTokenRequest) inActionContext.getParams(); OAuthEntry entry = new OAuthEntry(); entry.setAppId(currentRequest.getConsumerKey()); entry.setConsumerKey(currentRequest.getConsumerKey()); entry.setDomain(oauthDomain); entry.setContainer(oauthContainer); entry.setToken(UUID.randomUUID().toString()); entry.setTokenSecret(UUID.randomUUID().toString()); entry.setType(OAuthEntry.Type.REQUEST); entry.setIssueTime(new Date()); entry.setOauthVersion(currentRequest.getOauthVersion()); if (currentRequest.getSignedCallbackUrl() != null) { entry.setCallbackUrlSigned(true); entry.setCallbackUrl(currentRequest.getSignedCallbackUrl()); } OAuthDomainEntry dto = oauthConversionStrat.convertToEntryDTO(entry); insertMapper.execute(new PersistenceRequest<OAuthDomainEntry>(dto)); return entry; } }
CreateOAuthRequestTokenExecution implements ExecutionStrategy<PrincipalActionContext> { @Override public OAuthEntry execute(final PrincipalActionContext inActionContext) throws ExecutionException { CreateOAuthRequestTokenRequest currentRequest = (CreateOAuthRequestTokenRequest) inActionContext.getParams(); OAuthEntry entry = new OAuthEntry(); entry.setAppId(currentRequest.getConsumerKey()); entry.setConsumerKey(currentRequest.getConsumerKey()); entry.setDomain(oauthDomain); entry.setContainer(oauthContainer); entry.setToken(UUID.randomUUID().toString()); entry.setTokenSecret(UUID.randomUUID().toString()); entry.setType(OAuthEntry.Type.REQUEST); entry.setIssueTime(new Date()); entry.setOauthVersion(currentRequest.getOauthVersion()); if (currentRequest.getSignedCallbackUrl() != null) { entry.setCallbackUrlSigned(true); entry.setCallbackUrl(currentRequest.getSignedCallbackUrl()); } OAuthDomainEntry dto = oauthConversionStrat.convertToEntryDTO(entry); insertMapper.execute(new PersistenceRequest<OAuthDomainEntry>(dto)); return entry; } CreateOAuthRequestTokenExecution(final String inOAuthDomain, final String inOAuthContainer,
            final InsertMapper<OAuthDomainEntry> inInsertMapper,
            final OAuthEntryConversionStrategy inOAuthConversionStrat); }
CreateOAuthRequestTokenExecution implements ExecutionStrategy<PrincipalActionContext> { @Override public OAuthEntry execute(final PrincipalActionContext inActionContext) throws ExecutionException { CreateOAuthRequestTokenRequest currentRequest = (CreateOAuthRequestTokenRequest) inActionContext.getParams(); OAuthEntry entry = new OAuthEntry(); entry.setAppId(currentRequest.getConsumerKey()); entry.setConsumerKey(currentRequest.getConsumerKey()); entry.setDomain(oauthDomain); entry.setContainer(oauthContainer); entry.setToken(UUID.randomUUID().toString()); entry.setTokenSecret(UUID.randomUUID().toString()); entry.setType(OAuthEntry.Type.REQUEST); entry.setIssueTime(new Date()); entry.setOauthVersion(currentRequest.getOauthVersion()); if (currentRequest.getSignedCallbackUrl() != null) { entry.setCallbackUrlSigned(true); entry.setCallbackUrl(currentRequest.getSignedCallbackUrl()); } OAuthDomainEntry dto = oauthConversionStrat.convertToEntryDTO(entry); insertMapper.execute(new PersistenceRequest<OAuthDomainEntry>(dto)); return entry; } CreateOAuthRequestTokenExecution(final String inOAuthDomain, final String inOAuthContainer,
            final InsertMapper<OAuthDomainEntry> inInsertMapper,
            final OAuthEntryConversionStrategy inOAuthConversionStrat); @Override OAuthEntry execute(final PrincipalActionContext inActionContext); }
CreateOAuthRequestTokenExecution implements ExecutionStrategy<PrincipalActionContext> { @Override public OAuthEntry execute(final PrincipalActionContext inActionContext) throws ExecutionException { CreateOAuthRequestTokenRequest currentRequest = (CreateOAuthRequestTokenRequest) inActionContext.getParams(); OAuthEntry entry = new OAuthEntry(); entry.setAppId(currentRequest.getConsumerKey()); entry.setConsumerKey(currentRequest.getConsumerKey()); entry.setDomain(oauthDomain); entry.setContainer(oauthContainer); entry.setToken(UUID.randomUUID().toString()); entry.setTokenSecret(UUID.randomUUID().toString()); entry.setType(OAuthEntry.Type.REQUEST); entry.setIssueTime(new Date()); entry.setOauthVersion(currentRequest.getOauthVersion()); if (currentRequest.getSignedCallbackUrl() != null) { entry.setCallbackUrlSigned(true); entry.setCallbackUrl(currentRequest.getSignedCallbackUrl()); } OAuthDomainEntry dto = oauthConversionStrat.convertToEntryDTO(entry); insertMapper.execute(new PersistenceRequest<OAuthDomainEntry>(dto)); return entry; } CreateOAuthRequestTokenExecution(final String inOAuthDomain, final String inOAuthContainer,
            final InsertMapper<OAuthDomainEntry> inInsertMapper,
            final OAuthEntryConversionStrategy inOAuthConversionStrat); @Override OAuthEntry execute(final PrincipalActionContext inActionContext);  }