protected static JSONOAuth2Persister getDummyPersister() throws Exception { final JSONObject configFile = new JSONObject(MockUtils.getJSONString()); return new JSONOAuth2Persister(MockUtils.getDummyEncrypter(), MockUtils.getDummyAuthority(), MockUtils.REDIRECT_URI, "xxx", configFile); }
protected static JSONOAuth2Persister getDummyPersister() throws Exception { final JSONObject configFile = new JSONObject(MockUtils.getJSONString()); return new JSONOAuth2Persister(MockUtils.getDummyEncrypter(), MockUtils.getDummyAuthority(), MockUtils.REDIRECT_URI, "xxx", configFile); }
protected static OAuth2TokenPersistence getAccessToken() throws Exception { final OAuth2TokenPersistence accessToken = new OAuth2TokenPersistence( MockUtils.getDummyEncrypter()); MockUtils.setTokenCommons(accessToken); accessToken.setType(OAuth2Token.Type.ACCESS); return accessToken; }
protected static OAuth2TokenPersistence getAccessToken() throws Exception { final OAuth2TokenPersistence accessToken = new OAuth2TokenPersistence( MockUtils.getDummyEncrypter()); MockUtils.setTokenCommons(accessToken); accessToken.setType(OAuth2Token.Type.ACCESS); return accessToken; }
@Test public void testGetEncrypter_1() throws Exception { final OAuth2Encrypter result = OAuth2ClientTest.client1.getEncrypter(); Assert.assertNotNull(result); Assert.assertEquals(MockUtils.getDummyEncrypter(), result); }
@Test public void testGetEncrypter_1() throws Exception { final OAuth2Encrypter result = OAuth2ClientTest.client1.getEncrypter(); Assert.assertNotNull(result); Assert.assertEquals(MockUtils.getDummyEncrypter(), result); }
protected static OAuth2TokenPersistence getMacToken() throws Exception { final OAuth2TokenPersistence accessToken = new OAuth2TokenPersistence( MockUtils.getDummyEncrypter()); MockUtils.setTokenCommons(accessToken); accessToken.setMacAlgorithm(OAuth2Message.HMAC_SHA_1); accessToken.setMacExt("1 2 3"); accessToken.setMacSecret(MockUtils.MAC_SECRET.getBytes("UTF-8")); accessToken.setTokenType(OAuth2Message.MAC_TOKEN_TYPE); accessToken.setType(OAuth2Token.Type.ACCESS); return accessToken; }
protected static OAuth2TokenPersistence getBadMacToken() throws Exception { final OAuth2TokenPersistence accessToken = new OAuth2TokenPersistence( MockUtils.getDummyEncrypter()); MockUtils.setTokenCommons(accessToken); accessToken.setMacAlgorithm(OAuth2Message.HMAC_SHA_256); accessToken.setMacExt("1 2 3"); accessToken.setMacSecret(MockUtils.MAC_SECRET.getBytes("UTF-8")); accessToken.setTokenType(OAuth2Message.MAC_TOKEN_TYPE); accessToken.setType(OAuth2Token.Type.ACCESS); return accessToken; }
protected static OAuth2TokenPersistence getMacToken() throws Exception { final OAuth2TokenPersistence accessToken = new OAuth2TokenPersistence( MockUtils.getDummyEncrypter()); MockUtils.setTokenCommons(accessToken); accessToken.setMacAlgorithm(OAuth2Message.HMAC_SHA_1); accessToken.setMacExt("1 2 3"); accessToken.setMacSecret(MockUtils.MAC_SECRET.getBytes("UTF-8")); accessToken.setTokenType(OAuth2Message.MAC_TOKEN_TYPE); accessToken.setType(OAuth2Token.Type.ACCESS); return accessToken; }
protected static OAuth2TokenPersistence getBadMacToken() throws Exception { final OAuth2TokenPersistence accessToken = new OAuth2TokenPersistence( MockUtils.getDummyEncrypter()); MockUtils.setTokenCommons(accessToken); accessToken.setMacAlgorithm(OAuth2Message.HMAC_SHA_256); accessToken.setMacExt("1 2 3"); accessToken.setMacSecret(MockUtils.MAC_SECRET.getBytes("UTF-8")); accessToken.setTokenType(OAuth2Message.MAC_TOKEN_TYPE); accessToken.setType(OAuth2Token.Type.ACCESS); return accessToken; }
protected static OAuth2Accessor getOAuth2Accessor_ClientCredentialsRedirecting() throws Exception { final OAuth2Cache cache = new InMemoryCache(); final OAuth2Persister persister = MockUtils.getDummyPersister(); final OAuth2Encrypter encrypter = MockUtils.getDummyEncrypter(); final OAuth2Store store = MockUtils.getDummyStore(cache, persister, encrypter, MockUtils.REDIRECT_URI, null, null, MockUtils.stateCrypter); final BasicOAuth2Accessor accessor = new BasicOAuth2Accessor(MockUtils.GADGET_URI1, MockUtils.SERVICE_NAME, MockUtils.USER, MockUtils.SCOPE, true, store, MockUtils.REDIRECT_URI, null, null); accessor.setGrantType(OAuth2Message.CLIENT_CREDENTIALS); accessor.setRedirecting(Boolean.TRUE); return accessor; }
protected static OAuth2Store getDummyStore() throws Exception { if (MockUtils.dummyStore == null) { final OAuth2Cache cache = new InMemoryCache(); final OAuth2Persister persister = MockUtils.getDummyPersister(); final OAuth2Encrypter encrypter = MockUtils.getDummyEncrypter(); final BlobCrypter stateCrypter = MockUtils.getDummyStateCrypter(); MockUtils.dummyStore = MockUtils.getDummyStore(cache, persister, encrypter, MockUtils.REDIRECT_URI, null, null, stateCrypter); } MockUtils.dummyStore.clearCache(); MockUtils.dummyStore.init(); return MockUtils.dummyStore; }
protected static OAuth2Accessor getOAuth2Accessor_ClientCredentialsRedirecting() throws Exception { final OAuth2Cache cache = new InMemoryCache(); final OAuth2Persister persister = MockUtils.getDummyPersister(); final OAuth2Encrypter encrypter = MockUtils.getDummyEncrypter(); final OAuth2Store store = MockUtils.getDummyStore(cache, persister, encrypter, MockUtils.REDIRECT_URI, null, null, MockUtils.stateCrypter); final BasicOAuth2Accessor accessor = new BasicOAuth2Accessor(MockUtils.GADGET_URI1, MockUtils.SERVICE_NAME, MockUtils.USER, MockUtils.SCOPE, true, store, MockUtils.REDIRECT_URI, null, null); accessor.setGrantType(OAuth2Message.CLIENT_CREDENTIALS); accessor.setRedirecting(Boolean.TRUE); return accessor; }
protected static OAuth2Store getDummyStore() throws Exception { if (MockUtils.dummyStore == null) { final OAuth2Cache cache = new InMemoryCache(); final OAuth2Persister persister = MockUtils.getDummyPersister(); final OAuth2Encrypter encrypter = MockUtils.getDummyEncrypter(); final BlobCrypter stateCrypter = MockUtils.getDummyStateCrypter(); MockUtils.dummyStore = MockUtils.getDummyStore(cache, persister, encrypter, MockUtils.REDIRECT_URI, null, null, stateCrypter); } MockUtils.dummyStore.clearCache(); MockUtils.dummyStore.init(); return MockUtils.dummyStore; }
protected static OAuth2Client getClient_Code_Confidential() throws Exception { final OAuth2Client client = new OAuth2Client(MockUtils.getDummyEncrypter()); MockUtils.setClientCommons(client); client.setClientAuthenticationType(OAuth2Message.BASIC_AUTH_TYPE); client.setClientId(MockUtils.CLIENT_ID1); client.setClientSecret(MockUtils.CLIENT_SECRET1.getBytes("UTF-8")); client.setGadgetUri(MockUtils.GADGET_URI1); client.setType(OAuth2Accessor.Type.CONFIDENTIAL); client.setAllowModuleOverride(true); client.setAuthorizationHeader(true); client.setUrlParameter(false); return client; }
protected static OAuth2Client getClient_Code_Confidential() throws Exception { final OAuth2Client client = new OAuth2Client(MockUtils.getDummyEncrypter()); MockUtils.setClientCommons(client); client.setClientAuthenticationType(OAuth2Message.BASIC_AUTH_TYPE); client.setClientId(MockUtils.CLIENT_ID1); client.setClientSecret(MockUtils.CLIENT_SECRET1.getBytes("UTF-8")); client.setGadgetUri(MockUtils.GADGET_URI1); client.setType(OAuth2Accessor.Type.CONFIDENTIAL); client.setAllowModuleOverride(true); client.setAuthorizationHeader(true); client.setUrlParameter(false); return client; }
protected static OAuth2Client getClient_Code_Public() throws Exception { final OAuth2Client client = new OAuth2Client(MockUtils.getDummyEncrypter()); MockUtils.setClientCommons(client); client.setClientAuthenticationType(OAuth2Message.STANDARD_AUTH_TYPE); client.setClientId(MockUtils.CLIENT_ID2); client.setClientSecret(MockUtils.CLIENT_SECRET2.getBytes("UTF-8")); client.setGadgetUri(MockUtils.GADGET_URI2); client.setType(OAuth2Accessor.Type.PUBLIC); client.setAllowModuleOverride(false); client.setAuthorizationHeader(false); client.setUrlParameter(true); return client; }
protected static OAuth2Client getClient_Code_Public() throws Exception { final OAuth2Client client = new OAuth2Client(MockUtils.getDummyEncrypter()); MockUtils.setClientCommons(client); client.setClientAuthenticationType(OAuth2Message.STANDARD_AUTH_TYPE); client.setClientId(MockUtils.CLIENT_ID2); client.setClientSecret(MockUtils.CLIENT_SECRET2.getBytes("UTF-8")); client.setGadgetUri(MockUtils.GADGET_URI2); client.setType(OAuth2Accessor.Type.PUBLIC); client.setAllowModuleOverride(false); client.setAuthorizationHeader(false); client.setUrlParameter(true); return client; }
@Test public void testStoreClient_1() throws Exception { OAuth2Client client = new OAuth2Client(MockUtils.getDummyEncrypter()); client.setGadgetUri("xxx"); client.setServiceName("yyy"); this.cache.storeClient(client); client = this.cache.getClient(client.getGadgetUri(), client.getServiceName()); Assert.assertNotNull(client); Assert.assertEquals("xxx", client.getGadgetUri()); Assert.assertEquals("yyy", client.getServiceName()); }
@Test public void testStoreClient_1() throws Exception { OAuth2Client client = new OAuth2Client(MockUtils.getDummyEncrypter()); client.setGadgetUri("xxx"); client.setServiceName("yyy"); this.cache.storeClient(client); client = this.cache.getClient(client.getGadgetUri(), client.getServiceName()); Assert.assertNotNull(client); Assert.assertEquals("xxx", client.getGadgetUri()); Assert.assertEquals("yyy", client.getServiceName()); }