private static X509Certificate getReqSigCert ( Message message ) { List < WSHandlerResult > results = CastUtils . cast ( ( List < ? > ) message . getExchange ( ) . getInMessage ( ) . get ( WSHandlerConstants . RECV_RESULTS ) ) ; if ( results == null ) { return null ; } /* * Scan the results for a matching actor. Use results only if the * receiving Actor and the sending Actor match. */ for ( WSHandlerResult rResult : results ) { List < WSSecurityEngineResult > wsSecEngineResults = rResult . getResults ( ) ; /* * Scan the results for the first Signature action. Use the * certificate of this Signature to set the certificate for the * encryption action :-). */ for ( WSSecurityEngineResult wser : wsSecEngineResults ) { Integer actInt = ( Integer ) wser . get ( WSSecurityEngineResult . TAG_ACTION ) ; if ( actInt . intValue ( ) == WSConstants . SIGN ) { return ( X509Certificate ) wser . get ( WSSecurityEngineResult . TAG_X509_CERTIFICATE ) ; } } } return null ; }
Refactor the method into public CXF utility and reuse it from CXF instead copy&paste