Problem in WSSecurityHandler with keystore property
---------------------------------------------------

                 Key: SM-947
                 URL: https://issues.apache.org/activemq/browse/SM-947
             Project: ServiceMix
          Issue Type: Bug
          Components: servicemix-soap
    Affects Versions: 3.1
         Environment: apache-servicemix-3.1
            Reporter: Jorge Rodríguez Pedrianes
            Priority: Minor


Hello,  When I use WS-Security and I have configured KEYSTORE_MANAGER but i 
don´t put the keystore property, this throw a NullPointerException. 

{noformat} 
java.lang.NullPointerException
        at 
org.apache.servicemix.jbi.security.keystore.impl.BaseKeystoreManager.getKeystore(BaseKeystoreManager.java:253)
        at 
org.apache.servicemix.soap.handlers.security.KeystoreInstanceCrypto.<init>(KeystoreInstanceCrypto.java:41)
        at 
org.apache.servicemix.soap.handlers.security.WSSecurityHandler.init(WSSecurityHandler.java:568)
        at 
org.apache.servicemix.soap.handlers.security.WSSecurityHandler.onReceive(WSSecurityHandler.java:292)
        at org.apache.servicemix.soap.SoapHelper.onReceive(SoapHelper.java:111)
        at 
org.apache.servicemix.http.processors.ConsumerProcessor.process(ConsumerProcessor.java:177)
        at 
org.apache.servicemix.http.HttpBridgeServlet.doPost(HttpBridgeServlet.java:71)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
        at 
org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:445)
        at 
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:356)
        at 
org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:627)
        at 
org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:149)
        at 
org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:123)
        at 
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:141)
        at org.mortbay.jetty.Server.handle(Server.java:269)
        at 
org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:430)
        at 
org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:701)
        at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:617)
        at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:199)
        at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:339)
        at 
org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:208)
        at 
org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:475)
{noformat} 

I see the documentation example, and in this example dont't use this property, 
but if i don't use throw a exception. I Think that to avoid this is better add
a condition in init method of WSSecurityHandler like:

{noformat} 
  protected void init(Context context) {
        currentSubject.set(null);
        if (context.getProperty(Context.AUTHENTICATION_SERVICE) != null) {
            setAuthenticationService((AuthenticationService) 
context.getProperty(Context.AUTHENTICATION_SERVICE));
        }
        if (crypto == null && context.getProperty(Context.KEYSTORE_MANAGER) != 
null
             && keystore != null   // <------- New Condition
            ) {
            KeystoreManager km = (KeystoreManager) 
context.getProperty(Context.KEYSTORE_MANAGER);
            setCrypto(new KeystoreInstanceCrypto(km, keystore));
        }
    }
{noformat} 

Thanks
       Jorge Rodríguez Pedrianes

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to