@Test public void testSuccessfulAuthorization() { context.checking(new Expectations() { { oneOf(actionContext).getParams(); will(returnValue("testconsumerkey")); oneOf(actionContext).getPrincipal(); will(returnValue(principal)); oneOf(principal).getId(); will(returnValue(1L)); oneOf(verifyMapper).execute(with(any(GetGadgetsByGadgetDefAndConsumerKeyRequest.class))); will(returnValue(1L)); } }); sut.authorize(actionContext); context.assertIsSatisfied(); }
@Override public void authorize(final PrincipalActionContext inActionContext) throws AuthorizationException { String consumerKey = (String) inActionContext.getParams(); Long gadgetCount = verifyMapper.execute(new GetGadgetsByGadgetDefAndConsumerKeyRequest(consumerKey, inActionContext.getPrincipal().getId())); if (gadgetCount <= 0) { throw new AuthorizationException("The user supplied with this OAuth request does not have the app " + "associated with this consumer key installed on their start page."); } }
OAuthRequestAuthorization implements AuthorizationStrategy<PrincipalActionContext> { @Override public void authorize(final PrincipalActionContext inActionContext) throws AuthorizationException { String consumerKey = (String) inActionContext.getParams(); Long gadgetCount = verifyMapper.execute(new GetGadgetsByGadgetDefAndConsumerKeyRequest(consumerKey, inActionContext.getPrincipal().getId())); if (gadgetCount <= 0) { throw new AuthorizationException("The user supplied with this OAuth request does not have the app " + "associated with this consumer key installed on their start page."); } } }
OAuthRequestAuthorization implements AuthorizationStrategy<PrincipalActionContext> { @Override public void authorize(final PrincipalActionContext inActionContext) throws AuthorizationException { String consumerKey = (String) inActionContext.getParams(); Long gadgetCount = verifyMapper.execute(new GetGadgetsByGadgetDefAndConsumerKeyRequest(consumerKey, inActionContext.getPrincipal().getId())); if (gadgetCount <= 0) { throw new AuthorizationException("The user supplied with this OAuth request does not have the app " + "associated with this consumer key installed on their start page."); } } OAuthRequestAuthorization(final GetGadgetsByGadgetDefAndConsumerKey inVerifyMapper); }
OAuthRequestAuthorization implements AuthorizationStrategy<PrincipalActionContext> { @Override public void authorize(final PrincipalActionContext inActionContext) throws AuthorizationException { String consumerKey = (String) inActionContext.getParams(); Long gadgetCount = verifyMapper.execute(new GetGadgetsByGadgetDefAndConsumerKeyRequest(consumerKey, inActionContext.getPrincipal().getId())); if (gadgetCount <= 0) { throw new AuthorizationException("The user supplied with this OAuth request does not have the app " + "associated with this consumer key installed on their start page."); } } OAuthRequestAuthorization(final GetGadgetsByGadgetDefAndConsumerKey inVerifyMapper); @Override void authorize(final PrincipalActionContext inActionContext); }
OAuthRequestAuthorization implements AuthorizationStrategy<PrincipalActionContext> { @Override public void authorize(final PrincipalActionContext inActionContext) throws AuthorizationException { String consumerKey = (String) inActionContext.getParams(); Long gadgetCount = verifyMapper.execute(new GetGadgetsByGadgetDefAndConsumerKeyRequest(consumerKey, inActionContext.getPrincipal().getId())); if (gadgetCount <= 0) { throw new AuthorizationException("The user supplied with this OAuth request does not have the app " + "associated with this consumer key installed on their start page."); } } OAuthRequestAuthorization(final GetGadgetsByGadgetDefAndConsumerKey inVerifyMapper); @Override void authorize(final PrincipalActionContext inActionContext);  }