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(); }
private Map<String, Iterable<String>> getParameterMap() { if (parameterMap == null) { parameterMap = makeUnmodifiableMap(makeParameterMap()); } return parameterMap; }
/** * Creates a new {@code TokenProperties} instance using the attributes of the {@code Token} as property values. */ public TokenProperties(Token token) { putToken(token.getToken()); putTokenSecret(token.getTokenSecret()); putTokenType(token.isAccessToken() ? TokenType.ACCESS : TokenType.REQUEST); putConsumerKey(token.getConsumer().getKey()); if (!token.getProperties().isEmpty()) { putProperties(token.getProperties()); } }
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; } }
/** * Create a basic Consumer for the specified ApplicationLink */ private Consumer createBasicConsumer(final ConsumerEntity consumerEntity, ApplicationLink applicationLink) throws InvalidKeySpecException, NoSuchAlgorithmException, URISyntaxException { return Consumer.key(consumerEntity.getKey()) .name(consumerEntity.getName()) .publicKey(RSAKeys.fromPemEncodingToPublicKey(consumerEntity.getPublicKey())) .description(consumerEntity.getDescription()) .callback(consumerEntity.getCallback()) .build(); }
/** * 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; }
private String getHostClientKey() { return consumerService.getConsumer().getKey(); }
/** * Additional descriptive text about the consumer application. */ public String getDescription() { return token.getConsumer().getDescription(); }
/** * The human-readable name of the consumer application. */ public String getConsumerName() { if (token.hasProperty("alternate.consumer.name")) { return token.getProperty("alternate.consumer.name"); } return token.getConsumer().getName(); }
public static boolean isOAuthPluginInstalled(final ApplicationLink applicationLink) { final boolean oAuthPluginInstalled = false; try { final Consumer consumer = fetchConsumerInformation(applicationLink); return consumer.getKey() != null; } catch (ResponseException e) { //ignored } return oAuthPluginInstalled; }
public boolean incomingEnabled(final ApplicationLink applicationLink) { final Consumer consumer = serviceProviderStoreService.getConsumer(applicationLink); return consumer != null && consumer.getTwoLOAllowed() && consumer.getTwoLOImpersonationAllowed(); }
/** * Static factory method that starts the process of building a {@code Consumer} instance. Returns an * {@code InstanceBuilder} so the other attribute can be set. * * @param key unique key used to identify the consumer in requests unauthorized OAuth request tokens * @return the builder for constructing the rest of the {@code Consumer} instance */ public static InstanceBuilder key(String key) { return new InstanceBuilder(checkNotNull(key, "key")); }
public boolean incomingEnabled(final ApplicationLink applicationLink) { final Consumer consumer = serviceProviderStoreService.getConsumer(applicationLink); return consumer != null && consumer.getTwoLOAllowed(); }
public static ServiceProvider getServiceProvider(final URI rpcUrl, final URI displayUrl) { final URI requestTokenUri = uncheckedConcatenate(rpcUrl, "/plugins/servlet/oauth/request-token"); final URI authorizeTokenUri = uncheckedConcatenate(displayUrl, "/plugins/servlet/oauth/authorize"); final URI accessTokenUri = uncheckedConcatenate(rpcUrl, "/plugins/servlet/oauth/access-token"); return new ServiceProvider(requestTokenUri, authorizeTokenUri, accessTokenUri); }
public Request(HttpMethod method, URI uri, Iterable<Parameter> parameters) { this.method = checkNotNull(method, "method"); this.uri = checkNotNull(uri, "uri"); this.parameters = copy(parameters); }
/** * Constructs and returns the final{@code Consumer} instance. * * @return the final {@code Consumer} instance */ public Consumer build() { checkNotNull(name, "name"); checkNotNull(signatureMethod, "signatureMethod"); if (signatureMethod == SignatureMethod.RSA_SHA1) { checkNotNull(publicKey, "publicKey must be set when the signature method is RSA-SHA1"); } return new Consumer(this); } }
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(); }
/** * Convert a given {@code consumerInfo} to a {@link com.atlassian.oauth.Consumer} * * @param consumerInfo the {@link com.marvelution.jenkins.plugins.jira.model.ConsumerInfo} to convert * @return the {@link com.atlassian.oauth.Consumer} * @throws InvalidKeySpecException * @throws NoSuchAlgorithmException */ public static Consumer toConsumer(ConsumerInfo consumerInfo) throws InvalidKeySpecException, NoSuchAlgorithmException { return Consumer.key(consumerInfo.getKey()).name(consumerInfo.getName()).description(consumerInfo.getDescription()) .publicKey(RSAKeys.fromPemEncodingToPublicKey(consumerInfo.getPublicKey())).build(); }
@Override public void marshal(Object value, HierarchicalStreamWriter writer, MarshallingContext context) { writer.setValue(((Consumer) value).getKey()); }