public void updateIncomingConfig(@Nonnull ApplicationLink applink, @Nonnull OAuthConfig incoming) throws ConsumerInformationUnavailableException { checkNotNull(applink, "applink"); checkNotNull(incoming, "incoming"); if (!incoming.isEnabled()) { try { serviceProviderStoreService.removeConsumer(applink); } catch (IllegalStateException e) { log.debug("Attempting to remove non-existing consumer for Application Link '{}'", applink); log.trace("Stack trace for link '{}'", applink, e); } } else { Consumer updatedConsumer = consumerBuilder(getOrFetchConsumer(applink)) .twoLOAllowed(incoming.isTwoLoEnabled()) .twoLOImpersonationAllowed(incoming.isTwoLoImpersonationEnabled()) .build(); serviceProviderStoreService.addConsumer(updatedConsumer, applink); } }
.twoLOAllowed(twoLOAllowed).executingTwoLOUser(executingTwoLOUser).twoLOImpersonationAllowed(twoLOImpersonationAllowed) .build(); providerStoreService.addConsumer(consumer, applicationLink);
.signatureMethod(consumer.getSignatureMethod()) .callback(consumer.getCallback()) .twoLOAllowed(twoLoEnabled)
.publicKey(publicKey) .description("Hardcoded 2LO Consumer") .twoLOAllowed(true) .executingTwoLOUser("barney") .build(); .description("Hardcoded 2LO Consumer") .threeLOAllowed(false) .twoLOAllowed(true) .executingTwoLOUser("barney") .build(); .publicKey(publicKey) .description("Hardcoded 2LO Consumer with bad executing user") .twoLOAllowed(true) .executingTwoLOUser("does_not_exist_user") .build(); .publicKey(publicKey) .description("Hardcoded 2LO Consumer with bad executing user") .twoLOAllowed(true) .executingTwoLOUser(null) .build(); .publicKey(publicKey) .description("Hardcoded 2LO with Impersonation Consumer") .twoLOAllowed(true) .executingTwoLOUser("barney") .twoLOImpersonationAllowed(true)
.signatureMethod(consumer.getSignatureMethod()) .callback(consumer.getCallback()) .twoLOAllowed(consumerEntity.isTwoLOAllowed()) .executingTwoLOUser(consumerEntity.getExecutingTwoLOUser()) .twoLOImpersonationAllowed(consumerEntity.isTwoLOImpersonationAllowed()) .signatureMethod(consumer.getSignatureMethod()) .callback(consumer.getCallback()) .twoLOAllowed(consumerEntity.isTwoLOAllowed()) .executingTwoLOUser(consumerEntity.getExecutingTwoLOUser()) .twoLOImpersonationAllowed(consumerEntity.isTwoLOImpersonationAllowed())
.signatureMethod(Consumer.SignatureMethod.HMAC_SHA1) .callback(new URI("http://callback.com")) .twoLOAllowed(options.add2LO) .executingTwoLOUser("2LOuser") .twoLOImpersonationAllowed(options.add2LOi)
.description("Consumer Description") .callback(URI.create(appProp.getBaseUrl() + "/consumer/oauthcallback1")) .twoLOAllowed(true) .executingTwoLOUser("2lo_user") .twoLOImpersonationAllowed(true) .description("Consumer Description") .callback(URI.create(appProp.getBaseUrl() + "/consumer/oauthcallback1")) .twoLOAllowed(false) .executingTwoLOUser("2lo_user_changed") .twoLOImpersonationAllowed(false)
@Test public void testServiceProviderConsumerStoreCanStoreConsumerWith2LOEnabledIndependently() throws Exception { PublicKey publicKey = RSAKeys.fromPemEncodingToPublicKey(CONSUMER_PUBLIC_KEY); final Consumer consumer = Consumer.key(CONSUMER_KEY) .name("Test Consumer Name") .publicKey(publicKey) .description("Consumer Description") .callback(URI.create(appProp.getBaseUrl() + "/consumer/oauthcallback1")) .threeLOAllowed(false) .twoLOAllowed(true) .build(); consumerStore.put(consumer); final Consumer savedConsumer = consumerStore.get(CONSUMER_KEY); assertFalse(savedConsumer.getThreeLOAllowed()); assertTrue(savedConsumer.getTwoLOAllowed()); assertFalse(savedConsumer.getTwoLOImpersonationAllowed()); }
@Test public void testServiceProviderConsumerStoreCanStoreOAuth2LOConfiguration() throws Exception { PublicKey publicKey = RSAKeys.fromPemEncodingToPublicKey(CONSUMER_PUBLIC_KEY); final Consumer consumer = Consumer.key(CONSUMER_KEY) .name("Test Consumer Name") .publicKey(publicKey) .description("Consumer Description") .callback(URI.create(appProp.getBaseUrl() + "/consumer/oauthcallback1")) .twoLOAllowed(true) .executingTwoLOUser("2lo_user") .build(); consumerStore.put(consumer); final Consumer savedConsumer = consumerStore.get(CONSUMER_KEY); assertTrue(savedConsumer.getTwoLOAllowed()); assertEquals("2lo_user", savedConsumer.getExecutingTwoLOUser()); }
public static Consumer.InstanceBuilder consumerBuilder(@Nonnull Consumer consumer) { checkNotNull(consumer, "consumer"); Consumer.InstanceBuilder builder = new Consumer.InstanceBuilder(consumer.getKey()) .name(consumer.getName()) .description(consumer.getDescription()) .signatureMethod(consumer.getSignatureMethod()) .callback(consumer.getCallback()) .twoLOAllowed(consumer.getTwoLOAllowed()) .executingTwoLOUser(consumer.getExecutingTwoLOUser()) .twoLOImpersonationAllowed(consumer.getTwoLOImpersonationAllowed()); if (consumer.getPublicKey() != null) { builder.publicKey(consumer.getPublicKey()); } return builder; } }
private void setUpOAuthConsumer() throws Exception { PublicKey publicKey = RSAKeys.fromPemEncodingToPublicKey(CONSUMER_PUBLIC_KEY); Consumer hardcodedConsumer = Consumer.key("hardcoded-consumer") .name("Hardcoded Consumer") .publicKey(publicKey) .description("Hardcoded Consumer") .callback(URI.create(appProp.getBaseUrl() + "/consumer/oauthcallback")) .twoLOAllowed(true) .executingTwoLOUser(infoProvider.getAdminUsername()) .build(); consumerStore.put(hardcodedConsumer); }
public static Consumer createConsumer(boolean threeLo, boolean twoLo, boolean twoLoi) { return Consumer.key(TEST_CONSUMER_KEY) .name(TEST_CONSUMER_NAME) .signatureMethod(Consumer.SignatureMethod.HMAC_SHA1) .threeLOAllowed(threeLo) .twoLOAllowed(twoLo) .twoLOImpersonationAllowed(twoLoi) .build(); }
public static Consumer createRsaConsumer(boolean threeLo, boolean twoLo, boolean twoLoi) { return Consumer.key(TEST_CONSUMER_KEY) .name(TEST_CONSUMER_NAME) .signatureMethod(Consumer.SignatureMethod.RSA_SHA1) .publicKey(TEST_KEYS.getPublic()) .threeLOAllowed(threeLo) .twoLOAllowed(twoLo) .twoLOImpersonationAllowed(twoLoi) .build(); }