private HTTPArtifactBinding artifactBinding(ParserPool parserPool, VelocityEngine velocityEngine, ArtifactResolutionProfile artifactResolutionProfile) { return new HTTPArtifactBinding(parserPool, velocityEngine, artifactResolutionProfile); }
public SAMLMessageContext sendMessage(SAMLMessageContext samlContext, boolean sign, String bindingName) throws SAMLException, MetadataProviderException, MessageEncodingException { return sendMessage(samlContext, sign, getBinding(bindingName)); }
/** * Method calls the processor and sends the message contained in the context. Subclasses can provide additional * processing before the message delivery. Message is sent using binding defined in the peer entity of the context. * * @param context context * @param sign whether the message should be signed * @throws MetadataProviderException metadata error * @throws SAMLException SAML encoding error * @throws org.opensaml.ws.message.encoder.MessageEncodingException * message encoding error */ protected void sendMessage(SAMLMessageContext context, boolean sign) throws MetadataProviderException, SAMLException, MessageEncodingException { processor.sendMessage(context, sign); }
@Bean public SAMLProcessorImpl processor() { HttpClient httpClient = new HttpClient(new MultiThreadedHttpConnectionManager()); ArtifactResolutionProfileImpl artifactResolutionProfile = new ArtifactResolutionProfileImpl(httpClient); HTTPSOAP11Binding soapBinding = new HTTPSOAP11Binding(parserPool()); artifactResolutionProfile.setProcessor(new SAMLProcessorImpl(soapBinding)); VelocityEngine velocityEngine = VelocityFactory.getEngine(); Collection<SAMLBinding> bindings = new ArrayList<>(); bindings.add(new HTTPRedirectDeflateBinding(parserPool())); bindings.add(new HTTPPostBinding(parserPool(), velocityEngine)); bindings.add(new HTTPArtifactBinding(parserPool(), velocityEngine, artifactResolutionProfile)); bindings.add(new HTTPSOAP11Binding(parserPool())); bindings.add(new HTTPPAOS11Binding(parserPool())); return new SAMLProcessorImpl(bindings); }
@VisibleForTesting protected HTTPArtifactBinding createDefaultArtifactBinding(ServiceProviderBuilder builder) { HttpClientParams params = new HttpClientParams(); params.setIntParameter(HttpConnectionParams.CONNECTION_TIMEOUT, 60000); HttpClient httpClient = new HttpClient(params, new MultiThreadedHttpConnectionManager()); ArtifactResolutionProfileImpl artifactResolutionProfile = new ArtifactResolutionProfileImpl(httpClient); builder.setSharedObject(ArtifactResolutionProfile.class, artifactResolutionProfile); HTTPSOAP11Binding soapBinding = new HTTPSOAP11Binding(parserPool); artifactResolutionProfile.setProcessor(new SAMLProcessorImpl(soapBinding)); return new HTTPArtifactBinding(parserPool, getVelocityEngine(), artifactResolutionProfile); }
private HTTPRedirectDeflateBinding httpRedirectDeflateBinding(ParserPool parserPool) { return new HTTPRedirectDeflateBinding(parserPool); }
private HTTPPostBinding httpPostBinding(ParserPool parserPool) { return new HTTPPostBinding(parserPool, VelocityFactory.getEngine()); }
@VisibleForTesting protected HTTPPAOS11Binding createDefaultPaosBinding() { return new HTTPPAOS11Binding(parserPool); }
@VisibleForTesting protected HTTPSOAP11Binding createDefaultSoapBinding() { return new HTTPSOAP11Binding(parserPool); }
@VisibleForTesting protected SAMLProcessorImpl createDefaultSamlProcessor(List<SAMLBinding> bindings) { return new SAMLProcessorImpl(bindings); }
/** * Loads incoming SAML message using one of the configured bindings and populates the SAMLMessageContext object with it. * * @param samlContext saml context * @param binding to use for message extraction * @return SAML message context with filled information about the message * @throws org.opensaml.common.SAMLException * error retrieving the message from the request * @throws org.opensaml.saml2.metadata.provider.MetadataProviderException * error retrieving metadat * @throws org.opensaml.ws.message.decoder.MessageDecodingException * error decoding the message * @throws org.opensaml.xml.security.SecurityException * error verifying message */ public SAMLMessageContext retrieveMessage(SAMLMessageContext samlContext, String binding) throws SAMLException, MetadataProviderException, MessageDecodingException, org.opensaml.xml.security.SecurityException { return retrieveMessage(samlContext, getBinding(binding)); }
/** * Determines binding to be used for the given endpoint. By default binding returned from getBinding call on the * endpoint is used. Speciall handling is used for Holder of Key WebSSO profile endpoints where real binding * is stored under hoksso:ProtocolBinding attribute. * * @param endpoint endpoint t * @return binding * @throws SAMLException in case binding can't be found * @throws MetadataProviderException in case binding of the endpoint can't be determined * @see SAMLUtil#getBindingForEndpoint(org.opensaml.saml2.metadata.Endpoint) */ protected SAMLBinding getBinding(Endpoint endpoint) throws SAMLException, MetadataProviderException { return getBinding(SAMLUtil.getBindingForEndpoint(endpoint)); }
/** * Analyzes the transport object and returns the first binding capable of sending/extracting a SAML message from to/from it. * In case no binding is found SAMLException is thrown. * * @param transport transport type to get binding for * @return decoder * @throws SAMLException in case no suitable decoder is found for given request */ protected SAMLBinding getBinding(InTransport transport) throws SAMLException { for (SAMLBinding binding : bindings) { if (binding.supports(transport)) { return binding; } } throw new SAMLException("Unsupported request"); }
@VisibleForTesting protected HTTPRedirectDeflateBinding createDefaultRedirectBinding() { return new HTTPRedirectDeflateBinding(parserPool); }
/** * A HTTP POST binding to use. * * @return The post binding * @see HTTPPostBinding */ @Bean public HTTPPostBinding httpPostBinding() { return new HTTPPostBinding(parserPool(), velocityEngine()); }
/** * A PAOS binding to use. * * @return The PAOS binding * @see HTTPPAOS11Binding */ @Bean public HTTPPAOS11Binding httpPAOS11Binding() { return new HTTPPAOS11Binding(parserPool()); }
/** * A SOAP binding to use. * * @return a SOAP binding * @see HTTPSOAP11Binding */ @Bean public HTTPSOAP11Binding soapBinding() { return new HTTPSOAP11Binding(parserPool()); }
private ArtifactResolutionProfile artifactResolutionProfile() { final ArtifactResolutionProfileImpl artifactResolutionProfile = new ArtifactResolutionProfileImpl(httpClient()); artifactResolutionProfile.setProcessor(new SAMLProcessorImpl(soapBinding())); return artifactResolutionProfile; }
/** * Loads incoming SAML message using one of the configured bindings and populates the SAMLMessageContext object with it. * * @param samlContext saml context * @return SAML message context with filled information about the message * @throws org.opensaml.common.SAMLException * error retrieving the message from the request * @throws org.opensaml.saml2.metadata.provider.MetadataProviderException * error retrieving metadat * @throws org.opensaml.ws.message.decoder.MessageDecodingException * error decoding the message * @throws org.opensaml.xml.security.SecurityException * error verifying message */ public SAMLMessageContext retrieveMessage(SAMLMessageContext samlContext) throws SAMLException, MetadataProviderException, MessageDecodingException, org.opensaml.xml.security.SecurityException { return retrieveMessage(samlContext, getBinding(samlContext.getInboundMessageTransport())); }
/** * Method calls the processor and sends the message contained in the context. Subclasses can provide additional * processing before the message delivery. Message is sent using the specified binding. * * @param context context * @param sign whether the message should be signed * @param binding binding to use to send the message * @throws MetadataProviderException metadata error * @throws SAMLException SAML encoding error * @throws org.opensaml.ws.message.encoder.MessageEncodingException * message encoding error */ protected void sendMessage(SAMLMessageContext context, boolean sign, String binding) throws MetadataProviderException, SAMLException, MessageEncodingException { processor.sendMessage(context, sign, binding); }