/** Constructor. */ public BaseMetadataProvider() { requireValidMetadata = false; unmarshallerFactory = Configuration.getUnmarshallerFactory(); }
/** * Constructor. */ protected AbstractXMLObjectUnmarshaller() { xmlObjectBuilderFactory = Configuration.getBuilderFactory(); unmarshallerFactory = Configuration.getUnmarshallerFactory(); }
/** * Constructor. */ protected AbstractXMLObjectUnmarshaller() { xmlObjectBuilderFactory = Configuration.getBuilderFactory(); unmarshallerFactory = Configuration.getUnmarshallerFactory(); }
/** * Constructor. * * @param newResolver resolver for data encryption keys. * @param newKEKResolver resolver for key encryption keys. * @param newEncKeyResolver resolver for EncryptedKey elements */ public Decrypter(KeyInfoCredentialResolver newResolver, KeyInfoCredentialResolver newKEKResolver, EncryptedKeyResolver newEncKeyResolver) { resolver = newResolver; kekResolver = newKEKResolver; encKeyResolver = newEncKeyResolver; resolverCriteria = null; kekResolverCriteria = null; // Note: Use of this internal JAXP ParserPool is hopefully only temporary, // to be replaced when Xerces implements DOM 3 LSParser.parseWithContext(...). parserPool = buildParserPool(); unmarshallerFactory = Configuration.getUnmarshallerFactory(); defaultRootInNewDocument = false; }
/** * Constructor. * * @param newResolver resolver for data encryption keys. * @param newKEKResolver resolver for key encryption keys. * @param newEncKeyResolver resolver for EncryptedKey elements */ public Decrypter(KeyInfoCredentialResolver newResolver, KeyInfoCredentialResolver newKEKResolver, EncryptedKeyResolver newEncKeyResolver) { resolver = newResolver; kekResolver = newKEKResolver; encKeyResolver = newEncKeyResolver; resolverCriteria = null; kekResolverCriteria = null; // Note: Use of this internal JAXP ParserPool is hopefully only temporary, // to be replaced when Xerces implements DOM 3 LSParser.parseWithContext(...). parserPool = buildParserPool(); unmarshallerFactory = Configuration.getUnmarshallerFactory(); defaultRootInNewDocument = false; }
/** * Creates the SAML object from the element This method must be called first * * @param elem * @throws UnmarshallingException If the token creation fails */ @Override public void createToken(Element elem) throws UnmarshallingException { UnmarshallerFactory unmarshallerFactory = Configuration.getUnmarshallerFactory(); Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(elem); assertion = (Assertion) unmarshaller.unmarshall(elem); }
/** * Creates the SAML object from the element This method must be called first * * @param elem * @throws UnmarshallingException If the token creation fails */ @Override public void createToken(Element elem) throws UnmarshallingException { UnmarshallerFactory unmarshallerFactory = Configuration.getUnmarshallerFactory(); Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(elem); assertion = (Assertion) unmarshaller.unmarshall(elem); }
/** * This constructor supports checking a DOM Element to be unmarshalled, either element name or schema type, against * a given namespace/local name pair. * * @deprecated no replacement * * @param targetNamespaceURI the namespace URI of either the schema type QName or element QName of the elements this * unmarshaller operates on * @param targetLocalName the local name of either the schema type QName or element QName of the elements this * unmarshaller operates on */ protected AbstractXMLObjectUnmarshaller(String targetNamespaceURI, String targetLocalName) { targetQName = XMLHelper.constructQName(targetNamespaceURI, targetLocalName, null); xmlObjectBuilderFactory = Configuration.getBuilderFactory(); unmarshallerFactory = Configuration.getUnmarshallerFactory(); }
/** * This constructor supports checking a DOM Element to be unmarshalled, either element name or schema type, against * a given namespace/local name pair. * * @deprecated no replacement * * @param targetNamespaceURI the namespace URI of either the schema type QName or element QName of the elements this * unmarshaller operates on * @param targetLocalName the local name of either the schema type QName or element QName of the elements this * unmarshaller operates on */ protected AbstractXMLObjectUnmarshaller(String targetNamespaceURI, String targetLocalName) { targetQName = XMLHelper.constructQName(targetNamespaceURI, targetLocalName, null); xmlObjectBuilderFactory = Configuration.getBuilderFactory(); unmarshallerFactory = Configuration.getUnmarshallerFactory(); }
/** * Get a KeyInfo unmarshaller. * * @return a KeyInfo unmarshaller * @throws SecurityException thrown if there is an error obtaining the unmarshaller from the configuration */ private Unmarshaller getUnmarshaller() throws SecurityException { if (keyInfoUnmarshaller != null) { return keyInfoUnmarshaller; } keyInfoUnmarshaller = Configuration.getUnmarshallerFactory().getUnmarshaller(KeyInfo.DEFAULT_ELEMENT_NAME); if (keyInfoUnmarshaller == null) { throw new SecurityException("Could not obtain KeyInfo unmarshaller from the configuration"); } return keyInfoUnmarshaller; }
/** * Initialise the SAML library */ public static synchronized void initSamlEngine() { if (!samlEngineInitialized) { if (LOG.isDebugEnabled()) { LOG.debug("Initializing the opensaml2 library..."); } try { OpenSAMLBootstrap.bootstrap(); builderFactory = Configuration.getBuilderFactory(); marshallerFactory = Configuration.getMarshallerFactory(); unmarshallerFactory = Configuration.getUnmarshallerFactory(); samlEngineInitialized = true; if (LOG.isDebugEnabled()) { LOG.debug("opensaml2 library bootstrap complete"); } } catch (ConfigurationException e) { LOG.error( "Unable to bootstrap the opensaml2 library - all SAML operations will fail", e ); } } }
/** * Get a KeyInfo unmarshaller. * * @return a KeyInfo unmarshaller * @throws SecurityException thrown if there is an error obtaining the unmarshaller from the configuration */ private Unmarshaller getUnmarshaller() throws SecurityException { if (keyInfoUnmarshaller != null) { return keyInfoUnmarshaller; } keyInfoUnmarshaller = Configuration.getUnmarshallerFactory().getUnmarshaller(KeyInfo.DEFAULT_ELEMENT_NAME); if (keyInfoUnmarshaller == null) { throw new SecurityException("Could not obtain KeyInfo unmarshaller from the configuration"); } return keyInfoUnmarshaller; }
/** * Initialise the SAML library */ public static synchronized void initSamlEngine() { if (!samlEngineInitialized) { if (LOG.isDebugEnabled()) { LOG.debug("Initializing the opensaml2 library..."); } try { OpenSAMLBootstrap.bootstrap(); builderFactory = Configuration.getBuilderFactory(); marshallerFactory = Configuration.getMarshallerFactory(); unmarshallerFactory = Configuration.getUnmarshallerFactory(); samlEngineInitialized = true; if (LOG.isDebugEnabled()) { LOG.debug("opensaml2 library bootstrap complete"); } } catch (ConfigurationException e) { LOG.error( "Unable to bootstrap the opensaml2 library - all SAML operations will fail", e ); } } }
/** * Initialise the SAML library */ public synchronized static void initSamlEngine() { if (!samlEngineInitialized) { if (log.isDebugEnabled()) { log.debug("Initilizing the opensaml2 library..."); } try { DefaultBootstrap.bootstrap(); builderFactory = Configuration.getBuilderFactory(); marshallerFactory = Configuration.getMarshallerFactory(); unmarshallerFactory = Configuration.getUnmarshallerFactory(); samlEngineInitialized = true; if (log.isDebugEnabled()) { log.debug("opensaml2 library bootstrap complete"); } } catch (ConfigurationException e) { log.error( "Unable to bootstrap the opensaml2 library - all SAML operations will fail", e ); } } }
private static Assertion unmarshellElement(OMElement omAssertion) throws Exception{ if(omAssertion.getLocalName().equals("Assertion")){ try{ UnmarshallerFactory factory = Configuration.getUnmarshallerFactory (); javax.xml.namespace.QName qname = omAssertion.getQName(); Unmarshaller unmarsh = factory.getUnmarshaller(qname); if(unmarsh == null){ throw new Exception("Unmarshell Exception"); } Assertion assertion; assertion = (Assertion)unmarsh.unmarshall(XMLUtils.toDOM(omAssertion)); return assertion; } catch(Exception e){ throw e ; } } return null ; }
/** * Constructor. * */ public Encrypter() { UnmarshallerFactory unmarshallerFactory = Configuration.getUnmarshallerFactory(); encryptedDataUnmarshaller = unmarshallerFactory.getUnmarshaller(EncryptedData.DEFAULT_ELEMENT_NAME); encryptedKeyUnmarshaller = unmarshallerFactory.getUnmarshaller(EncryptedKey.DEFAULT_ELEMENT_NAME); XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory(); keyInfoBuilder = (XMLSignatureBuilder<KeyInfo>) builderFactory.getBuilder(KeyInfo.DEFAULT_ELEMENT_NAME); jcaProviderName = null; }
/** * Constructor. * */ public Encrypter() { UnmarshallerFactory unmarshallerFactory = Configuration.getUnmarshallerFactory(); encryptedDataUnmarshaller = unmarshallerFactory.getUnmarshaller(EncryptedData.DEFAULT_ELEMENT_NAME); encryptedKeyUnmarshaller = unmarshallerFactory.getUnmarshaller(EncryptedKey.DEFAULT_ELEMENT_NAME); XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory(); keyInfoBuilder = (XMLSignatureBuilder<KeyInfo>) builderFactory.getBuilder(KeyInfo.DEFAULT_ELEMENT_NAME); jcaProviderName = null; }
Unmarshaller unmarshaller = Configuration.getUnmarshallerFactory().getUnmarshaller(messageElem); if (unmarshaller == null) { log.error("Unable to unmarshall Reader, no unmarshaller registered for element "
/** * Unmarshalls the incoming response from a POST request. * * @param responseStream input stream bearing the response * * @return the response * * @throws SOAPClientException thrown if the incoming response can not be unmarshalled into an {@link Envelope} */ protected Envelope unmarshallResponse(InputStream responseStream) throws SOAPClientException { try { Element responseElem = parserPool.parse(responseStream).getDocumentElement(); if (log.isDebugEnabled()) { log.debug("Inbound SOAP message was:\n" + XMLHelper.prettyPrintXML(responseElem)); } Unmarshaller unmarshaller = Configuration.getUnmarshallerFactory().getUnmarshaller(responseElem); return (Envelope) unmarshaller.unmarshall(responseElem); } catch (XMLParserException e) { throw new SOAPClientException("Unable to parse the XML within the response", e); } catch (UnmarshallingException e) { throw new SOAPClientException("unable to unmarshall the response DOM", e); } }
/** {@inheritDoc} */ public Signature unmarshall(Element signatureElement) throws UnmarshallingException { log.debug("Starting to unmarshall Apache XML-Security-based SignatureImpl element"); SignatureImpl signature = new SignatureImpl(signatureElement.getNamespaceURI(), signatureElement.getLocalName(), signatureElement.getPrefix()); try { log.debug("Constructing Apache XMLSignature object"); XMLSignature xmlSignature = new XMLSignature(signatureElement, ""); SignedInfo signedInfo = xmlSignature.getSignedInfo(); log.debug("Adding canonicalization and signing algorithms, and HMAC output length to Signature"); signature.setCanonicalizationAlgorithm(signedInfo.getCanonicalizationMethodURI()); signature.setSignatureAlgorithm(signedInfo.getSignatureMethodURI()); signature.setHMACOutputLength(getHMACOutputLengthValue(signedInfo.getSignatureMethodElement())); org.apache.xml.security.keys.KeyInfo xmlSecKeyInfo = xmlSignature.getKeyInfo(); if (xmlSecKeyInfo != null) { log.debug("Adding KeyInfo to Signature"); Unmarshaller unmarshaller = Configuration.getUnmarshallerFactory().getUnmarshaller( xmlSecKeyInfo.getElement()); KeyInfo keyInfo = (KeyInfo) unmarshaller.unmarshall(xmlSecKeyInfo.getElement()); signature.setKeyInfo(keyInfo); } signature.setXMLSignature(xmlSignature); signature.setDOM(signatureElement); return signature; } catch (XMLSecurityException e) { log.error("Error constructing Apache XMLSignature instance from Signature element: {}", e.getMessage()); throw new UnmarshallingException("Unable to unmarshall Signature with Apache XMLSignature", e); } }