/** * Create a {@link WSSecurityEngine} by default. */ public Wss4jSecurityInterceptor() { this.securityEngine = new WSSecurityEngine(); }
/** * Create a {@link WSSecurityEngine} by default. */ public Wss4jSecurityInterceptor() { this.securityEngine = new WSSecurityEngine(); }
/** * Create a {@link WSSecurityEngine} by default. */ public Wss4jSecurityInterceptor() { this.securityEngine = new WSSecurityEngine(); }
WSSecurityEngine secEngine = new WSSecurityEngine(); WSSConfig wsConfig = WSSConfig.newInstance(); wsConfig.setProcessor(UsernameToken.TOKEN, new Processor() { @Override public void handleToken(Element arg0, Crypto arg1, Crypto arg2, CallbackHandler arg3, WSDocInfo arg4, Vector arg5, WSSConfig arg6) throws WSSecurityException { // skip the token processing logger.debug("Skipping processing of the username token"); } @Override public String getId() { return null; } }); secEngine.setWssConfig(wsConfig);
SOAPMessage soapMessage = MessageFactory.newInstance().createMessage(null, new ByteArrayInputStream(soapRequest.getBytes())); FileInputStream is = new FileInputStream(keyStore); KeyPair keypair = null; KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType()); keystore.load(is, keyStorePwd.toCharArray()); Certificate cert = null; Key key = keystore.getKey(alias, keyStorePwd.toCharArray()); if (key instanceof PrivateKey) { cert = keystore.getCertificate(alias); PublicKey publicKey = cert.getPublicKey(); keypair = new KeyPair(publicKey, (PrivateKey) key); } Properties properties = new Properties(); properties.setProperty("org.apache.ws.security.crypto.provider", "org.apache.ws.security.components.crypto.Merlin"); Crypto crypto = CryptoFactory.getInstance(properties); keystore.setKeyEntry(alias, keypair.getPrivate(), keyStorePwd.toCharArray(), new Certificate[]{cert}); ((Merlin) crypto).setKeyStore(keystore); crypto.loadCertificate(new ByteArrayInputStream(cert.getEncoded())); WSSecurityEngine engine = new WSSecurityEngine(); WSSConfig config = WSSConfig.getNewInstance(); config.setWsiBSPCompliant(false); engine.setWssConfig(config); List<WSSecurityEngineResult> res = engine.processSecurityHeader(toDocument(soapMessage), null, null, crypto); for (WSSecurityEngineResult ers : res) { LOG.trace("Details of security header after validation {}" , ers.toString()); } LOG.debug("Validation code executed");
@Override protected WSSecurityEngine getSecurityEngine(boolean utNoCallbacks) { WSSConfig config = WSSConfig.getNewInstance(); config.setValidator(WSConstants.USERNAME_TOKEN, new CustomValidator()); WSSecurityEngine ret = new WSSecurityEngine(); ret.setWssConfig(config); return ret; }
@Override protected WSSecurityEngine getSecurityEngine(boolean utNoCallbacks) { WSSConfig config = WSSConfig.getNewInstance(); config.setValidator(WSConstants.USERNAME_TOKEN, new CustomValidator()); WSSecurityEngine ret = new WSSecurityEngine(); ret.setWssConfig(config); return ret; }
secEngineOverride = new WSSecurityEngine(); secEngineOverride.setWssConfig(config);
secEngineOverride = new WSSecurityEngine(); secEngineOverride.setWssConfig(config);
/** * @return the WSSecurityEngine in use by this interceptor. * This engine is defined to be the secEngineOverride * instance, if defined in this class (and supplied through * construction); otherwise, it is taken to be the default * WSSecEngine instance (currently defined in the WSHandler * base class). */ protected WSSecurityEngine getSecurityEngine(boolean utWithCallbacks) { if (secEngineOverride != null) { return secEngineOverride; } if (!utWithCallbacks) { WSSConfig config = WSSConfig.getNewInstance(); config.setValidator(WSConstants.USERNAME_TOKEN, new NoOpValidator()); WSSecurityEngine ret = new WSSecurityEngine(); ret.setWssConfig(config); return ret; } return null; }
/** * @return the WSSecurityEngine in use by this interceptor. * This engine is defined to be the secEngineOverride * instance, if defined in this class (and supplied through * construction); otherwise, it is taken to be the default * WSSecEngine instance (currently defined in the WSHandler * base class). */ protected WSSecurityEngine getSecurityEngine(boolean utWithCallbacks) { if (secEngineOverride != null) { return secEngineOverride; } if (!utWithCallbacks) { WSSConfig config = WSSConfig.getNewInstance(); config.setValidator(WSConstants.USERNAME_TOKEN, new NoOpValidator()); WSSecurityEngine ret = new WSSecurityEngine(); ret.setWssConfig(config); return ret; } return null; }
final WSSecurityEngine aSecurityEngine = new WSSecurityEngine (); List <WSSecurityEngineResult> aResults = null;
WSSecurityEngine engine; if (config != null) { engine = new WSSecurityEngine(); engine.setWssConfig(config); } else { engine = getSecurityEngine(utWithCallbacks); if (engine == null) { engine = new WSSecurityEngine();
WSSecurityEngine engine; if (config != null) { engine = new WSSecurityEngine(); engine.setWssConfig(config); } else { engine = getSecurityEngine(utWithCallbacks); if (engine == null) { engine = new WSSecurityEngine();