Package org.jboss.ws.extensions.security.exception

Examples of org.jboss.ws.extensions.security.exception.WSSecurityException


         signature = new XMLSignature(element, null);
         publicKey = resolver.resolvePublicKey(signature.getKeyInfo());
      }
      catch (XMLSecurityException e)
      {
         throw new WSSecurityException("Error decoding xml signature: " + e.getMessage(), e);
      }
   }
View Full Code Here


         list.add(id);
         cipher.doFinal(message, element, target.isContent());
      }
      catch (Exception e)
      {
         throw new WSSecurityException("Error encrypting target: " + name, e);
      }
   }
View Full Code Here

         kgen.init(alg.size);
         return kgen.generateKey();
      }
      catch (NoSuchAlgorithmException e)
      {
         throw new WSSecurityException(e.getMessage());
      }
   }
View Full Code Here

         cipher = XMLCipher.getInstance(algorithms.get(algorithm).xmlName);
         cipher.init(XMLCipher.ENCRYPT_MODE, secretKey);
      }
      catch (XMLSecurityException e)
      {
         throw new WSSecurityException("Error initializing xml cipher" + e.getMessage(), e);
      }

      ReferenceList list = new ReferenceList();

      if (targets == null || targets.size() == 0)
View Full Code Here

      X509Certificate cert = null;
      if (alias != null)
      {
         cert = store.getCertificate(alias);
         if (cert == null)
            throw new WSSecurityException("Cannot load certificate from keystore; alias = " + alias);
      }
      else
      {
         List<PublicKey> publicKeys = SignatureKeysAssociation.getPublicKeys();
         if (publicKeys != null && publicKeys.size() == 1)
            cert = store.getCertificateByPublicKey(publicKeys.iterator().next());
         if (cert == null)
            throw new WSSecurityException("Cannot get the certificate for message encryption! Verify the keystore contents, " +
                "considering the certificate is obtained through the alias specified in the encrypt configuration element " +
                "or (server side only) through a single key used to sign the incoming message.");
      }
      return cert;
   }
View Full Code Here

      {
         return false;
      }
      catch (Exception e)
      {
         throw new WSSecurityException("Error probing cryptographic permissions", e);
      }
   }
View Full Code Here

   private Element getHeader(Document message) throws WSSecurityException
   {
      Element header = Util.findElement(message.getDocumentElement(), "Security", Constants.WSSE_NS);
      if (header == null)
         throw new WSSecurityException("Expected security header was not found");

      return header;
   }
View Full Code Here

   public UsernameToken(Element element) throws WSSecurityException
   {
      this.doc = element.getOwnerDocument();
      String id = element.getAttributeNS(Constants.WSU_NS, Constants.ID);
      if (id == null || id.length() == 0)
         throw new WSSecurityException("Invalid message, UsernameToken is missing an id");

      setId(id);

      Element child = Util.getFirstChildElement(element);
      if (child == null || ! Constants.WSSE_NS.equals(child.getNamespaceURI()) || ! "Username".equals(child.getLocalName()))
         throw new WSSecurityException("Username child expected in UsernameToken element");

      this.username = XMLUtils.getFullTextChildrenFromElement(child);

      child = Util.getNextSiblingElement(child);
      if (child == null || ! Constants.WSSE_NS.equals(child.getNamespaceURI()) || ! "Password".equals(child.getLocalName()))
         throw new WSSecurityException("Password child expected in UsernameToken element");

      this.password = XMLUtils.getFullTextChildrenFromElement(child);
      String passwordType = child.getAttribute("Type");
      this.digest = Constants.PASSWORD_DIGEST_TYPE.equals(passwordType);
     
      Iterator<Element> itNonce = DOMUtils.getChildElements(element, new QName(Constants.WSSE_NS, "Nonce"));
      if (itNonce != null && itNonce.hasNext())
      {
         Element elem = itNonce.next();
         String encodingType = elem.getAttribute("EncodingType");
         if (encodingType != null && !Constants.BASE64_ENCODING_TYPE.equalsIgnoreCase(encodingType))
            throw new WSSecurityException("Unsupported nonce encoding type: " + encodingType);
         this.nonce = XMLUtils.getFullTextChildrenFromElement(elem);
      }
     
      Iterator<Element> itCreated = DOMUtils.getChildElements(element, new QName(Constants.WSSE_NS, "Created"));
      if (itCreated != null && itCreated.hasNext())
View Full Code Here

   private SecurityTokenReference extractSecurityTokenReference(KeyInfo info) throws WSSecurityException
   {
      Element child = Util.getFirstChildElement(info.getElement());
      if (child == null)
         throw new WSSecurityException("Empty KeyInfo");

      if (! child.getLocalName().equals("SecurityTokenReference"))
         throw new WSSecurityException("KeyInfo did not contain expected SecurityTokenReference, instead got: " + child.getLocalName());

      return new SecurityTokenReference(child);
   }
View Full Code Here

   public X509Certificate resolveCertificate(SecurityTokenReference reference) throws WSSecurityException
   {
      BinarySecurityToken token = resolve(reference);

      if (! (token instanceof X509Token))
         throw new WSSecurityException("Expected X509Token, cache contained: " + token.getClass().getName());

      return ((X509Token)token).getCert();
   }
View Full Code Here

TOP

Related Classes of org.jboss.ws.extensions.security.exception.WSSecurityException

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.