You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2012/04/06 11:03:37 UTC

svn commit: r1310249 - in /camel/trunk: camel-core/src/main/java/org/apache/camel/util/ExchangeHelper.java components/camel-shiro/src/main/java/org/apache/camel/component/shiro/security/ShiroSecurityPolicy.java

Author: davsclaus
Date: Fri Apr  6 09:03:37 2012
New Revision: 1310249

URL: http://svn.apache.org/viewvc?rev=1310249&view=rev
Log:
Polished

Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/util/ExchangeHelper.java
    camel/trunk/components/camel-shiro/src/main/java/org/apache/camel/component/shiro/security/ShiroSecurityPolicy.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/util/ExchangeHelper.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ExchangeHelper.java?rev=1310249&r1=1310248&r2=1310249&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/util/ExchangeHelper.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/util/ExchangeHelper.java Fri Apr  6 09:03:37 2012
@@ -94,10 +94,10 @@ public final class ExchangeHelper {
         throw new NoSuchPropertyException(exchange, propertyName, type);
     }
 
-    public static <T> T getMandatoryHeader(Exchange exchange, String propertyName, Class<T> type) throws NoSuchHeaderException {
-        T answer = exchange.getIn().getHeader(propertyName, type);
+    public static <T> T getMandatoryHeader(Exchange exchange, String headerName, Class<T> type) throws NoSuchHeaderException {
+        T answer = exchange.getIn().getHeader(headerName, type);
         if (answer == null) {
-            throw new NoSuchHeaderException(exchange, propertyName, type);
+            throw new NoSuchHeaderException(exchange, headerName, type);
         }
         return answer;
     }

Modified: camel/trunk/components/camel-shiro/src/main/java/org/apache/camel/component/shiro/security/ShiroSecurityPolicy.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-shiro/src/main/java/org/apache/camel/component/shiro/security/ShiroSecurityPolicy.java?rev=1310249&r1=1310248&r2=1310249&view=diff
==============================================================================
--- camel/trunk/components/camel-shiro/src/main/java/org/apache/camel/component/shiro/security/ShiroSecurityPolicy.java (original)
+++ camel/trunk/components/camel-shiro/src/main/java/org/apache/camel/component/shiro/security/ShiroSecurityPolicy.java Fri Apr  6 09:03:37 2012
@@ -31,6 +31,7 @@ import org.apache.camel.spi.Authorizatio
 import org.apache.camel.spi.RouteContext;
 import org.apache.camel.util.AsyncProcessorConverterHelper;
 import org.apache.camel.util.AsyncProcessorHelper;
+import org.apache.camel.util.ExchangeHelper;
 import org.apache.camel.util.IOHelper;
 import org.apache.shiro.SecurityUtils;
 import org.apache.shiro.authc.AuthenticationException;
@@ -161,7 +162,7 @@ public class ShiroSecurityPolicy impleme
             }
             
             private void applySecurityPolicy(Exchange exchange) throws Exception {
-                ByteSource encryptedToken = (ByteSource)exchange.getIn().getHeader("SHIRO_SECURITY_TOKEN");
+                ByteSource encryptedToken = ExchangeHelper.getMandatoryHeader(exchange, "SHIRO_SECURITY_TOKEN", ByteSource.class);
                 ByteSource decryptedToken = getCipherService().decrypt(encryptedToken.getBytes(), getPassPhrase());
                 
                 ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(decryptedToken.getBytes());