private Crypto getEncryptionCrypto(Object e, SoapMessage message, RequestData requestData) throws WSSecurityException { PasswordEncryptor passwordEncryptor = getPasswordEncryptor(message, requestData); return WSS4JUtils.getEncryptionCrypto(e, message, passwordEncryptor); }
private Crypto getCrypto( SamlToken samlToken, String cryptoKey, String propKey, SoapMessage message ) throws WSSecurityException { Crypto crypto = (Crypto)SecurityUtils.getSecurityPropertyValue(cryptoKey, message); if (crypto != null) { return crypto; } Object o = SecurityUtils.getSecurityPropertyValue(propKey, message); if (o == null) { return null; } URL propsURL = SecurityUtils.loadResource(message, o); Properties properties = WSS4JUtils.getProps(o, propsURL); if (properties != null) { PasswordEncryptor passwordEncryptor = WSS4JUtils.getPasswordEncryptor(message); crypto = CryptoFactory.getInstance(properties, this.getClass().getClassLoader(), passwordEncryptor); } return crypto; }
/** * Get a ReplayCache instance. It first checks to see whether caching has been explicitly * enabled or disabled via the booleanKey argument. If it has been set to false then no * replay caching is done (for this booleanKey). If it has not been specified, then caching * is enabled only if we are not the initiator of the exchange. If it has been specified, then * caching is enabled. * * It tries to get an instance of ReplayCache via the instanceKey argument from a * contextual property, and failing that the message exchange. If it can't find any, then it * defaults to using an EH-Cache instance and stores that on the message exchange. */ protected ReplayCache getReplayCache( SoapMessage message, String booleanKey, String instanceKey ) { return WSS4JUtils.getReplayCache(message, booleanKey, instanceKey); }
private String setupEncryptedKey(AbstractTokenWrapper wrapper, AbstractToken sigToken) throws WSSecurityException { Instant created = Instant.now(); Instant expires = created.plusSeconds(WSS4JUtils.getSecurityTokenLifetime(message) / 1000L); SecurityToken tempTok = new SecurityToken(IDGenerator.generateID(null), created, expires); KeyGenerator keyGenerator = KeyUtils.getKeyGenerator(sbinding.getAlgorithmSuite().getAlgorithmSuiteType().getEncryption()); SecretKey symmetricKey = keyGenerator.generateKey(); tempTok.setKey(symmetricKey); tempTok.setSecret(symmetricKey.getEncoded()); TokenStoreUtils.getTokenStore(message).add(tempTok); return tempTok.getId(); }
(List<WSHandlerResult>) messageContext.get(WSHandlerConstants.RECV_RESULTS); X509Certificate cert = WSS4JUtils.getReqSigCert(results); if (cert != null) { return cert;
throw WSS4JUtils.createSoapFault(message, message.getVersion(), ex);
WSS4JUtils.getReplayCache( message, SecurityConstants.ENABLE_NONCE_CACHE, SecurityConstants.NONCE_CACHE_INSTANCE ); return results.get(0); } catch (WSSecurityException ex) { throw WSS4JUtils.createSoapFault(message, message.getVersion(), ex);
@Override public void registerSecurityEvent(SecurityEvent securityEvent) throws XMLSecurityException { if (securityEvent.getSecurityEventType() == WSSecurityEventConstants.SAML_TOKEN) { // Store SAML keys in case we need them on the inbound side TokenSecurityEvent<?> tokenSecurityEvent = (TokenSecurityEvent<?>)securityEvent; WSS4JUtils.parseAndStoreStreamingSecurityToken(tokenSecurityEvent.getSecurityToken(), msg); } else if (securityEvent.getSecurityEventType() == WSSecurityEventConstants.SignatureValue) { // Required for Signature Confirmation outgoingSecurityEventList.add(securityEvent); } } };
protected Crypto loadCryptoFromPropertiesFile( SoapMessage soapMessage, String propFilename, WSSSecurityProperties securityProperties ) throws WSSecurityException { PasswordEncryptor passwordEncryptor = getPasswordEncryptor(soapMessage, securityProperties); return WSS4JUtils.loadCryptoFromPropertiesFile( soapMessage, propFilename, getClassLoader(), passwordEncryptor ); }
private Crypto getSignatureCrypto(Object s, SoapMessage message, RequestData requestData) throws WSSecurityException { PasswordEncryptor passwordEncryptor = getPasswordEncryptor(message, requestData); return WSS4JUtils.getSignatureCrypto(s, message, passwordEncryptor); }
public static Crypto getEncryptionCrypto( Object e, SoapMessage message, PasswordEncryptor passwordEncryptor ) throws WSSecurityException { Crypto encrCrypto = null; if (e instanceof Crypto) { encrCrypto = (Crypto)e; } else if (e != null) { URL propsURL = SecurityUtils.loadResource(message, e); Properties props = WSS4JUtils.getProps(e, propsURL); if (props == null) { LOG.fine("Cannot find Crypto Encryption properties: " + e); Exception ex = new Exception("Cannot find Crypto Encryption properties: " + e); throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, ex); } encrCrypto = CryptoFactory.getInstance(props, Loader.getClassLoader(CryptoFactory.class), passwordEncryptor); EndpointInfo info = message.getExchange().getEndpoint().getEndpointInfo(); synchronized (info) { info.setProperty(SecurityConstants.ENCRYPT_CRYPTO, encrCrypto); } } return encrCrypto; }
private String setupEncryptedKey(AbstractTokenWrapper wrapper, AbstractToken sigToken) throws WSSecurityException { Instant created = Instant.now(); Instant expires = created.plusSeconds(WSS4JUtils.getSecurityTokenLifetime(message) / 1000L); SecurityToken tempTok = new SecurityToken(IDGenerator.generateID(null), created, expires); KeyGenerator keyGenerator = KeyUtils.getKeyGenerator(sbinding.getAlgorithmSuite().getAlgorithmSuiteType().getEncryption()); SecretKey symmetricKey = keyGenerator.generateKey(); tempTok.setKey(symmetricKey); tempTok.setSecret(symmetricKey.getEncoded()); TokenStoreUtils.getTokenStore(message).add(tempTok); return tempTok.getId(); }
(List<WSHandlerResult>) messageContext.get(WSHandlerConstants.RECV_RESULTS); X509Certificate cert = WSS4JUtils.getReqSigCert(results); if (cert != null) { return cert;
throw WSS4JUtils.createSoapFault(message, message.getVersion(), ex);
WSS4JUtils.getReplayCache( message, SecurityConstants.ENABLE_NONCE_CACHE, SecurityConstants.NONCE_CACHE_INSTANCE ); return results.get(0); } catch (WSSecurityException ex) { throw WSS4JUtils.createSoapFault(message, message.getVersion(), ex);
@Override public void registerSecurityEvent(SecurityEvent securityEvent) throws XMLSecurityException { if (securityEvent.getSecurityEventType() == WSSecurityEventConstants.SAML_TOKEN) { // Store SAML keys in case we need them on the inbound side TokenSecurityEvent<?> tokenSecurityEvent = (TokenSecurityEvent<?>)securityEvent; WSS4JUtils.parseAndStoreStreamingSecurityToken(tokenSecurityEvent.getSecurityToken(), msg); } else if (securityEvent.getSecurityEventType() == WSSecurityEventConstants.SignatureValue) { // Required for Signature Confirmation outgoingSecurityEventList.add(securityEvent); } } };
protected Crypto loadCryptoFromPropertiesFile( SoapMessage soapMessage, String propFilename, WSSSecurityProperties securityProperties ) throws WSSecurityException { PasswordEncryptor passwordEncryptor = getPasswordEncryptor(soapMessage, securityProperties); return WSS4JUtils.loadCryptoFromPropertiesFile( soapMessage, propFilename, getClassLoader(), passwordEncryptor ); }
protected Crypto getSignatureCrypto( Object s, SoapMessage message, WSSSecurityProperties securityProperties ) throws WSSecurityException { PasswordEncryptor passwordEncryptor = getPasswordEncryptor(message, securityProperties); return WSS4JUtils.getSignatureCrypto(s, message, passwordEncryptor); }
public static Crypto getEncryptionCrypto( Object e, SoapMessage message, PasswordEncryptor passwordEncryptor ) throws WSSecurityException { Crypto encrCrypto = null; if (e instanceof Crypto) { encrCrypto = (Crypto)e; } else if (e != null) { URL propsURL = SecurityUtils.loadResource(message, e); Properties props = WSS4JUtils.getProps(e, propsURL); if (props == null) { LOG.fine("Cannot find Crypto Encryption properties: " + e); Exception ex = new Exception("Cannot find Crypto Encryption properties: " + e); throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, ex); } encrCrypto = CryptoFactory.getInstance(props, Loader.getClassLoader(CryptoFactory.class), passwordEncryptor); EndpointInfo info = message.getExchange().getEndpoint().getEndpointInfo(); synchronized (info) { info.setProperty(SecurityConstants.ENCRYPT_CRYPTO, encrCrypto); } } return encrCrypto; }
protected Crypto createCrypto(boolean decrypt) throws IOException, WSSecurityException { Crypto crypto = (Crypto)getProperty(SecurityConstants.STS_TOKEN_CRYPTO + (decrypt ? ".decrypt" : "")); if (crypto != null) { return crypto; } Object o = getProperty(SecurityConstants.STS_TOKEN_PROPERTIES + (decrypt ? ".decrypt" : "")); URL propsURL = SecurityUtils.loadResource(message, o); Properties properties = WSS4JUtils.getProps(o, propsURL); if (properties != null) { PasswordEncryptor passwordEncryptor = WSS4JUtils.getPasswordEncryptor(message); return CryptoFactory.getInstance(properties, this.getClass().getClassLoader(), passwordEncryptor); } if (decrypt) { return createCrypto(false); } return null; }