Package org.apache.xml.security.exceptions

Examples of org.apache.xml.security.exceptions.XMLSecurityException


                     ._TAG_EXPONENT, Constants.SignatureSpecNS));
         PublicKey pk = rsaFactory.generatePublic(rsaKeyspec);

         return pk;
      } catch (NoSuchAlgorithmException ex) {
         throw new XMLSecurityException("empty", ex);
      } catch (InvalidKeySpecException ex) {
         throw new XMLSecurityException("empty", ex);
      }
   }
View Full Code Here


    private void checkEncryptionAlgorithms(AlgorithmSuiteSecurityEvent event)
        throws XMLSecurityException {
        if (XMLSecurityConstants.Enc.equals(event.getAlgorithmUsage())
            && encryptionProperties.getEncryptionSymmetricKeyAlgo() != null
            && !encryptionProperties.getEncryptionSymmetricKeyAlgo().equals(event.getAlgorithmURI())) {
            throw new XMLSecurityException("empty", "The symmetric encryption algorithm "
                                           + event.getAlgorithmURI() + " is not allowed");
        } else if ((XMLSecurityConstants.Sym_Key_Wrap.equals(event.getAlgorithmUsage())
            || XMLSecurityConstants.Asym_Key_Wrap.equals(event.getAlgorithmUsage()))
            && encryptionProperties.getEncryptionKeyTransportAlgo() != null
            && !encryptionProperties.getEncryptionKeyTransportAlgo().equals(event.getAlgorithmURI())) {
            throw new XMLSecurityException("empty", "The key transport algorithm "
                + event.getAlgorithmURI() + " is not allowed");
        } else if (XMLSecurityConstants.EncDig.equals(event.getAlgorithmUsage())
            && encryptionProperties.getEncryptionDigestAlgo() != null
            && !encryptionProperties.getEncryptionDigestAlgo().equals(event.getAlgorithmURI())) {
            throw new XMLSecurityException("empty", "The encryption digest algorithm "
                + event.getAlgorithmURI() + " is not allowed");
        }
    }
View Full Code Here

        throws XMLSecurityException {
        if ((XMLSecurityConstants.Asym_Sig.equals(event.getAlgorithmUsage())
            || XMLSecurityConstants.Sym_Sig.equals(event.getAlgorithmUsage()))
            && sigProps.getSignatureAlgo() != null
            && !sigProps.getSignatureAlgo().equals(event.getAlgorithmURI())) {
            throw new XMLSecurityException("empty", "The signature algorithm "
                                           + event.getAlgorithmURI() + " is not allowed");
        } else if (XMLSecurityConstants.SigDig.equals(event.getAlgorithmUsage())
            && sigProps.getSignatureDigestAlgo() != null
            && !sigProps.getSignatureDigestAlgo().equals(event.getAlgorithmURI())) {
            throw new XMLSecurityException("empty", "The signature digest algorithm "
                + event.getAlgorithmURI() + " is not allowed");
        } else if (XMLSecurityConstants.SigC14n.equals(event.getAlgorithmUsage())
            && sigProps.getSignatureC14nMethod() != null
            && !sigProps.getSignatureC14nMethod().equals(event.getAlgorithmURI())) {
            throw new XMLSecurityException("empty", "The signature c14n algorithm "
                + event.getAlgorithmURI() + " is not allowed");
        } else if (XMLSecurityConstants.SigTransform.equals(event.getAlgorithmUsage())
            && !XMLSecurityConstants.NS_XMLDSIG_ENVELOPED_SIGNATURE.equals(event.getAlgorithmURI())
            && sigProps.getSignatureC14nTransform() != null
            && !sigProps.getSignatureC14nTransform().equals(event.getAlgorithmURI())) {
            throw new XMLSecurityException("empty", "The signature transformation algorithm "
                + event.getAlgorithmURI() + " is not allowed");
        }
    }
View Full Code Here

           
            // validate trust
            try {
                new TrustValidator().validateTrust(sigCrypto, cert, publicKey);
            } catch (WSSecurityException e) {
                throw new XMLSecurityException("empty", "Error during Signature Trust "
                                               + "validation: " + e.getMessage());
            }
           
            if (persistSignature) {
                msg.setContent(X509Certificate.class, cert);
View Full Code Here

            final List<SecurityEvent> incomingSecurityEventList =
                (List<SecurityEvent>)message.get(SecurityEvent.class.getName() + ".in");

            if (incomingSecurityEventList == null) {
                LOG.warning("Security processing failed (actions mismatch)");
                XMLSecurityException ex =
                    new XMLSecurityException("empty", "The request was not signed or encrypted");
                throwFault(ex.getMessage(), ex);
            }
           
            if (signatureRequired) {
                Event requiredEvent = SecurityEventConstants.SignatureValue;
                if (!isEventInResults(requiredEvent, incomingSecurityEventList)) {
                    LOG.warning("The request was not signed");
                    XMLSecurityException ex =
                        new XMLSecurityException("empty", "The request was not signed");
                    throwFault(ex.getMessage(), ex);
                }
            }
           
            if (encryptionRequired) {
                boolean foundEncryptionPart =
                    isEventInResults(SecurityEventConstants.EncryptedElement, incomingSecurityEventList);
                if (!foundEncryptionPart) {
                    LOG.warning("The request was not encrypted");
                    XMLSecurityException ex =
                        new XMLSecurityException("empty", "The request was not encrypted");
                    throwFault(ex.getMessage(), ex);
                }
            }
           
        }
View Full Code Here

      }

      if (nodes.getLength() == 0) {
         Object exArgs[] = { "Elements", Constants._TAG_X509DATA };

         throw new XMLSecurityException("xml.WrongContent", exArgs);
      }

      for (int i = 0; i < nodes.getLength(); i++) {
         Element currentElem = (Element) nodes.item(i);
         String localname = currentElem.getLocalName();
View Full Code Here

      Vector v = (Vector) this._algorithmHash.get(algorithmURI);

      if (v == null) {
         Object exArgs[] = { "Could not find a registered Provider" };

         throw new XMLSecurityException("empty");
      }

      searchForWorkingClass: for (int i = 0; i < v.size(); i++) {
         try {
            String implementingClass = (String) v.elementAt(i);

            this._emSpi =
               (EncryptionMethodSpi) Class.forName(implementingClass)
                  .newInstance();

            if ((this._emSpi != null)
                    && this._emSpi.getRequiredProviderAvailable()) {
               cat.debug("Create URI \"" + algorithmURI + "\" class \""
                         + implementingClass + "\"");

               break searchForWorkingClass;
            }
         } catch (ClassNotFoundException ex) {
            throw new XMLSecurityException("empty", ex);
         } catch (IllegalAccessException ex) {
            throw new XMLSecurityException("empty", ex);
         } catch (InstantiationException ex) {
            throw new XMLSecurityException("empty", ex);
         }
      }

      if (this._emSpi == null) {
         Object exArgs[] = { "Could not find a registered Provider" };

         throw new XMLSecurityException("empty");
      }

      this._encMethodParams = this._emSpi.engineInit(doc, params);

      if (this._encMethodParams != null) {
View Full Code Here

      Vector v = (Vector) this._algorithmHash.get(algorithmURI);

      if (v == null) {
         Object exArgs[] = { "Could not find a registered Provider" };

         throw new XMLSecurityException("empty");
      }

      searchForWorkingClass: for (int i = 0; i < v.size(); i++) {
         try {
            String implementingClass = (String) v.elementAt(i);

            this._emSpi =
               (EncryptionMethodSpi) Class.forName(implementingClass)
                  .newInstance();

            if ((this._emSpi != null)
                    && this._emSpi.getRequiredProviderAvailable()) {
               cat.debug("Create URI \"" + algorithmURI + "\" class \""
                         + implementingClass + "\"");

               break searchForWorkingClass;
            }
         } catch (ClassNotFoundException ex) {
            throw new XMLSecurityException("empty", ex);
         } catch (IllegalAccessException ex) {
            throw new XMLSecurityException("empty", ex);
         } catch (InstantiationException ex) {
            throw new XMLSecurityException("empty", ex);
         }
      }

      if (this._emSpi == null) {
         Object exArgs[] = { "Could not find a registered Provider" };

         throw new XMLSecurityException("empty");
      }

      this._encMethodParams = this._emSpi.engineInit(this._constructionElement);
   }
View Full Code Here

      if (encryptionMethod != null) {
         if (!encryptionMethod.getUsableInEncryptedKey()) {
            Object exArgs[] = { encryptionMethod.getAlgorithmURI() };

            throw new XMLSecurityException(
               "encryption.algorithmCannotBeUsedForEncryptedKey", exArgs);
         }

         this._constructionElement.appendChild(encryptionMethod.getElement());
         XMLUtils.addReturnToElement(this._constructionElement);
View Full Code Here

                                             encryptionMethodParams);

      if (!encryptionMethod.getUsableInEncryptedKey()) {
         Object exArgs[] = { encryptionMethod.getAlgorithmURI() };

         throw new XMLSecurityException(
            "encryption.algorithmCannotBeUsedForEncryptedKey", exArgs);
      }

      this._constructionElement.appendChild(encryptionMethod.getElement());
      XMLUtils.addReturnToElement(this._constructionElement);
View Full Code Here

TOP

Related Classes of org.apache.xml.security.exceptions.XMLSecurityException

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.