org.apache.cxf.jaxws.context.WrappedMessageContext Java Examples
The following examples show how to use
org.apache.cxf.jaxws.context.WrappedMessageContext.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ContextPropertiesMappingTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testCreateWebServiceContext() { Exchange exchange = new ExchangeImpl(); Message inMessage = new MessageImpl(); Message outMessage = new MessageImpl(); inMessage.putAll(message); exchange.setInMessage(inMessage); exchange.setOutMessage(outMessage); MessageContext ctx = new WrappedMessageContext(exchange.getInMessage(), Scope.APPLICATION); Object requestHeader = ctx.get(MessageContext.HTTP_REQUEST_HEADERS); assertNotNull("the request header should not be null", requestHeader); assertEquals("we should get the request header", requestHeader, HEADER); Object responseHeader = ctx.get(MessageContext.HTTP_RESPONSE_HEADERS); assertNull("the response header should be null", responseHeader); Object outMessageHeader = outMessage.get(Message.PROTOCOL_HEADERS); assertEquals("the outMessage PROTOCOL_HEADERS should be update", responseHeader, outMessageHeader); Object inAttachments = ctx.get(MessageContext.INBOUND_MESSAGE_ATTACHMENTS); assertNotNull("inbound attachments object must be initialized", inAttachments); assertTrue("inbound attachments must be in a Map", inAttachments instanceof Map); assertTrue("no inbound attachments expected", ((Map<?, ?>)inAttachments).isEmpty()); }
Example #2
Source File: SAMLTokenValidatorRealmTest.java From cxf with Apache License 2.0 | 5 votes |
private TokenProviderParameters createProviderParameters( String tokenType, String keyType, Crypto crypto, String signatureUsername, CallbackHandler callbackHandler ) throws WSSecurityException { TokenProviderParameters parameters = new TokenProviderParameters(); TokenRequirements tokenRequirements = new TokenRequirements(); tokenRequirements.setTokenType(tokenType); parameters.setTokenRequirements(tokenRequirements); KeyRequirements keyRequirements = new KeyRequirements(); keyRequirements.setKeyType(keyType); parameters.setKeyRequirements(keyRequirements); parameters.setPrincipal(new CustomTokenPrincipal("alice")); // Mock up message context MessageImpl msg = new MessageImpl(); WrappedMessageContext msgCtx = new WrappedMessageContext(msg); parameters.setMessageContext(msgCtx); parameters.setAppliesToAddress("http://dummy-service.com/dummy"); // Add STSProperties object StaticSTSProperties stsProperties = new StaticSTSProperties(); stsProperties.setSignatureCrypto(crypto); stsProperties.setSignatureUsername(signatureUsername); stsProperties.setCallbackHandler(callbackHandler); stsProperties.setIssuer("STS"); parameters.setStsProperties(stsProperties); parameters.setEncryptionProperties(new EncryptionProperties()); return parameters; }
Example #3
Source File: SAMLTokenRenewerPOPTest.java From cxf with Apache License 2.0 | 5 votes |
private TokenValidatorParameters createValidatorParameters() throws WSSecurityException { TokenValidatorParameters parameters = new TokenValidatorParameters(); TokenRequirements tokenRequirements = new TokenRequirements(); parameters.setTokenRequirements(tokenRequirements); KeyRequirements keyRequirements = new KeyRequirements(); parameters.setKeyRequirements(keyRequirements); parameters.setPrincipal(new CustomTokenPrincipal("alice")); // Mock up message context MessageImpl msg = new MessageImpl(); WrappedMessageContext msgCtx = new WrappedMessageContext(msg); parameters.setMessageContext(msgCtx); // Add STSProperties object StaticSTSProperties stsProperties = new StaticSTSProperties(); Crypto crypto = CryptoFactory.getInstance(getEncryptionProperties()); stsProperties.setEncryptionCrypto(crypto); stsProperties.setSignatureCrypto(crypto); stsProperties.setEncryptionUsername("myservicekey"); stsProperties.setSignatureUsername("mystskey"); stsProperties.setCallbackHandler(new PasswordCallbackHandler()); stsProperties.setIssuer("STS"); parameters.setStsProperties(stsProperties); parameters.setTokenStore(tokenStore); return parameters; }
Example #4
Source File: JWTTokenValidatorTest.java From cxf with Apache License 2.0 | 5 votes |
private TokenValidatorParameters createValidatorParameters() throws WSSecurityException { TokenValidatorParameters parameters = new TokenValidatorParameters(); TokenRequirements tokenRequirements = new TokenRequirements(); tokenRequirements.setTokenType(STSConstants.STATUS); parameters.setTokenRequirements(tokenRequirements); KeyRequirements keyRequirements = new KeyRequirements(); parameters.setKeyRequirements(keyRequirements); parameters.setPrincipal(new CustomTokenPrincipal("alice")); // Mock up message context MessageImpl msg = new MessageImpl(); WrappedMessageContext msgCtx = new WrappedMessageContext(msg); parameters.setMessageContext(msgCtx); // Add STSProperties object StaticSTSProperties stsProperties = new StaticSTSProperties(); Crypto crypto = CryptoFactory.getInstance(getEncryptionProperties()); stsProperties.setEncryptionCrypto(crypto); stsProperties.setSignatureCrypto(crypto); stsProperties.setEncryptionUsername("myservicekey"); stsProperties.setSignatureUsername("mystskey"); stsProperties.setCallbackHandler(new PasswordCallbackHandler()); stsProperties.setIssuer("STS"); parameters.setStsProperties(stsProperties); parameters.setTokenStore(tokenStore); return parameters; }
Example #5
Source File: SAMLProviderLifetimeTest.java From cxf with Apache License 2.0 | 5 votes |
private TokenProviderParameters createProviderParameters( String tokenType, String keyType ) throws WSSecurityException { TokenProviderParameters parameters = new TokenProviderParameters(); TokenRequirements tokenRequirements = new TokenRequirements(); tokenRequirements.setTokenType(tokenType); parameters.setTokenRequirements(tokenRequirements); KeyRequirements keyRequirements = new KeyRequirements(); keyRequirements.setKeyType(keyType); parameters.setKeyRequirements(keyRequirements); parameters.setPrincipal(new CustomTokenPrincipal("alice")); // Mock up message context MessageImpl msg = new MessageImpl(); WrappedMessageContext msgCtx = new WrappedMessageContext(msg); parameters.setMessageContext(msgCtx); parameters.setAppliesToAddress("http://dummy-service.com/dummy"); // Add STSProperties object StaticSTSProperties stsProperties = new StaticSTSProperties(); Crypto crypto = CryptoFactory.getInstance(getEncryptionProperties()); stsProperties.setEncryptionCrypto(crypto); stsProperties.setSignatureCrypto(crypto); stsProperties.setEncryptionUsername("myservicekey"); stsProperties.setSignatureUsername("mystskey"); stsProperties.setCallbackHandler(new PasswordCallbackHandler()); stsProperties.setIssuer("STS"); parameters.setStsProperties(stsProperties); parameters.setEncryptionProperties(new EncryptionProperties()); return parameters; }
Example #6
Source File: SAMLTokenValidatorCachedRealmTest.java From cxf with Apache License 2.0 | 5 votes |
private TokenValidatorParameters createValidatorParameters() throws WSSecurityException { TokenValidatorParameters parameters = new TokenValidatorParameters(); TokenRequirements tokenRequirements = new TokenRequirements(); tokenRequirements.setTokenType(STSConstants.STATUS); parameters.setTokenRequirements(tokenRequirements); KeyRequirements keyRequirements = new KeyRequirements(); parameters.setKeyRequirements(keyRequirements); parameters.setPrincipal(new CustomTokenPrincipal("alice")); // Mock up message context MessageImpl msg = new MessageImpl(); WrappedMessageContext msgCtx = new WrappedMessageContext(msg); parameters.setMessageContext(msgCtx); // Add STSProperties object StaticSTSProperties stsProperties = new StaticSTSProperties(); Crypto crypto = CryptoFactory.getInstance(getEncryptionProperties()); stsProperties.setEncryptionCrypto(crypto); stsProperties.setSignatureCrypto(crypto); stsProperties.setEncryptionUsername("myservicekey"); stsProperties.setSignatureUsername("mystskey"); stsProperties.setCallbackHandler(new PasswordCallbackHandler()); stsProperties.setIssuer("STS-2"); parameters.setStsProperties(stsProperties); parameters.setTokenStore(tokenStore); return parameters; }
Example #7
Source File: SCTCancellerTest.java From cxf with Apache License 2.0 | 5 votes |
private TokenCancellerParameters createCancellerParameters() throws WSSecurityException { TokenCancellerParameters parameters = new TokenCancellerParameters(); TokenRequirements tokenRequirements = new TokenRequirements(); tokenRequirements.setTokenType(STSConstants.STATUS); parameters.setTokenRequirements(tokenRequirements); KeyRequirements keyRequirements = new KeyRequirements(); parameters.setKeyRequirements(keyRequirements); parameters.setTokenStore(tokenStore); parameters.setPrincipal(new CustomTokenPrincipal("alice")); // Mock up message context MessageImpl msg = new MessageImpl(); WrappedMessageContext msgCtx = new WrappedMessageContext(msg); parameters.setMessageContext(msgCtx); // Add STSProperties object StaticSTSProperties stsProperties = new StaticSTSProperties(); Crypto crypto = CryptoFactory.getInstance(getEncryptionProperties()); stsProperties.setEncryptionCrypto(crypto); stsProperties.setSignatureCrypto(crypto); stsProperties.setEncryptionUsername("myservicekey"); stsProperties.setSignatureUsername("mystskey"); stsProperties.setCallbackHandler(new PasswordCallbackHandler()); stsProperties.setIssuer("STS"); parameters.setStsProperties(stsProperties); return parameters; }
Example #8
Source File: SAMLTokenRenewerLifetimeTest.java From cxf with Apache License 2.0 | 5 votes |
private TokenProviderParameters createProviderParameters( String tokenType, String keyType, Crypto crypto, String signatureUsername, CallbackHandler callbackHandler ) throws WSSecurityException { TokenProviderParameters parameters = new TokenProviderParameters(); TokenRequirements tokenRequirements = new TokenRequirements(); tokenRequirements.setTokenType(tokenType); parameters.setTokenRequirements(tokenRequirements); KeyRequirements keyRequirements = new KeyRequirements(); keyRequirements.setKeyType(keyType); parameters.setKeyRequirements(keyRequirements); parameters.setPrincipal(new CustomTokenPrincipal("alice")); // Mock up message context MessageImpl msg = new MessageImpl(); WrappedMessageContext msgCtx = new WrappedMessageContext(msg); parameters.setMessageContext(msgCtx); parameters.setAppliesToAddress("http://dummy-service.com/dummy"); // Add STSProperties object StaticSTSProperties stsProperties = new StaticSTSProperties(); stsProperties.setSignatureCrypto(crypto); stsProperties.setSignatureUsername(signatureUsername); stsProperties.setCallbackHandler(callbackHandler); stsProperties.setIssuer("STS"); parameters.setStsProperties(stsProperties); parameters.setEncryptionProperties(new EncryptionProperties()); parameters.setTokenStore(tokenStore); return parameters; }
Example #9
Source File: SAMLTokenRenewerRealmTest.java From cxf with Apache License 2.0 | 5 votes |
private TokenValidatorParameters createValidatorParameters() throws WSSecurityException { TokenValidatorParameters parameters = new TokenValidatorParameters(); TokenRequirements tokenRequirements = new TokenRequirements(); tokenRequirements.setTokenType(STSConstants.STATUS); parameters.setTokenRequirements(tokenRequirements); KeyRequirements keyRequirements = new KeyRequirements(); parameters.setKeyRequirements(keyRequirements); parameters.setPrincipal(new CustomTokenPrincipal("alice")); // Mock up message context MessageImpl msg = new MessageImpl(); WrappedMessageContext msgCtx = new WrappedMessageContext(msg); parameters.setMessageContext(msgCtx); // Add STSProperties object StaticSTSProperties stsProperties = new StaticSTSProperties(); Crypto crypto = CryptoFactory.getInstance(getEncryptionProperties()); stsProperties.setEncryptionCrypto(crypto); stsProperties.setSignatureCrypto(crypto); stsProperties.setEncryptionUsername("myservicekey"); stsProperties.setSignatureUsername("mystskey"); stsProperties.setCallbackHandler(new PasswordCallbackHandler()); stsProperties.setIssuer("STS-2"); parameters.setStsProperties(stsProperties); parameters.setTokenStore(tokenStore); return parameters; }
Example #10
Source File: SAMLTokenRenewerRealmTest.java From cxf with Apache License 2.0 | 5 votes |
private TokenProviderParameters createProviderParameters( String tokenType, String keyType, Crypto crypto, String signatureUsername, CallbackHandler callbackHandler ) throws WSSecurityException { TokenProviderParameters parameters = new TokenProviderParameters(); TokenRequirements tokenRequirements = new TokenRequirements(); tokenRequirements.setTokenType(tokenType); parameters.setTokenRequirements(tokenRequirements); KeyRequirements keyRequirements = new KeyRequirements(); keyRequirements.setKeyType(keyType); parameters.setKeyRequirements(keyRequirements); parameters.setPrincipal(new CustomTokenPrincipal("alice")); // Mock up message context MessageImpl msg = new MessageImpl(); WrappedMessageContext msgCtx = new WrappedMessageContext(msg); parameters.setMessageContext(msgCtx); parameters.setAppliesToAddress("http://dummy-service.com/dummy"); // Add STSProperties object StaticSTSProperties stsProperties = new StaticSTSProperties(); stsProperties.setSignatureCrypto(crypto); stsProperties.setSignatureUsername(signatureUsername); stsProperties.setCallbackHandler(callbackHandler); stsProperties.setIssuer("STS"); parameters.setStsProperties(stsProperties); parameters.setEncryptionProperties(new EncryptionProperties()); parameters.setTokenStore(tokenStore); return parameters; }
Example #11
Source File: SAMLTokenRenewerTest.java From cxf with Apache License 2.0 | 5 votes |
private TokenValidatorParameters createValidatorParameters() throws WSSecurityException { TokenValidatorParameters parameters = new TokenValidatorParameters(); TokenRequirements tokenRequirements = new TokenRequirements(); parameters.setTokenRequirements(tokenRequirements); KeyRequirements keyRequirements = new KeyRequirements(); parameters.setKeyRequirements(keyRequirements); parameters.setPrincipal(new CustomTokenPrincipal("alice")); // Mock up message context MessageImpl msg = new MessageImpl(); WrappedMessageContext msgCtx = new WrappedMessageContext(msg); parameters.setMessageContext(msgCtx); // Add STSProperties object StaticSTSProperties stsProperties = new StaticSTSProperties(); Crypto crypto = CryptoFactory.getInstance(getEncryptionProperties()); stsProperties.setEncryptionCrypto(crypto); stsProperties.setSignatureCrypto(crypto); stsProperties.setEncryptionUsername("myservicekey"); stsProperties.setSignatureUsername("mystskey"); stsProperties.setCallbackHandler(new PasswordCallbackHandler()); stsProperties.setIssuer("STS"); parameters.setStsProperties(stsProperties); parameters.setTokenStore(tokenStore); return parameters; }
Example #12
Source File: SAMLTokenRenewerTest.java From cxf with Apache License 2.0 | 5 votes |
private TokenProviderParameters createProviderParameters( String tokenType, String keyType, Crypto crypto, String signatureUsername, CallbackHandler callbackHandler ) throws WSSecurityException { TokenProviderParameters parameters = new TokenProviderParameters(); TokenRequirements tokenRequirements = new TokenRequirements(); tokenRequirements.setTokenType(tokenType); parameters.setTokenRequirements(tokenRequirements); KeyRequirements keyRequirements = new KeyRequirements(); keyRequirements.setKeyType(keyType); parameters.setKeyRequirements(keyRequirements); parameters.setPrincipal(new CustomTokenPrincipal("alice")); // Mock up message context MessageImpl msg = new MessageImpl(); WrappedMessageContext msgCtx = new WrappedMessageContext(msg); parameters.setMessageContext(msgCtx); parameters.setAppliesToAddress("http://dummy-service.com/dummy"); // Add STSProperties object StaticSTSProperties stsProperties = new StaticSTSProperties(); stsProperties.setSignatureCrypto(crypto); stsProperties.setSignatureUsername(signatureUsername); stsProperties.setCallbackHandler(callbackHandler); stsProperties.setIssuer("STS"); parameters.setStsProperties(stsProperties); parameters.setEncryptionProperties(new EncryptionProperties()); parameters.setTokenStore(tokenStore); return parameters; }
Example #13
Source File: JWTTokenProviderRealmTest.java From cxf with Apache License 2.0 | 5 votes |
private TokenProviderParameters createProviderParameters( String tokenType ) throws WSSecurityException { TokenProviderParameters parameters = new TokenProviderParameters(); TokenRequirements tokenRequirements = new TokenRequirements(); tokenRequirements.setTokenType(tokenType); parameters.setTokenRequirements(tokenRequirements); KeyRequirements keyRequirements = new KeyRequirements(); parameters.setKeyRequirements(keyRequirements); parameters.setPrincipal(new CustomTokenPrincipal("alice")); // Mock up message context MessageImpl msg = new MessageImpl(); WrappedMessageContext msgCtx = new WrappedMessageContext(msg); parameters.setMessageContext(msgCtx); parameters.setAppliesToAddress("http://dummy-service.com/dummy"); // Add STSProperties object StaticSTSProperties stsProperties = new StaticSTSProperties(); Crypto crypto = CryptoFactory.getInstance(getEncryptionProperties()); stsProperties.setEncryptionCrypto(crypto); stsProperties.setSignatureCrypto(crypto); stsProperties.setEncryptionUsername("myservicekey"); stsProperties.setSignatureUsername("mystskey"); stsProperties.setCallbackHandler(new PasswordCallbackHandler()); stsProperties.setIssuer("STS"); parameters.setStsProperties(stsProperties); parameters.setEncryptionProperties(new EncryptionProperties()); return parameters; }
Example #14
Source File: SCTProviderTest.java From cxf with Apache License 2.0 | 5 votes |
private TokenProviderParameters createProviderParameters(String tokenType) throws WSSecurityException { TokenProviderParameters parameters = new TokenProviderParameters(); TokenRequirements tokenRequirements = new TokenRequirements(); tokenRequirements.setTokenType(tokenType); parameters.setTokenRequirements(tokenRequirements); KeyRequirements keyRequirements = new KeyRequirements(); parameters.setKeyRequirements(keyRequirements); parameters.setTokenStore(tokenStore); parameters.setPrincipal(new CustomTokenPrincipal("alice")); // Mock up message context MessageImpl msg = new MessageImpl(); WrappedMessageContext msgCtx = new WrappedMessageContext(msg); parameters.setMessageContext(msgCtx); parameters.setAppliesToAddress("http://dummy-service.com/dummy"); // Add STSProperties object StaticSTSProperties stsProperties = new StaticSTSProperties(); Crypto crypto = CryptoFactory.getInstance(getEncryptionProperties()); stsProperties.setSignatureCrypto(crypto); stsProperties.setSignatureUsername("mystskey"); stsProperties.setCallbackHandler(new PasswordCallbackHandler()); stsProperties.setIssuer("STS"); parameters.setStsProperties(stsProperties); parameters.setEncryptionProperties(new EncryptionProperties()); return parameters; }
Example #15
Source File: SAMLClaimsTest.java From cxf with Apache License 2.0 | 5 votes |
private TokenProviderParameters createProviderParameters( String tokenType, String keyType, String appliesTo ) throws WSSecurityException { TokenProviderParameters parameters = new TokenProviderParameters(); TokenRequirements tokenRequirements = new TokenRequirements(); tokenRequirements.setTokenType(tokenType); parameters.setTokenRequirements(tokenRequirements); KeyRequirements keyRequirements = new KeyRequirements(); keyRequirements.setKeyType(keyType); parameters.setKeyRequirements(keyRequirements); parameters.setPrincipal(new CustomTokenPrincipal("alice")); // Mock up message context MessageImpl msg = new MessageImpl(); WrappedMessageContext msgCtx = new WrappedMessageContext(msg); parameters.setMessageContext(msgCtx); if (appliesTo != null) { parameters.setAppliesToAddress(appliesTo); } else { parameters.setAppliesToAddress(APPLICATION_APPLIES_TO); } // Add STSProperties object StaticSTSProperties stsProperties = new StaticSTSProperties(); Crypto crypto = CryptoFactory.getInstance(getEncryptionProperties()); stsProperties.setEncryptionCrypto(crypto); stsProperties.setSignatureCrypto(crypto); stsProperties.setEncryptionUsername("myservicekey"); stsProperties.setSignatureUsername("mystskey"); stsProperties.setCallbackHandler(new PasswordCallbackHandler()); stsProperties.setIssuer("STS"); parameters.setStsProperties(stsProperties); parameters.setEncryptionProperties(new EncryptionProperties()); return parameters; }
Example #16
Source File: UsernameTokenValidatorTest.java From cxf with Apache License 2.0 | 5 votes |
private TokenValidatorParameters createValidatorParameters() throws WSSecurityException { TokenValidatorParameters parameters = new TokenValidatorParameters(); TokenRequirements tokenRequirements = new TokenRequirements(); tokenRequirements.setTokenType(STSConstants.STATUS); parameters.setTokenRequirements(tokenRequirements); KeyRequirements keyRequirements = new KeyRequirements(); parameters.setKeyRequirements(keyRequirements); parameters.setPrincipal(new CustomTokenPrincipal("alice")); // Mock up message context MessageImpl msg = new MessageImpl(); WrappedMessageContext msgCtx = new WrappedMessageContext(msg); parameters.setMessageContext(msgCtx); // Add STSProperties object StaticSTSProperties stsProperties = new StaticSTSProperties(); Crypto crypto = CryptoFactory.getInstance(getEncryptionProperties()); stsProperties.setEncryptionCrypto(crypto); stsProperties.setSignatureCrypto(crypto); stsProperties.setEncryptionUsername("myservicekey"); stsProperties.setSignatureUsername("mystskey"); stsProperties.setCallbackHandler(new PasswordCallbackHandler()); stsProperties.setIssuer("STS"); parameters.setStsProperties(stsProperties); return parameters; }
Example #17
Source File: SCTValidatorTest.java From cxf with Apache License 2.0 | 5 votes |
private TokenProviderParameters createProviderParameters(String tokenType) throws WSSecurityException { TokenProviderParameters parameters = new TokenProviderParameters(); TokenRequirements tokenRequirements = new TokenRequirements(); tokenRequirements.setTokenType(tokenType); parameters.setTokenRequirements(tokenRequirements); KeyRequirements keyRequirements = new KeyRequirements(); parameters.setKeyRequirements(keyRequirements); parameters.setTokenStore(tokenStore); parameters.setPrincipal(new CustomTokenPrincipal("alice")); // Mock up message context MessageImpl msg = new MessageImpl(); WrappedMessageContext msgCtx = new WrappedMessageContext(msg); parameters.setMessageContext(msgCtx); parameters.setAppliesToAddress("http://dummy-service.com/dummy"); // Add STSProperties object StaticSTSProperties stsProperties = new StaticSTSProperties(); Crypto crypto = CryptoFactory.getInstance(getEncryptionProperties()); stsProperties.setSignatureCrypto(crypto); stsProperties.setSignatureUsername("mystskey"); stsProperties.setCallbackHandler(new PasswordCallbackHandler()); stsProperties.setIssuer("STS"); parameters.setStsProperties(stsProperties); parameters.setEncryptionProperties(new EncryptionProperties()); return parameters; }
Example #18
Source File: SAMLTokenValidatorRealmTest.java From cxf with Apache License 2.0 | 5 votes |
private TokenValidatorParameters createValidatorParameters() throws WSSecurityException { TokenValidatorParameters parameters = new TokenValidatorParameters(); TokenRequirements tokenRequirements = new TokenRequirements(); tokenRequirements.setTokenType(STSConstants.STATUS); parameters.setTokenRequirements(tokenRequirements); KeyRequirements keyRequirements = new KeyRequirements(); parameters.setKeyRequirements(keyRequirements); parameters.setPrincipal(new CustomTokenPrincipal("alice")); // Mock up message context MessageImpl msg = new MessageImpl(); WrappedMessageContext msgCtx = new WrappedMessageContext(msg); parameters.setMessageContext(msgCtx); // Add STSProperties object StaticSTSProperties stsProperties = new StaticSTSProperties(); Crypto crypto = CryptoFactory.getInstance(getEncryptionProperties()); stsProperties.setEncryptionCrypto(crypto); stsProperties.setSignatureCrypto(crypto); stsProperties.setEncryptionUsername("myservicekey"); stsProperties.setSignatureUsername("mystskey"); stsProperties.setCallbackHandler(new PasswordCallbackHandler()); stsProperties.setIssuer("STS-2"); parameters.setStsProperties(stsProperties); return parameters; }
Example #19
Source File: JWTTokenValidatorRealmTest.java From cxf with Apache License 2.0 | 5 votes |
private TokenValidatorParameters createValidatorParameters() throws WSSecurityException { TokenValidatorParameters parameters = new TokenValidatorParameters(); TokenRequirements tokenRequirements = new TokenRequirements(); tokenRequirements.setTokenType(STSConstants.STATUS); parameters.setTokenRequirements(tokenRequirements); KeyRequirements keyRequirements = new KeyRequirements(); parameters.setKeyRequirements(keyRequirements); parameters.setPrincipal(new CustomTokenPrincipal("alice")); // Mock up message context MessageImpl msg = new MessageImpl(); WrappedMessageContext msgCtx = new WrappedMessageContext(msg); parameters.setMessageContext(msgCtx); // Add STSProperties object StaticSTSProperties stsProperties = new StaticSTSProperties(); Crypto crypto = CryptoFactory.getInstance(getEncryptionProperties()); stsProperties.setEncryptionCrypto(crypto); stsProperties.setSignatureCrypto(crypto); stsProperties.setEncryptionUsername("myservicekey"); stsProperties.setSignatureUsername("mystskey"); stsProperties.setCallbackHandler(new PasswordCallbackHandler()); stsProperties.setIssuer("STS"); parameters.setStsProperties(stsProperties); parameters.setTokenStore(tokenStore); return parameters; }
Example #20
Source File: SAMLTokenValidatorTest.java From cxf with Apache License 2.0 | 5 votes |
private TokenProviderParameters createProviderParameters( String subjectName, String tokenType, String keyType, Crypto crypto, String signatureUsername, CallbackHandler callbackHandler ) throws WSSecurityException { TokenProviderParameters parameters = new TokenProviderParameters(); TokenRequirements tokenRequirements = new TokenRequirements(); tokenRequirements.setTokenType(tokenType); parameters.setTokenRequirements(tokenRequirements); KeyRequirements keyRequirements = new KeyRequirements(); keyRequirements.setKeyType(keyType); parameters.setKeyRequirements(keyRequirements); parameters.setPrincipal(new CustomTokenPrincipal(subjectName)); // Mock up message context MessageImpl msg = new MessageImpl(); WrappedMessageContext msgCtx = new WrappedMessageContext(msg); parameters.setMessageContext(msgCtx); parameters.setAppliesToAddress("http://dummy-service.com/dummy"); // Add STSProperties object StaticSTSProperties stsProperties = new StaticSTSProperties(); stsProperties.setSignatureCrypto(crypto); stsProperties.setSignatureUsername(signatureUsername); stsProperties.setCallbackHandler(callbackHandler); stsProperties.setIssuer("STS"); parameters.setStsProperties(stsProperties); parameters.setEncryptionProperties(new EncryptionProperties()); parameters.setTokenStore(tokenStore); return parameters; }
Example #21
Source File: SAMLTokenValidatorTest.java From cxf with Apache License 2.0 | 5 votes |
private TokenValidatorParameters createValidatorParameters() throws WSSecurityException { TokenValidatorParameters parameters = new TokenValidatorParameters(); TokenRequirements tokenRequirements = new TokenRequirements(); tokenRequirements.setTokenType(STSConstants.STATUS); parameters.setTokenRequirements(tokenRequirements); KeyRequirements keyRequirements = new KeyRequirements(); parameters.setKeyRequirements(keyRequirements); parameters.setPrincipal(new CustomTokenPrincipal("alice")); // Mock up message context MessageImpl msg = new MessageImpl(); WrappedMessageContext msgCtx = new WrappedMessageContext(msg); parameters.setMessageContext(msgCtx); // Add STSProperties object StaticSTSProperties stsProperties = new StaticSTSProperties(); Crypto crypto = CryptoFactory.getInstance(getEncryptionProperties()); stsProperties.setEncryptionCrypto(crypto); stsProperties.setSignatureCrypto(crypto); stsProperties.setEncryptionUsername("myservicekey"); stsProperties.setSignatureUsername("mystskey"); stsProperties.setCallbackHandler(new PasswordCallbackHandler()); stsProperties.setIssuer("STS"); parameters.setStsProperties(stsProperties); parameters.setTokenStore(tokenStore); return parameters; }
Example #22
Source File: ValidateTokenTransformationUnitTest.java From cxf with Apache License 2.0 | 5 votes |
private TokenProviderParameters createProviderParameters( String tokenType, String keyType, Crypto crypto, String signatureUsername, CallbackHandler callbackHandler ) throws WSSecurityException { TokenProviderParameters parameters = new TokenProviderParameters(); TokenRequirements tokenRequirements = new TokenRequirements(); tokenRequirements.setTokenType(tokenType); parameters.setTokenRequirements(tokenRequirements); KeyRequirements keyRequirements = new KeyRequirements(); keyRequirements.setKeyType(keyType); parameters.setKeyRequirements(keyRequirements); parameters.setPrincipal(new CustomTokenPrincipal("alice")); // Mock up message context MessageImpl msg = new MessageImpl(); WrappedMessageContext msgCtx = new WrappedMessageContext(msg); parameters.setMessageContext(msgCtx); parameters.setAppliesToAddress("http://dummy-service.com/dummy"); // Add STSProperties object StaticSTSProperties stsProperties = new StaticSTSProperties(); stsProperties.setSignatureCrypto(crypto); stsProperties.setSignatureUsername(signatureUsername); stsProperties.setCallbackHandler(callbackHandler); stsProperties.setIssuer("STS"); parameters.setStsProperties(stsProperties); parameters.setEncryptionProperties(new EncryptionProperties()); return parameters; }
Example #23
Source File: JexlIssueSamlClaimsTest.java From cxf with Apache License 2.0 | 5 votes |
private TokenProviderParameters createProviderParameters(String tokenType, String keyType, Crypto crypto, String signatureUsername, CallbackHandler callbackHandler) throws WSSecurityException { TokenProviderParameters parameters = new TokenProviderParameters(); TokenRequirements tokenRequirements = new TokenRequirements(); tokenRequirements.setTokenType(tokenType); parameters.setTokenRequirements(tokenRequirements); KeyRequirements keyRequirements = new KeyRequirements(); keyRequirements.setKeyType(keyType); parameters.setKeyRequirements(keyRequirements); parameters.setPrincipal(new CustomTokenPrincipal("alice")); // Mock up message context MessageImpl msg = new MessageImpl(); WrappedMessageContext msgCtx = new WrappedMessageContext(msg); parameters.setMessageContext(msgCtx); parameters.setAppliesToAddress("http://dummy-service.com/dummy"); // Add STSProperties object StaticSTSProperties stsProperties = new StaticSTSProperties(); stsProperties.setSignatureCrypto(crypto); stsProperties.setSignatureUsername(signatureUsername); stsProperties.setCallbackHandler(callbackHandler); stsProperties.setIssuer("STS"); parameters.setStsProperties(stsProperties); parameters.setEncryptionProperties(new EncryptionProperties()); return parameters; }
Example #24
Source File: IssueJWTClaimsUnitTest.java From cxf with Apache License 2.0 | 5 votes |
/** * @return */ private Map<String, Object> setupMessageContext() { MessageImpl msg = new MessageImpl(); WrappedMessageContext msgCtx = new WrappedMessageContext(msg); msgCtx.put( SecurityContext.class.getName(), createSecurityContext(new CustomTokenPrincipal("alice")) ); return msgCtx; }
Example #25
Source File: JaxWsClientProxy.java From cxf with Apache License 2.0 | 5 votes |
public Map<String, Object> getRequestContext() { if (client == null) { throw new IllegalStateException("The client has been closed."); } return new WrappedMessageContext(this.getClient().getRequestContext(), null, Scope.APPLICATION); }
Example #26
Source File: IssueUnitTest.java From cxf with Apache License 2.0 | 5 votes |
/** * Test to successfully issue a single (dummy) token. */ @org.junit.Test public void testIssueSingleToken() throws Exception { TokenIssueOperation issueOperation = new TokenIssueOperation(); // Add Token Provider List<TokenProvider> providerList = new ArrayList<>(); providerList.add(new DummyTokenProvider()); issueOperation.setTokenProviders(providerList); // Add Service ServiceMBean service = new StaticService(); service.setEndpoints(Collections.singletonList("http://dummy-service.com/dummy")); issueOperation.setServices(Collections.singletonList(service)); // Add STSProperties object STSPropertiesMBean stsProperties = new StaticSTSProperties(); issueOperation.setStsProperties(stsProperties); // Mock up a request RequestSecurityTokenType request = new RequestSecurityTokenType(); JAXBElement<String> tokenType = new JAXBElement<String>( QNameConstants.TOKEN_TYPE, String.class, DummyTokenProvider.TOKEN_TYPE ); request.getAny().add(tokenType); request.getAny().add(createAppliesToElement("http://dummy-service.com/dummy")); // Mock up message context MessageImpl msg = new MessageImpl(); WrappedMessageContext msgCtx = new WrappedMessageContext(msg); // Issue a token RequestSecurityTokenResponseType response = issueOperation.issueSingle(request, null, msgCtx); assertFalse(response.getAny().isEmpty()); }
Example #27
Source File: IssueUnitTest.java From cxf with Apache License 2.0 | 5 votes |
/** * Test that a request with no AppliesTo is not rejected */ @org.junit.Test public void testNoAppliesTo() throws Exception { TokenIssueOperation issueOperation = new TokenIssueOperation(); // Add Token Provider List<TokenProvider> providerList = new ArrayList<>(); providerList.add(new DummyTokenProvider()); issueOperation.setTokenProviders(providerList); // Add Service ServiceMBean service = new StaticService(); service.setEndpoints(Collections.singletonList("http://dummy-service.com/dummy")); issueOperation.setServices(Collections.singletonList(service)); // Add STSProperties object STSPropertiesMBean stsProperties = new StaticSTSProperties(); issueOperation.setStsProperties(stsProperties); // Mock up a request RequestSecurityTokenType request = new RequestSecurityTokenType(); JAXBElement<String> tokenType = new JAXBElement<String>( QNameConstants.TOKEN_TYPE, String.class, DummyTokenProvider.TOKEN_TYPE ); request.getAny().add(tokenType); // Mock up message context MessageImpl msg = new MessageImpl(); WrappedMessageContext msgCtx = new WrappedMessageContext(msg); // Issue a token RequestSecurityTokenResponseCollectionType response = issueOperation.issue(request, null, msgCtx); List<RequestSecurityTokenResponseType> securityTokenResponse = response.getRequestSecurityTokenResponse(); assertFalse(securityTokenResponse.isEmpty()); }
Example #28
Source File: SonosService.java From airsonic-advanced with GNU General Public License v3.0 | 5 votes |
private SoapMessage getMessage() { MessageContext messageContext = context == null ? null : context.getMessageContext(); if (messageContext == null || !(messageContext instanceof WrappedMessageContext)) { return null; } return (SoapMessage) ((WrappedMessageContext) messageContext).getWrappedMessage(); }
Example #29
Source File: ValidateJWTTransformationTest.java From cxf with Apache License 2.0 | 5 votes |
private TokenProviderParameters createProviderParameters( String tokenType, String keyType, Crypto crypto, String signatureUsername, CallbackHandler callbackHandler ) throws WSSecurityException { TokenProviderParameters parameters = new TokenProviderParameters(); TokenRequirements tokenRequirements = new TokenRequirements(); tokenRequirements.setTokenType(tokenType); parameters.setTokenRequirements(tokenRequirements); KeyRequirements keyRequirements = new KeyRequirements(); keyRequirements.setKeyType(keyType); parameters.setKeyRequirements(keyRequirements); parameters.setPrincipal(new CustomTokenPrincipal("alice")); // Mock up message context MessageImpl msg = new MessageImpl(); WrappedMessageContext msgCtx = new WrappedMessageContext(msg); parameters.setMessageContext(msgCtx); parameters.setAppliesToAddress("http://dummy-service.com/dummy"); // Add STSProperties object StaticSTSProperties stsProperties = new StaticSTSProperties(); stsProperties.setSignatureCrypto(crypto); stsProperties.setSignatureUsername(signatureUsername); stsProperties.setCallbackHandler(callbackHandler); stsProperties.setIssuer("STS"); parameters.setStsProperties(stsProperties); parameters.setEncryptionProperties(new EncryptionProperties()); return parameters; }
Example #30
Source File: ResourceLocal.java From cxf with Apache License 2.0 | 5 votes |
@Override public PutResponse put(Put body) { // Getting reference paramaters AddressingProperties addrProps = (AddressingProperties) ((WrappedMessageContext) context .getMessageContext()).getWrappedMessage() .getContextualProperty(JAXWSAConstants.ADDRESSING_PROPERTIES_INBOUND); ReferenceParametersType refParams = addrProps .getToEndpointReference() .getReferenceParameters(); // Getting representation from the ResourceManager Representation storedRepresentation = manager.get(refParams); // Getting representation from the incoming SOAP message. This representation will be stored. Representation putRepresentation = body.getRepresentation(); // Dialect processing if (body.getDialect() != null && !body.getDialect().isEmpty()) { if (dialects.containsKey(body.getDialect())) { Dialect dialect = dialects.get(body.getDialect()); putRepresentation = dialect.processPut(body, storedRepresentation); } else { throw new UnknownDialect(); } } ValidAndTransformHelper.validationAndTransformation( resourceTypeIdentifiers, putRepresentation, storedRepresentation); manager.put(refParams, putRepresentation); PutResponse response = new PutResponse(); response.setRepresentation(putRepresentation); return response; }