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);
.twoLOImpersonationAllowed(twoLoIEnabled) .build();
.twoLOAllowed(true) .executingTwoLOUser("barney") .twoLOImpersonationAllowed(true) .build(); consumerStore.put(hardcoded2LOImpersonationConsumer); .twoLOAllowed(false) .executingTwoLOUser("barney") .twoLOImpersonationAllowed(true) .build(); consumerStore.put(hardcoded2LOImpersonationOnlyConsumer);
.twoLOAllowed(consumerEntity.isTwoLOAllowed()) .executingTwoLOUser(consumerEntity.getExecutingTwoLOUser()) .twoLOImpersonationAllowed(consumerEntity.isTwoLOImpersonationAllowed()) .build(); .twoLOAllowed(consumerEntity.isTwoLOAllowed()) .executingTwoLOUser(consumerEntity.getExecutingTwoLOUser()) .twoLOImpersonationAllowed(consumerEntity.isTwoLOImpersonationAllowed()) .build();
.twoLOAllowed(options.add2LO) .executingTwoLOUser("2LOuser") .twoLOImpersonationAllowed(options.add2LOi) .build(); serviceProviderConsumerStore.put(updatedConsumer);
.twoLOAllowed(true) .executingTwoLOUser("2lo_user") .twoLOImpersonationAllowed(true) .build(); consumerStore.put(consumer); .twoLOAllowed(false) .executingTwoLOUser("2lo_user_changed") .twoLOImpersonationAllowed(false) .build(); consumerStore.put(consumer2);
@Test public void testServiceProviderConsumerStoreCanStoreConsumerWith2LOWithImpersonationEnabledIndependently() 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) .twoLOImpersonationAllowed(true) .build(); consumerStore.put(consumer); final Consumer savedConsumer = consumerStore.get(CONSUMER_KEY); assertFalse(savedConsumer.getThreeLOAllowed()); assertFalse(savedConsumer.getTwoLOAllowed()); assertTrue(savedConsumer.getTwoLOImpersonationAllowed()); }
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; } }
@Test public void testServiceProviderConsumerStoreCanStoreOAuth2LOImpersonationConfiguration() 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")) .twoLOImpersonationAllowed(true) .build(); consumerStore.put(consumer); final Consumer savedConsumer = consumerStore.get(CONSUMER_KEY); assertTrue(savedConsumer.getTwoLOImpersonationAllowed()); }
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(); }