uri = new URI(uriReference.getURI()); } catch (URISyntaxException e) { throw new URIReferenceException("could not URL decode the uri: "+uriReference.getURI(), e); throw new URIReferenceException("I/O error: " + e.getMessage(), e);
public Data dereference(URIReference uriRef, XMLCryptoContext context) throws URIReferenceException { try{ String uri = null; uri = uriRef.getURI(); return dereferenceURI(uri,context); }catch(Exception ex){ // log here throw new URIReferenceException(ex); } } Data dereferenceURI(String uri, XMLCryptoContext context) throws URIReferenceException{
public Data dereference(URIReference uriReference, XMLCryptoContext context) throws URIReferenceException { if (null == uriReference) { throw new URIReferenceException("URIReference cannot be null"); throw new URIReferenceException("XMLCrytoContext cannot be null"); zipInputStream = new FileInputStream(this.tmpFile); } catch (FileNotFoundException e) { throw new URIReferenceException("file not found error: " + e.getMessage(), e); dataInputStream = ODFUtil.findDataInputStream(zipInputStream, uri); } catch (IOException e) { throw new URIReferenceException("I/O error: " + e.getMessage(), e);
public Data dereference (URIReference uriRef, XMLCryptoContext context) throws URIReferenceException { try{ String uri = null; uri = uriRef.getURI (); return dereferenceURI (uri,context); }catch(Exception ex){ throw new URIReferenceException (ex); } } Data dereferenceURI (String uri, XMLCryptoContext context) throws URIReferenceException{
public Data dereference(URIReference uriRef, XMLCryptoContext context) throws URIReferenceException { try{ String uri = null; uri = uriRef.getURI(); return dereferenceURI(uri,context); }catch(Exception ex){ // log here throw new URIReferenceException(ex); } } Data dereferenceURI(String uri, XMLCryptoContext context) throws URIReferenceException{
private Data dereferenceURI(final String uri, final XMLCryptoContext context) throws URIReferenceException{ try{ if(uri == null || uri.equals("")){ throw new UnsupportedOperationException("Empty Reference URI not supported"); } else if(uri.charAt(0) == '#'){ return dereferenceFragment(getIdFromFragmentRef(uri), context); } else if(uri.startsWith("cid:") || uri.startsWith("attachmentRef:")){ //throw new UnsupportedOperationException("Not supported in optimized path"); return dereferenceAttachments(uri, context); } else if(uri.startsWith("http")){ throw new UnsupportedOperationException("Not supported in optimized path"); } else { return dereferenceFragment(uri, context); } } catch(Exception e){ throw new URIReferenceException(e); } }
public Data dereference(URIReference uriReference, XMLCryptoContext context) throws URIReferenceException { if (null == uriReference) { throw new URIReferenceException("URIReference cannot be null"); throw new URIReferenceException("XMLCrytoContext cannot be null"); zipInputStream = new FileInputStream(this.tmpFile); } catch (FileNotFoundException e) { throw new URIReferenceException("file not found error: " + e.getMessage(), e); dataInputStream = ODFUtil.findDataInputStream(zipInputStream, uri); } catch (IOException e) { throw new URIReferenceException("I/O error: " + e.getMessage(), e);
public Data dereference(URIReference uriReference, XMLCryptoContext context) throws URIReferenceException { if (null == uriReference) { throw new NullPointerException("URIReference cannot be null"); } if (null == context) { throw new NullPointerException("XMLCrytoContext cannot be null"); } String uri = uriReference.getURI(); try { uri = URLDecoder.decode(uri, "UTF-8"); } catch (UnsupportedEncodingException e) { LOG.warn("could not URL decode the uri: " + uri); } LOG.debug("dereference: " + uri); try { InputStream dataInputStream = findDataInputStream(uri); if (null == dataInputStream) { LOG.debug("cannot resolve, delegating to base DOM URI dereferencer: " + uri); return this.baseUriDereferencer.dereference(uriReference, context); } return new OctetStreamData(dataInputStream, uri, null); } catch (IOException e) { throw new URIReferenceException("I/O error: " + e.getMessage(), e); } }
throw new URIReferenceException(e); Node root = (Node)i.next(); if ("RetrievalMethod".equals(root.getLocalName())) { throw new URIReferenceException( "It is forbidden to have one RetrievalMethod point " + "to another when secure validation is enabled");
protected static Node deReference(final Node node,XMLCryptoContext context)throws URIReferenceException { /*NodeList nodeList = ((Document)node).getElementsByTagNameNS(WSSE_EXT,"SecurityTokenReference"); final Node domNode = nodeList.item(0);*/ URIDereferencer dereferencer = context.getURIDereferencer(); //Dereference SecurityTokenReference; DOMURIReference domReference = new DOMURIReference(){ public Node getHere(){ return node; } public String getURI(){ return null; } public String getType(){ return null; } }; Data data = dereferencer.dereference(domReference, context); //Node parentNode = node.getParentNode(); Iterator nodeIterator = ((NodeSetData)data).iterator(); if(nodeIterator.hasNext()){ return (Node)nodeIterator.next(); }else{ throw new URIReferenceException("URI "+((Element)node).getAttribute("URI") + "not found"); } }
@Override public Data dereference(final URIReference uriReference, final XMLCryptoContext context) throws URIReferenceException { if (null == uriReference) { throw new IllegalArgumentException("La referencia no puede ser nula"); //$NON-NLS-1$ } if (null == context) { throw new IllegalArgumentException("El contexto de firma no puede ser nulo"); //$NON-NLS-1$ } String uri = uriReference.getURI(); try { uri = URLDecoder.decode(uri, StandardCharsets.UTF_8.name()); } catch (final UnsupportedEncodingException e) { Logger.getLogger("es.gob.afirma").warning("No se puede decodificar la URI '" + uri + "': " + e); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } try ( final InputStream dataInputStream = findDataInputStream(uri); ) { if (null == dataInputStream) { return this.baseUriDereferencer.dereference(uriReference, context); } final byte[] data = AOUtil.getDataFromInputStream(dataInputStream); dataInputStream.close(); return new OctetStreamData(new ByteArrayInputStream(data), uri, null); } catch (final IOException e) { throw new URIReferenceException("Error de I/O: " + e, e); //$NON-NLS-1$ } }
public XMLStructure dereferenceAsXMLStructure(XMLCryptoContext context) throws URIReferenceException { DocumentBuilder db = null; boolean secVal = Utils.secureValidation(context); ApacheData data = (ApacheData)dereference(context); try (InputStream is = new ByteArrayInputStream(data.getXMLSignatureInput().getBytes())) { db = XMLUtils.createDocumentBuilder(false, secVal); Document doc = db.parse(is); Element kiElem = doc.getDocumentElement(); if (kiElem.getLocalName().equals("X509Data") && XMLSignature.XMLNS.equals(kiElem.getNamespaceURI())) { return new DOMX509Data(kiElem); } else { return null; // unsupported } } catch (Exception e) { throw new URIReferenceException(e); } finally { if (db != null) { XMLUtils.repoolDocumentBuilder(db); } } }
throw new URIReferenceException("I/O error: " + e.getMessage(), e); } catch (SAXException e) { throw new URIReferenceException("SAX error: " + e.getMessage(), e);
logger.log (Level.FINEST,"Error occurred while resolving"+uri,ex); throw new URIReferenceException (ex.getMessage ());
private Data dereferenceAttachments(String cidRef) throws URIReferenceException{ AttachmentSet attachments = securityContext.getAttachmentSet(); if(attachments == null || attachments.isEmpty()){ throw new URIReferenceException ("Attachment Resource with Identifier "+cidRef+" was not found"); } Attachment attachment = attachments.get(cidRef); AttachmentData attachData = new AttachmentData(attachment); return attachData; }
Data dereferenceAttachments(final String uri, final XMLCryptoContext context) throws URIReferenceException{ JAXBFilterProcessingContext filterContext = (JAXBFilterProcessingContext) context.get(MessageConstants.WSS_PROCESSING_CONTEXT); SecuredMessage secureMsg = filterContext.getSecuredMessage(); Attachment attachment = secureMsg.getAttachment(uri); if(attachment == null){ throw new URIReferenceException ("Attachment Resource with Identifier "+uri+" was not found"); } AttachmentData attachData = new AttachmentData(attachment); return attachData; }
uri = new URI(uriReference.getURI()); } catch (URISyntaxException e) { throw new URIReferenceException("could not URL decode the uri: "+uriReference.getURI(), e); throw new URIReferenceException("I/O error: " + e.getMessage(), e);
Data dereferenceAttachments (String uri, XMLCryptoContext context) throws URIReferenceException, XWSSecurityException { boolean sunAttachmentTransformProvider = true; FilterProcessingContext filterContext =(FilterProcessingContext) context.get (MessageConstants.WSS_PROCESSING_CONTEXT); SecurableSoapMessage secureMsg = filterContext.getSecurableSoapMessage (); AttachmentPart attachment = secureMsg.getAttachmentPart (uri); if(attachment == null){ throw new URIReferenceException ("Attachment Resource with Identifier "+uri+" was not found"); } if(sunAttachmentTransformProvider){ AttachmentData attachData = new AttachmentData (); attachData.setAttachmentPart (attachment); return attachData; }else{ //Attachments need to be serialized and returned as OctectStreamData //attachment.getDataHandler(); // new OctectStreamData(); throw new UnsupportedOperationException ("Not yet supported "); } // throw new URIReferenceException("Attachment Resource with Identifier "+uri+" was not found"); }
if (!XMLUtils.protectAgainstWrappingAttack(start, (Element)referencedElem, id)) { String error = "Multiple Elements with the same ID " + id + " were detected"; throw new URIReferenceException(error); throw new URIReferenceException(e);
Element element = secureMsg.getElementById (uri); if(element == null){ throw new URIReferenceException ("Resource with fragment Identifier "+uri+" was not found");