Package org.apache.xml.security.utils.resolver

Examples of org.apache.xml.security.utils.resolver.ResourceResolverException


      try
         AttachmentPart _part =
              ((SecurableSoapMessage)soapMsg).getAttachmentPart(uriNodeValue);
         if (_part == null) {
             // log
             throw new ResourceResolverException("empty", uri, baseUri);
         }
         Object[] obj = AttachmentSignatureInput._getSignatureInput(_part);
         result = new AttachmentSignatureInput((byte[])obj[1]);
         ((AttachmentSignatureInput)result).setMimeHeaders((Vector)obj[0]);
         ((AttachmentSignatureInput)result).setContentType(_part.getContentType());
      } catch (Exception e) {
         // log
         throw new ResourceResolverException("empty", e, uri, baseUri);
      }

      try {
         URI uriNew = new URI(new URI(baseUri), uriNodeValue);
         result.setSourceURI(uriNew.toString());
View Full Code Here


      XMLSignatureInput result = null;
      try {
         uriNew = getNewURI(uri.getNodeValue(), baseUri);
      } catch (URI.MalformedURIException ex) {
         // log         
         throw new ResourceResolverException("empty", ex, uri, baseUri);
      }

      if (soapMsg == null) throw generateException(uri, baseUri, errors[1]);

      try
         AttachmentPart _part = ((SecurableSoapMessage)soapMsg).getAttachmentPart(uriNew.toString());
         if (_part == null) {
             // log 
             throw new URIResolverException();
         }
         Object[] obj = AttachmentSignatureInput._getSignatureInput(_part);
         result = new AttachmentSignatureInput((byte[])obj[1]);
         ((AttachmentSignatureInput)result).setMimeHeaders((Vector)obj[0]);
         ((AttachmentSignatureInput)result).setContentType(_part.getContentType());
      } catch (XWSSecurityException e) {
         throw new ResourceResolverException("empty", e, uri, baseUri);
      } catch (SOAPException spe) {
         // log
         throw new ResourceResolverException("empty", spe, uri, baseUri);
      } catch (java.io.IOException ioe) {
         // log
         throw new ResourceResolverException("empty", ioe, uri, baseUri);
      }


      result.setSourceURI(uriNew.toString());
      return result;
View Full Code Here

        return element;
    }

    private ResourceResolverException generateException(Attr uri, String baseUri, String error) {
        XWSSecurityException xwssE = new XWSSecurityException(error);
        return new ResourceResolverException("empty", xwssE, uri, baseUri);
    }
View Full Code Here

         } else {
            String errMsg = "You did not supply enough data!!! There are only "
                            + (this._data2.length) + " byte[] arrays";
            Object exArgs[] = { errMsg };

            throw new ResourceResolverException("empty", exArgs, uri, BaseURI);
         }
      } else {
         Object exArgs[] = { "You did not supply data !!!" };

         throw new ResourceResolverException("empty", exArgs, uri, BaseURI);
      }

      return result;
   }
View Full Code Here

                result.setSourceURI(uriNew.toString());

                return result;
            } catch (Exception ex) {
                throw new ResourceResolverException(
                    "generic.EmptyMessage", ex, uri, baseURI
                );
            }
        }
View Full Code Here

                String mapping = parts[i].substring(XNS_OPEN.length(), parts[i].length() - 1);

                int pos = mapping.indexOf('=');

                if (pos <= 0 || pos >= mapping.length() - 1) {
                    throw new ResourceResolverException(
                        "malformed namespace part of XPointer expression", uri, BaseURI
                    );
                }

                namespaces.put(
                    mapping.substring(0, pos),
                    mapping.substring(pos + 1)
                );
            }
        }

        try {
            Node node = null;
            NodeList nodes = null;

            // plain ID reference.
            if (i == 0 && !parts[i].startsWith(XP_OPEN)) {
                node = this.baseNode.getOwnerDocument().getElementById(parts[i]);
            } else {
                if (!parts[i].endsWith(")") || !parts[i].startsWith(XP_OPEN)) {
                    return null;
                }

                String xpathExpr = parts[i].substring(XP_OPEN.length(), parts[i].length() - 1);

                XPathFactory xpf = XPathFactory.newInstance();
                XPath xpath = xpf.newXPath();
                DSNamespaceContext context =
                    new DSNamespaceContext(namespaces);
                xpath.setNamespaceContext(context);

                nodes =
                    (NodeList) xpath.evaluate(
                        xpathExpr, this.baseNode, XPathConstants.NODESET
                    );

                if (nodes.getLength() == 0) {
                    return null;
                }
                if (nodes.getLength() == 1) {
                    node = nodes.item(0);
                }
            }

            XMLSignatureInput result = null;

            if (node != null) {
                result = new XMLSignatureInput(node);
            } else if (nodes != null) {
                Set<Node> nodeSet = new HashSet<Node>(nodes.getLength());

                for (int j = 0; j < nodes.getLength(); ++j) {
                    nodeSet.add(nodes.item(j));
                }

                result = new XMLSignatureInput(nodeSet);
            } else {
                return null;
            }

            result.setMIMEType("text/xml");
            result.setExcludeComments(true);
            result.setSourceURI((BaseURI != null) ? BaseURI.concat(v) : v);     

            return result;
        } catch (XPathExpressionException e) {
            throw new ResourceResolverException(
                 "Problem evaluating XPath expression", e, uri, BaseURI
            );
        }
    }
View Full Code Here

            // calculate new URI
            URI uriNew = null;
            try {
                uriNew = getNewURI(uri.getNodeValue(), baseURI);
            } catch (URISyntaxException ex) {
                throw new ResourceResolverException("generic.EmptyMessage", ex, uri, baseURI);
            }

            URL url = uriNew.toURL();
            URLConnection urlConnection = url.openConnection();

            {
                // set proxy pass
                String proxyUser =
                    engineGetProperty(ResolverDirectHTTP.properties[ResolverDirectHTTP.HttpProxyUser]);
                String proxyPass =
                    engineGetProperty(ResolverDirectHTTP.properties[ResolverDirectHTTP.HttpProxyPass]);

                if ((proxyUser != null) && (proxyPass != null)) {
                    String password = proxyUser + ":" + proxyPass;
                    String encodedPassword = Base64.encode(password.getBytes("ISO-8859-1"));

                    // or was it Proxy-Authenticate ?
                    urlConnection.setRequestProperty("Proxy-Authorization", encodedPassword);
                }
            }

            {
                // check if Basic authentication is required
                String auth = urlConnection.getHeaderField("WWW-Authenticate");

                if (auth != null && auth.startsWith("Basic")) {
                    // do http basic authentication
                    String user =
                        engineGetProperty(ResolverDirectHTTP.properties[ResolverDirectHTTP.HttpBasicUser]);
                    String pass =
                        engineGetProperty(ResolverDirectHTTP.properties[ResolverDirectHTTP.HttpBasicPass]);

                    if ((user != null) && (pass != null)) {
                        urlConnection = url.openConnection();

                        String password = user + ":" + pass;
                        String encodedPassword = Base64.encode(password.getBytes("ISO-8859-1"));

                        // set authentication property in the http header
                        urlConnection.setRequestProperty("Authorization",
                                                         "Basic " + encodedPassword);
                    }
                }
            }

            String mimeType = urlConnection.getHeaderField("Content-Type");
            InputStream inputStream = urlConnection.getInputStream();
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            byte buf[] = new byte[4096];
            int read = 0;
            int summarized = 0;

            while ((read = inputStream.read(buf)) >= 0) {
                baos.write(buf, 0, read);
                summarized += read;
            }

            if (log.isDebugEnabled()) {
                log.debug("Fetched " + summarized + " bytes from URI " + uriNew.toString());
            }

            XMLSignatureInput result = new XMLSignatureInput(baos.toByteArray());

            result.setSourceURI(uriNew.toString());
            result.setMIMEType(mimeType);

            // switch off proxy usage
            if (useProxy && switchBackProxy) {
                System.setProperty("http.proxySet", oldProxySet);
                System.setProperty("http.proxyHost", oldProxyHost);
                System.setProperty("http.proxyPort", oldProxyPort);
            }

            return result;
        } catch (MalformedURLException ex) {
            throw new ResourceResolverException("generic.EmptyMessage", ex, uri, baseURI);
        } catch (IOException ex) {
            throw new ResourceResolverException("generic.EmptyMessage", ex, uri, baseURI);
        }
    }
View Full Code Here

            result.setSourceURI(uriNew.toString());

            return result;
        } catch (Exception e) {
            throw new ResourceResolverException("generic.EmptyMessage", e, uri, baseURI);
        }
    }
View Full Code Here

            String id = uriNodeValue.substring(1);

            selectedElem = doc.getElementById(id);
            if (selectedElem == null) {
                Object exArgs[] = { id };
                throw new ResourceResolverException(
                    "signature.Verification.MissingID", exArgs, uri, baseURI
                );
            }
            if (secureValidation) {
                Element start = uri.getOwnerDocument().getDocumentElement();
                if (!XMLUtils.protectAgainstWrappingAttack(start, id)) {
                    Object exArgs[] = { id };
                    throw new ResourceResolverException(
                        "signature.Verification.MultipleIDs", exArgs, uri, baseURI
                    );
                }
            }
            if (log.isDebugEnabled()) {
View Full Code Here

            } else {
                String errMsg = "You did not supply enough data!!! There are only "
                    + (this._data2.length) + " byte[] arrays";
                Object exArgs[] = { errMsg };

                throw new ResourceResolverException("empty", exArgs, uri, BaseURI);
            }
        } else {
            Object exArgs[] = { "You did not supply data !!!" };

            throw new ResourceResolverException("empty", exArgs, uri, BaseURI);
        }

        return result;
    }
View Full Code Here

TOP

Related Classes of org.apache.xml.security.utils.resolver.ResourceResolverException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.