.description(consumer.getDescription()) .publicKey(consumer.getPublicKey()) .signatureMethod(consumer.getSignatureMethod()) .callback(consumer.getCallback()) .twoLOAllowed(twoLoEnabled)
/** * Converts an {@code OAuthConsumer} to a {@code Consumer}. * * @param consumer {@code OAuthConsumer} to convert to a {@code Consumer} * @return {@code Consumer} converted from the {@code OAuthConsumer} */ public static Consumer fromOAuthConsumer(OAuthConsumer consumer) { checkNotNull(consumer, "consumer"); String name = (String) consumer.getProperty(ConsumerProperty.NAME); URI callback = consumer.callbackURL != null ? URI.create(consumer.callbackURL) : null; String description = (String) consumer.getProperty(ConsumerProperty.DESCRIPTION); InstanceBuilder builder = Consumer.key(consumer.consumerKey).name(name).description(description).callback(callback); if (consumer.getProperty(OAuth.OAUTH_SIGNATURE_METHOD).equals(OAuth.HMAC_SHA1)) { builder.signatureMethod(SignatureMethod.HMAC_SHA1); } else { // we could check if it's a string or byte[] and do the conversion, but for now let's keep things simple PublicKey publicKey = (PublicKey) consumer.getProperty(RSA_SHA1.PUBLIC_KEY); builder.publicKey(publicKey); } return builder.build(); }
.description("consumerdesc-" + options.id) .publicKey(publickey) .signatureMethod(Consumer.SignatureMethod.HMAC_SHA1) .callback(new URI("http://callback.com")) .twoLOAllowed(options.add2LO)
.description(consumer.getDescription()) .publicKey(consumer.getPublicKey()) .signatureMethod(consumer.getSignatureMethod()) .callback(consumer.getCallback()) .twoLOAllowed(consumerEntity.isTwoLOAllowed()) .description(consumer.getDescription()) .publicKey(consumer.getPublicKey()) .signatureMethod(consumer.getSignatureMethod()) .callback(consumer.getCallback()) .twoLOAllowed(consumerEntity.isTwoLOAllowed())
final Consumer consumer = Consumer.key(consumerKey) .name(name) .signatureMethod(Consumer.SignatureMethod.HMAC_SHA1) .description(description) .build();
public Consumer updateHostConsumerInformation(String name, String description, URI callback) { ConsumerAndSecret cas = hostCasProvider.get(); Consumer oldConsumer = cas.getConsumer(); Consumer newConsumer = Consumer.key(oldConsumer.getKey()) .signatureMethod(oldConsumer.getSignatureMethod()) .publicKey(oldConsumer.getPublicKey()) .name(name) .description(description) .callback(callback) .build(); if (newConsumer.getSignatureMethod() == SignatureMethod.HMAC_SHA1) { cas = new ConsumerAndSecret(cas.getServiceName(), newConsumer, cas.getSharedSecret()); } else { cas = new ConsumerAndSecret(cas.getServiceName(), newConsumer, cas.getPrivateKey()); } return hostCasProvider.put(cas).getConsumer(); }
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; } }
/** * Add an Outgoing Consumer for a 3rdParty link. */ private Consumer add3rdPartyOutgoingConsumer(final ConsumerEntity consumerEntity) { final Consumer consumer = Consumer.key(consumerEntity.getKey()) .name(consumerEntity.getName()) .signatureMethod(Consumer.SignatureMethod.HMAC_SHA1) .description(consumerEntity.getDescription()) .build(); consumerService.add(consumer.getName(), consumer, consumerEntity.getSharedSecret()); return consumer; }
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(); }