1

我正在實施Spring Integration for REST服務。我遵循XPadro的githib示例 - https://github.com/xpadro/spring-integrationSpring集成安全性與REST服務示例

我已經創建了簡單的讀取,寫入和更新操作。 示例取自int-http-dsl項目。

我想用誓言來實現spring-security。我正在參考http://docs.spring.io/spring-integration/reference/html/security.html

我無法將兩者連接在一起。因爲下面是他們是如何映射請求

@Bean 
    public IntegrationFlow httpGetFlow() { 
     return IntegrationFlows.from(httpGetGate()).channel("httpGetChannel").handle("personEndpoint", "get").get(); 
    } 
@Bean 
    public MessagingGatewaySupport httpGetGate() { 
     HttpRequestHandlingMessagingGateway handler = new HttpRequestHandlingMessagingGateway(); 
     handler.setRequestMapping(createMapping(new HttpMethod[]{HttpMethod.GET}, "/persons/{personId}")); 
     handler.setPayloadExpression(parser().parseExpression("#pathVariables.personId")); 
     handler.setHeaderMapper(headerMapper()); 

     return handler; 
    } 

以下是我們如何能夠整合安全

@Bean 
    @SecuredChannel(interceptor = "channelSecurityInterceptor", sendAccess = "ROLE_ADMIN") 
    public SubscribableChannel adminChannel() { 
     return new DirectChannel(); 
    } 

我不能找到一種方法來創建第一個示例通道,因此如何整合這一點。

我正確的方向還是錯了?

有沒有更好的教程來處理spring-integration(http)與spring-security(使用oauth)?

回答

1

Spring集成Java DSL允許使用外部的@Bean作爲流定義中的消息通道。所以,你的httpGetChannel可聲明和使用,如:

@Bean 
@SecuredChannel(interceptor = "channelSecurityInterceptor", sendAccess = "ROLE_ADMIN") 
public SubscribableChannel httpGetChannel() { 
    return new DirectChannel(); 
} 

@Bean 
public IntegrationFlow httpGetFlow() { 
    return IntegrationFlows.from(httpGetGate()) 
        .channel(httpGetChannel()) 
        .handle("personEndpoint", "get") 
        .get(); 
} 

隨意提出一個GitHub的問題在框架的東西直接從DSL的.channel()定義更加明顯,使:https://github.com/spring-projects/spring-integration-java-dsl/issues

相關問題