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

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


            log.debug("KeyInfo does not contain any reference to a binary security token.", e);
         }
      }
      catch (XMLSecurityException e)
      {
         throw new WSSecurityException("Error decoding xml signature: " + e.getMessage(), e);
      }
   }
View Full Code Here


      if (id != null && id.length() > 0)
         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 && encodingType.length() > 0 && !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

   public Timestamp(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, Timestamp is missing an id");

      this.id = id;

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

      this.created = SimpleTypeBindings.unmarshalDateTime(XMLUtils.getFullTextChildrenFromElement(child));

      child = Util.getNextSiblingElement(child);
      if (child == null)
View Full Code Here

   }

   public SecurityTokenReference(Element element) throws WSSecurityException
   {
      if (! "SecurityTokenReference".equals(element.getLocalName()))
         throw new WSSecurityException("SecurityTokenReference was passed an invalid local name");

      String id = element.getAttributeNS(Constants.WSU_NS, Constants.ID);
      if (id == null || id.length() == 0)
         setId(id);

      Element child = Util.getFirstChildElement(element);
      if (child == null)
         throw new WSSecurityException("Invalid message, SecurityTokenRefence is empty: " + id);

      this.reference = Reference.getReference(child);
   }
View Full Code Here

   public DirectReference(Element element) throws WSSecurityException
   {
      this.doc = element.getOwnerDocument();

      if (!"Reference".equals(element.getLocalName()))
         throw new WSSecurityException("Invalid message, invalid local name on a DirectReference");

      String uri = element.getAttribute("URI");
      if (uri == null || uri.length() == 0)
         throw new WSSecurityException("Inavliad message, Reference element is missing a URI");

      setUri(uri);

      String valueType = element.getAttribute("ValueType");
      if (valueType == null || valueType.length() == 0)
         throw new WSSecurityException("Inavliad message, Reference element is missing a ValueType");

      setValueType(valueType);
   }
View Full Code Here

   {
      super(element.getOwnerDocument());

      String id = element.getAttributeNS(Constants.WSU_NS, Constants.ID);
      if (id == null || id.length() == 0)
         throw new WSSecurityException("Invalid message, BinarySecurityToken is missing an id");

      setId(id);

      if (! Constants.BASE64_ENCODING_TYPE.equals(element.getAttribute("EncodingType")))
         throw new WSSecurityException("Invalid encoding type (only base64 is supported) for token:" + id);

      setCert(decodeCert(XMLUtils.getFullTextChildrenFromElement(element)));
   }
View Full Code Here

         CertificateFactory factory = CertificateFactory.getInstance("X.509");
         return (X509Certificate)factory.generateCertificate(new ByteArrayInputStream(Base64.decode(data)));
      }
      catch(Exception e)
      {
         throw new WSSecurityException("Error decoding BinarySecurityToken: " + e.getMessage());
      }
   }
View Full Code Here

         {
            storeURL = storeFile.toURL();
         }
         catch (MalformedURLException e)
         {
            throw new WSSecurityException("Problems loading " + type + ": " + e.getMessage(), e);
         }
      }

      if (storeType == null)
         storeType = System.getProperty(property + "Type");
      if (storeType == null)
         storeType = "jks";

      KeyStore keyStore = null;
      try
      {
         log.debug("loadStore: " + storeURL);
         InputStream stream = storeURL.openStream();
         if (stream == null)
            throw new WSSecurityException("Cannot load store from: " + storeURL);

         keyStore = KeyStore.getInstance(storeType);
         if (keyStore == null)
            throw new WSSecurityException("Cannot get keystore for type: " + storeType);

         String decryptedPassword = decryptPassword(storePassword);
         if (decryptedPassword == null)
            throw new WSSecurityException("Cannot decrypt store password");

         keyStore.load(stream, decryptedPassword.toCharArray());
      }
      catch (RuntimeException rte)
      {
         throw rte;
      }
      catch (WSSecurityException ex)
      {
         throw ex;
      }
      catch (Exception ex)
      {
         throw new WSSecurityException("Problems loading " + type + ": " + ex.getMessage(), ex);
      }

      return keyStore;
   }
View Full Code Here

   private String decryptPassword(String password) throws WSSecurityException
   {
      log.trace("decrypt password: " + password);

      if (password == null)
         throw new WSSecurityException("Invalid null password for security store");

      if (password.charAt(0) == '{')
      {
         StringTokenizer tokenizer = new StringTokenizer(password, "{}");
         String keyStorePasswordCmdType = tokenizer.nextToken();
         String keyStorePasswordCmd = tokenizer.nextToken();
         if (keyStorePasswordCmdType.equals("EXT"))
         {
            password = execPasswordCmd(keyStorePasswordCmd);
         }
         else if (keyStorePasswordCmdType.equals("CLASS"))
         {
            password = invokePasswordClass(keyStorePasswordCmd);
         }
         else
         {
            throw new WSSecurityException("Unknown keyStorePasswordCmdType: " + keyStorePasswordCmdType);
         }
      }
      if (password == null)
         throw new WSSecurityException("Cannot decrypt password, result is null");

      log.trace("decrypted password: " + password);
      return password;
   }
View Full Code Here

         log.debug("Command exited with: " + status);
         return password;
      }
      catch (Exception e)
      {
         throw new WSSecurityException("Problems executing password cmd: " + keyStorePasswordCmd, e);
      }
   }
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.