302.8. ShiroSecurityPolicy에 의해 보안이 설정된 경로에 메시지 보내기 ( Camel 2.12 이후 더 쉽게)

Camel 2.12 부터 두 가지 방법으로 주제를 제공할 수 있기 때문에 훨씬 쉽습니다.

302.8.1. Using ShiroSecurityToken

사용자 이름과 암호를 포함하는 org.apache.camel.component.sh iromel.shiroSecurityToken의 키 ShiroConstants. SHIRO_SECURITY_TOKEN 으로 Camel 경로에 메시지를 보낼 수 있습니다. 예를 들면 다음과 같습니다.

        ShiroSecurityToken shiroSecurityToken = new ShiroSecurityToken("ringo", "starr");

        template.sendBodyAndHeader("direct:secureEndpoint", "Beatle Mania", ShiroSecurityConstants.SHIRO_SECURITY_TOKEN, shiroSecurityToken);

다음과 같이 두 개의 다른 헤더에 사용자 이름과 암호를 지정할 수도 있습니다.

        Map<String, Object> headers = new HashMap<String, Object>();
        headers.put(ShiroSecurityConstants.SHIRO_SECURITY_USERNAME, "ringo");
        headers.put(ShiroSecurityConstants.SHIRO_SECURITY_PASSWORD, "starr");
        template.sendBodyAndHeaders("direct:secureEndpoint", "Beatle Mania", headers);

사용자 이름 및 암호 헤더를 사용하면 Camel 경로의 ShiroSecurityPolicy가 주요 ShiroSecurityConstants.SHIRO_SECURITY_TOKEN과 함께 자동으로 단일 헤더로 변환됩니다. 그런 다음 토큰은 ShiroSecurityToken 인스턴스 또는 base64 표현 역할을 String으로 나타냅니다 (이 후자는 base64=true를 설정한 경우입니다).