0
votes

I am a little new to Spring-Integration and have been trying to POC some simple tasks. Having never touched OAuth at all and having a rest service with OAuth required I am hoping someone could show me an example of using OAuth with the Java DSL. I am currently taking a message from Rabbit and transforming to a JAVA POJO then sending it to a new channel to be posted to Rest service, but I need to authenticate against the server first. As I said new to SI and to OAuth and looking for a few pointers. I just can't seem to find anything on DSL with OAuth


    @Bean
    public IntegrationFlow amqpInboundGateway(ConnectionFactory connectionFactory, @Value("${rabbitmq.queue}") String queue) {
        return IntegrationFlows.from(Amqp.inboundGateway(connectionFactory, queue))
                .transform(Transformers.toJson())
                .transform(Transformers.fromJson(Call.class))
                .log(message -> message.getPayload())
                .channel("rabbitOutput")
                .get();
    }

    @Bean
    public IntegrationFlow httpPostAtms( @Value("${alemba.incident.get}") String uri) {

        return IntegrationFlows.from("rabbitOutput")
                .handle(Http.outboundGateway(uri)
                        .httpMethod(HttpMethod.POST)
                        .extractPayload(true))
                .transform(Transformers.toJson())
                .log()
                .get();

    }

1

1 Answers

1
votes

I'm not familiar with OAuth, but Http.outboundGateway() can be configured with an external RestTemplate, which could be customized any possible way. Please, learn more about OAuth in Spring Security: https://docs.spring.io/spring-security/site/docs/5.2.1.RELEASE/reference/htmlsingle/#oauth2. There is just nothing to do on the matter in Spring Integration: fully not this project responsibility