activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1457307 [5/6] - in /activemq/activemq-cpp/trunk/activemq-cpp/src: main/ main/decaf/internal/ main/decaf/internal/net/ main/decaf/internal/security/ main/decaf/internal/security/provider/ main/decaf/internal/security/provider/crypto/ main/d...
Date Sat, 16 Mar 2013 21:14:12 GMT
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/cert/CertificateException.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/cert/CertificateException.h?rev=1457307&r1=1457306&r2=1457307&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/cert/CertificateException.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/cert/CertificateException.h Sat Mar 16 21:14:01 2013
@@ -21,43 +21,63 @@
 #include <decaf/util/Config.h>
 #include <decaf/security/GeneralSecurityException.h>
 
-namespace decaf{
-namespace security{
-namespace cert{
+namespace decaf {
+namespace security {
+namespace cert {
 
     /*
      * Indicates one of a variety of certificate problems.
      */
-    class DECAF_API CertificateException : public GeneralSecurityException
-    {
+    class DECAF_API CertificateException : public GeneralSecurityException {
     public:
 
         /**
          * Default Constructor
          */
-        CertificateException() throw() {};
+        CertificateException();
 
         /**
          * Conversion Constructor from some other Exception
+         *
          * @param ex
          *      An exception that should become this type of Exception
          */
-        CertificateException(const Exception& ex) throw()
-        : Exception()
-        {
-            *(Exception*)this = ex;
-        }
+        CertificateException(const Exception& ex);
 
         /**
          * Copy Constructor
+         *
          * @param ex
          *      An exception that should become this type of Exception
          */
-        CertificateException(const CertificateException& ex) throw()
-        : Exception()
-        {
-            *(Exception*)this = ex;
-        }
+        CertificateException(const CertificateException& ex);
+
+        /**
+         * Constructor - Initializes the file name and line number where
+         * this message occurred.  Sets the message to report, using an
+         * optional list of arguments to parse into the message.
+         *
+         * @param file
+         *      The file name where exception occurs
+         * @param lineNumber
+         *      The line number where the exception occurred.
+         * @param cause
+         *      The exception that was the cause for this one to be thrown.
+         * @param msg
+         *      The message to report
+         * @param ...
+         *      list of primitives that are formatted into the message
+         */
+        CertificateException(const char* file, const int lineNumber, const std::exception* cause, const char* msg, ...);
+
+        /**
+         * Constructor
+         *
+         * @param cause
+         *      Pointer to the exception that caused this one to be
+         *      thrown, the object is cloned caller retains ownership.
+         */
+        CertificateException(const std::exception* cause);
 
         /**
          * Constructor - Initializes the file name and line number where
@@ -73,18 +93,7 @@ namespace cert{
          * @param ...
          *      list of primitives that are formatted into the message
          */
-        CertificateException( const char* file,
-                               const int lineNumber,
-                               const char* msg, ...) throw()
-        : Exception()
-        {
-            va_list vargs;
-            va_start(vargs, msg);
-            buildMessage(msg, vargs);
-
-            // Set the first mark for this exception.
-            setMark(file, lineNumber);
-        }
+        CertificateException(const char* file, const int lineNumber, const char* msg, ...);
 
         /**
          * Clones this exception.  This is useful for cases where you need
@@ -93,13 +102,13 @@ namespace cert{
          *
          * @return A deep copy of this exception.
          */
-        virtual CertificateException* clone() const{
+        virtual CertificateException* clone() const {
             return new CertificateException(*this);
         }
 
-        virtual ~CertificateException() throw() {}
+        virtual ~CertificateException() throw();
 
-   };
+    };
 
 }}}
 

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/cert/CertificateExpiredException.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/cert/CertificateExpiredException.cpp?rev=1457307&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/cert/CertificateExpiredException.cpp (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/cert/CertificateExpiredException.cpp Sat Mar 16 21:14:01 2013
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "CertificateExpiredException.h"
+
+using namespace decaf;
+using namespace decaf::security;
+using namespace decaf::security::cert;
+
+////////////////////////////////////////////////////////////////////////////////
+CertificateExpiredException::CertificateExpiredException() : CertificateException() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+CertificateExpiredException::CertificateExpiredException(const Exception& ex) : CertificateException() {
+    *(Exception*) this = ex;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+CertificateExpiredException::CertificateExpiredException(const CertificateExpiredException& ex) : CertificateException() {
+    *(Exception*) this = ex;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+CertificateExpiredException::CertificateExpiredException(const char* file, const int lineNumber, const std::exception* cause, const char* msg, ...) : CertificateException(cause) {
+
+    va_list vargs;
+    va_start(vargs, msg);
+    buildMessage(msg, vargs);
+
+    // Set the first mark for this exception.
+    setMark(file, lineNumber);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+CertificateExpiredException::CertificateExpiredException(const std::exception* cause) : CertificateException(cause) {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+CertificateExpiredException::CertificateExpiredException(const char* file, const int lineNumber, const char* msg, ...) : CertificateException() {
+
+    va_list vargs;
+    va_start(vargs, msg);
+    buildMessage(msg, vargs);
+
+    // Set the first mark for this exception.
+    setMark(file, lineNumber);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+CertificateExpiredException::~CertificateExpiredException() throw () {
+}

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/cert/CertificateExpiredException.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/cert/CertificateExpiredException.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/cert/CertificateExpiredException.h?rev=1457307&r1=1457306&r2=1457307&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/cert/CertificateExpiredException.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/cert/CertificateExpiredException.h Sat Mar 16 21:14:01 2013
@@ -21,45 +21,64 @@
 #include <decaf/util/Config.h>
 #include <decaf/security/cert/CertificateException.h>
 
-namespace decaf{
-namespace security{
-namespace cert{
+namespace decaf {
+namespace security {
+namespace cert {
 
     /*
      * Certificate Expired Exception. This is thrown whenever the current Date
      * or the specified Date is after the notAfter date/time specified in the
      * validity period of the certificate.
      */
-    class DECAF_API CertificateExpiredException : public CertificateException
-    {
+    class DECAF_API CertificateExpiredException : public CertificateException {
     public:
 
         /**
          * Default Constructor
          */
-        CertificateExpiredException() throw() {};
+        CertificateExpiredException();
 
         /**
          * Conversion Constructor from some other Exception
          * @param ex
          *      An exception that should become this type of Exception
          */
-        CertificateExpiredException(const Exception& ex) throw()
-        : Exception()
-        {
-            *(Exception*)this = ex;
-        }
+        CertificateExpiredException(const Exception& ex);
 
         /**
          * Copy Constructor
+         *
          * @param ex
          *      An exception that should become this type of Exception
          */
-        CertificateExpiredException(const CertificateExpiredException& ex) throw()
-        : Exception()
-        {
-            *(Exception*)this = ex;
-        }
+        CertificateExpiredException(const CertificateExpiredException& ex);
+
+        /**
+         * Constructor - Initializes the file name and line number where
+         * this message occurred.  Sets the message to report, using an
+         * optional list of arguments to parse into the message.
+         *
+         * @param file
+         *      The file name where exception occurs
+         * @param lineNumber
+         *      The line number where the exception occurred.
+         * @param cause
+         *      The exception that was the cause for this one to be thrown.
+         * @param msg
+         *      The message to report
+         * @param ...
+         *      list of primitives that are formatted into the message
+         */
+        CertificateExpiredException(const char* file, const int lineNumber, const std::exception* cause, const char* msg, ...);
+
+        /**
+         * Constructor
+         *
+         * @param cause
+         *      Pointer to the exception that caused this one to be
+         *      thrown, the object is cloned caller retains ownership.
+         */
+        CertificateExpiredException(const std::exception* cause);
 
         /**
          * Constructor - Initializes the file name and line number where
@@ -75,18 +94,7 @@ namespace cert{
          * @param ...
          *      list of primitives that are formatted into the message
          */
-        CertificateExpiredException( const char* file,
-                               const int lineNumber,
-                               const char* msg, ...) throw()
-        : Exception()
-        {
-            va_list vargs;
-            va_start(vargs, msg);
-            buildMessage(msg, vargs);
-
-            // Set the first mark for this exception.
-            setMark(file, lineNumber);
-        }
+        CertificateExpiredException(const char* file, const int lineNumber, const char* msg, ...);
 
         /**
          * Clones this exception.  This is useful for cases where you need
@@ -95,13 +103,13 @@ namespace cert{
          *
          * @return A deep copy of this exception.
          */
-        virtual CertificateExpiredException* clone() const{
+        virtual CertificateExpiredException* clone() const {
             return new CertificateExpiredException(*this);
         }
 
-        virtual ~CertificateExpiredException() throw() {}
+        virtual ~CertificateExpiredException() throw();
 
-   };
+    };
 
 }}}
 

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/cert/CertificateNotYetValidException.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/cert/CertificateNotYetValidException.cpp?rev=1457307&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/cert/CertificateNotYetValidException.cpp (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/cert/CertificateNotYetValidException.cpp Sat Mar 16 21:14:01 2013
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "CertificateNotYetValidException.h"
+
+using namespace decaf;
+using namespace decaf::security;
+using namespace decaf::security::cert;
+
+////////////////////////////////////////////////////////////////////////////////
+CertificateNotYetValidException::CertificateNotYetValidException() : CertificateException() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+CertificateNotYetValidException::CertificateNotYetValidException(const Exception& ex) : CertificateException() {
+    *(Exception*) this = ex;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+CertificateNotYetValidException::CertificateNotYetValidException(const CertificateNotYetValidException& ex) : CertificateException() {
+    *(Exception*) this = ex;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+CertificateNotYetValidException::CertificateNotYetValidException(const char* file, const int lineNumber, const std::exception* cause, const char* msg, ...) : CertificateException(cause) {
+
+    va_list vargs;
+    va_start(vargs, msg);
+    buildMessage(msg, vargs);
+
+    // Set the first mark for this exception.
+    setMark(file, lineNumber);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+CertificateNotYetValidException::CertificateNotYetValidException(const std::exception* cause) : CertificateException(cause) {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+CertificateNotYetValidException::CertificateNotYetValidException(const char* file, const int lineNumber, const char* msg, ...) : CertificateException() {
+
+    va_list vargs;
+    va_start(vargs, msg);
+    buildMessage(msg, vargs);
+
+    // Set the first mark for this exception.
+    setMark(file, lineNumber);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+CertificateNotYetValidException::~CertificateNotYetValidException() throw () {
+}

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/cert/CertificateNotYetValidException.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/cert/CertificateNotYetValidException.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/cert/CertificateNotYetValidException.h?rev=1457307&r1=1457306&r2=1457307&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/cert/CertificateNotYetValidException.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/cert/CertificateNotYetValidException.h Sat Mar 16 21:14:01 2013
@@ -21,45 +21,65 @@
 #include <decaf/util/Config.h>
 #include <decaf/security/cert/CertificateException.h>
 
-namespace decaf{
-namespace security{
-namespace cert{
+namespace decaf {
+namespace security {
+namespace cert {
 
     /*
      * Certificate is not yet valid exception. This is thrown whenever the
      * current Date or the specified Date  is before the notBefore
      * date/time in the Certificate validity period.
      */
-    class DECAF_API CertificateNotYetValidException : public CertificateException
-    {
+    class DECAF_API CertificateNotYetValidException : public CertificateException {
     public:
 
         /**
          * Default Constructor
          */
-        CertificateNotYetValidException() throw() {};
+        CertificateNotYetValidException();
 
         /**
          * Conversion Constructor from some other Exception
+         *
          * @param ex
          *      An exception that should become this type of Exception
          */
-        CertificateNotYetValidException(const Exception& ex) throw()
-        : Exception()
-        {
-            *(Exception*)this = ex;
-        }
+        CertificateNotYetValidException(const Exception& ex);
 
         /**
          * Copy Constructor
+         *
          * @param ex
          *      An exception that should become this type of Exception
          */
-        CertificateNotYetValidException(const CertificateNotYetValidException& ex) throw()
-        : Exception()
-        {
-            *(Exception*)this = ex;
-        }
+        CertificateNotYetValidException(const CertificateNotYetValidException& ex);
+
+        /**
+         * Constructor - Initializes the file name and line number where
+         * this message occurred.  Sets the message to report, using an
+         * optional list of arguments to parse into the message.
+         *
+         * @param file
+         *      The file name where exception occurs
+         * @param lineNumber
+         *      The line number where the exception occurred.
+         * @param cause
+         *      The exception that was the cause for this one to be thrown.
+         * @param msg
+         *      The message to report
+         * @param ...
+         *      list of primitives that are formatted into the message
+         */
+        CertificateNotYetValidException(const char* file, const int lineNumber, const std::exception* cause, const char* msg, ...);
+
+        /**
+         * Constructor
+         *
+         * @param cause
+         *      Pointer to the exception that caused this one to be
+         *      thrown, the object is cloned caller retains ownership.
+         */
+        CertificateNotYetValidException(const std::exception* cause);
 
         /**
          * Constructor - Initializes the file name and line number where
@@ -75,18 +95,7 @@ namespace cert{
          * @param ...
          *      list of primitives that are formatted into the message
          */
-        CertificateNotYetValidException( const char* file,
-                               const int lineNumber,
-                               const char* msg, ...) throw()
-        : Exception()
-        {
-            va_list vargs;
-            va_start(vargs, msg);
-            buildMessage(msg, vargs);
-
-            // Set the first mark for this exception.
-            setMark(file, lineNumber);
-        }
+        CertificateNotYetValidException(const char* file, const int lineNumber, const char* msg, ...);
 
         /**
          * Clones this exception.  This is useful for cases where you need
@@ -95,13 +104,13 @@ namespace cert{
          *
          * @return A deep copy of this exception.
          */
-        virtual CertificateNotYetValidException* clone() const{
+        virtual CertificateNotYetValidException* clone() const {
             return new CertificateNotYetValidException(*this);
         }
 
-        virtual ~CertificateNotYetValidException() throw() {}
+        virtual ~CertificateNotYetValidException() throw();
 
-   };
+    };
 
 }}}
 

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/cert/CertificateParsingException.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/cert/CertificateParsingException.cpp?rev=1457307&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/cert/CertificateParsingException.cpp (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/cert/CertificateParsingException.cpp Sat Mar 16 21:14:01 2013
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "CertificateParsingException.h"
+
+using namespace decaf;
+using namespace decaf::security;
+using namespace decaf::security::cert;
+
+////////////////////////////////////////////////////////////////////////////////
+CertificateParsingException::CertificateParsingException() : CertificateException() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+CertificateParsingException::CertificateParsingException(const Exception& ex) : CertificateException() {
+    *(Exception*) this = ex;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+CertificateParsingException::CertificateParsingException(const CertificateParsingException& ex) : CertificateException() {
+    *(Exception*) this = ex;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+CertificateParsingException::CertificateParsingException(const char* file, const int lineNumber, const std::exception* cause, const char* msg, ...) : CertificateException(cause) {
+
+    va_list vargs;
+    va_start(vargs, msg);
+    buildMessage(msg, vargs);
+
+    // Set the first mark for this exception.
+    setMark(file, lineNumber);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+CertificateParsingException::CertificateParsingException(const std::exception* cause) : CertificateException(cause) {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+CertificateParsingException::CertificateParsingException(const char* file, const int lineNumber, const char* msg, ...) : CertificateException() {
+
+    va_list vargs;
+    va_start(vargs, msg);
+    buildMessage(msg, vargs);
+
+    // Set the first mark for this exception.
+    setMark(file, lineNumber);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+CertificateParsingException::~CertificateParsingException() throw () {
+}

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/cert/CertificateParsingException.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/cert/CertificateParsingException.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/cert/CertificateParsingException.h?rev=1457307&r1=1457306&r2=1457307&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/cert/CertificateParsingException.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/cert/CertificateParsingException.h Sat Mar 16 21:14:01 2013
@@ -21,45 +21,65 @@
 #include <decaf/util/Config.h>
 #include <decaf/security/cert/CertificateException.h>
 
-namespace decaf{
-namespace security{
-namespace cert{
+namespace decaf {
+namespace security {
+namespace cert {
 
     /*
      * Certificate Parsing Exception. This is thrown whenever an invalid
      * DER-encoded certificate is parsed or unsupported DER features are found
      * in the Certificate.
      */
-    class DECAF_API CertificateParsingException : public CertificateException
-    {
+    class DECAF_API CertificateParsingException : public CertificateException {
     public:
 
         /**
          * Default Constructor
          */
-        CertificateParsingException() throw() {};
+        CertificateParsingException();
 
         /**
          * Conversion Constructor from some other Exception
+         *
          * @param ex
          *      An exception that should become this type of Exception
          */
-        CertificateParsingException(const Exception& ex) throw()
-        : Exception()
-        {
-            *(Exception*)this = ex;
-        }
+        CertificateParsingException(const Exception& ex);
 
         /**
          * Copy Constructor
+         *
          * @param ex
          *      An exception that should become this type of Exception
          */
-        CertificateParsingException(const CertificateParsingException& ex) throw()
-        : Exception()
-        {
-            *(Exception*)this = ex;
-        }
+        CertificateParsingException(const CertificateParsingException& ex);
+
+        /**
+         * Constructor - Initializes the file name and line number where
+         * this message occurred.  Sets the message to report, using an
+         * optional list of arguments to parse into the message.
+         *
+         * @param file
+         *      The file name where exception occurs
+         * @param lineNumber
+         *      The line number where the exception occurred.
+         * @param cause
+         *      The exception that was the cause for this one to be thrown.
+         * @param msg
+         *      The message to report
+         * @param ...
+         *      list of primitives that are formatted into the message
+         */
+        CertificateParsingException(const char* file, const int lineNumber, const std::exception* cause, const char* msg, ...);
+
+        /**
+         * Constructor
+         *
+         * @param cause
+         *      Pointer to the exception that caused this one to be
+         *      thrown, the object is cloned caller retains ownership.
+         */
+        CertificateParsingException(const std::exception* cause);
 
         /**
          * Constructor - Initializes the file name and line number where
@@ -75,18 +95,7 @@ namespace cert{
          * @param ...
          *      list of primitives that are formatted into the message
          */
-        CertificateParsingException( const char* file,
-                               const int lineNumber,
-                               const char* msg, ...) throw()
-        : Exception()
-        {
-            va_list vargs;
-            va_start(vargs, msg);
-            buildMessage(msg, vargs);
-
-            // Set the first mark for this exception.
-            setMark(file, lineNumber);
-        }
+        CertificateParsingException(const char* file, const int lineNumber, const char* msg, ...);
 
         /**
          * Clones this exception.  This is useful for cases where you need
@@ -95,13 +104,13 @@ namespace cert{
          *
          * @return A deep copy of this exception.
          */
-        virtual CertificateParsingException* clone() const{
+        virtual CertificateParsingException* clone() const {
             return new CertificateParsingException(*this);
         }
 
-        virtual ~CertificateParsingException() throw() {}
+        virtual ~CertificateParsingException() throw();
 
-   };
+    };
 
 }}}
 

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/cert/X509Certificate.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/cert/X509Certificate.cpp?rev=1457307&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/cert/X509Certificate.cpp (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/cert/X509Certificate.cpp Sat Mar 16 21:14:01 2013
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "X509Certificate.h"
+
+using namespace decaf;
+using namespace decaf::security;
+using namespace decaf::security::cert;
+
+////////////////////////////////////////////////////////////////////////////////

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/cert/X509Certificate.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/cert/X509Certificate.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/cert/X509Certificate.h?rev=1457307&r1=1457306&r2=1457307&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/cert/X509Certificate.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/cert/X509Certificate.h Sat Mar 16 21:14:01 2013
@@ -25,16 +25,19 @@
 
 namespace decaf {
 namespace security {
+namespace auth {
+    class X500Principal;
+}
 namespace cert {
 
     /**
      * Base interface for all identity certificates.
      */
     class DECAF_API X509Certificate : public Certificate {
-
     public:
 
-        virtual ~X509Certificate() {}
+        virtual ~X509Certificate() {
+        }
 
         virtual void checkValidity() const = 0;
 
@@ -42,15 +45,15 @@ namespace cert {
 
         virtual int getBasicConstraints() const = 0;
 
-        virtual void getIssuerUniqueID( std::vector<bool>& output ) const = 0;
+        virtual void getIssuerUniqueID(std::vector<bool>& output) const = 0;
 
-        virtual const X500Principal* getIssuerX500Principal() const = 0;
+        virtual const auth::X500Principal* getIssuerX500Principal() const = 0;
 
-        virtual void getKeyUsage( std::vector<unsigned char>& output ) const = 0;
+        virtual void getKeyUsage(std::vector<unsigned char>& output) const = 0;
 
-        virtual Date getNotAfter() const = 0;
+        virtual decaf::util::Date getNotAfter() const = 0;
 
-        virtual Date getNotBefore() const = 0;
+        virtual decaf::util::Date getNotBefore() const = 0;
 
         //virtual BigInteger getSerialNumber() const = 0;
 
@@ -58,17 +61,18 @@ namespace cert {
 
         virtual std::string getSigAlgOID() const = 0;
 
-        virtual void getSigAlgParams( std::vector<unsigned char>& output ) const = 0;
+        virtual void getSigAlgParams(std::vector<unsigned char>& output) const = 0;
 
-        virtual void getSignature( std::vector<unsigned char>& output ) const = 0;
+        virtual void getSignature(std::vector<unsigned char>& output) const = 0;
 
-        virtual void getSubjectUniqueID( std::vector<bool>& output ) const = 0;
+        virtual void getSubjectUniqueID(std::vector<bool>& output) const = 0;
 
-        virtual const X500Principal* getSubjectX500Principal() const = 0;
+        virtual const auth::X500Principal* getSubjectX500Principal() const = 0;
 
-        virtual void getTBSCertificate( std::vector<unsigned char>& output ) const = 0;
+        virtual void getTBSCertificate(std::vector<unsigned char>& output) const = 0;
 
         virtual int getVersion() const = 0;
+
     };
 
 }}}

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/HashMap.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/HashMap.h?rev=1457307&r1=1457306&r2=1457307&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/HashMap.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/HashMap.h Sat Mar 16 21:14:01 2013
@@ -534,7 +534,7 @@ namespace util {
                         __FILE__, __LINE__, "Can't clear a const collection");
             }
 
-            virtual bool remove(const MapEntry<K,V>& entry) {
+            virtual bool remove(const MapEntry<K,V>& entry DECAF_UNUSED) {
                 throw decaf::lang::exceptions::UnsupportedOperationException(
                         __FILE__, __LINE__, "Can't remove from const collection");
             }
@@ -636,7 +636,7 @@ namespace util {
                         __FILE__, __LINE__, "Can't modify a const collection");
             }
 
-            virtual bool remove(const K& key) {
+            virtual bool remove(const K& key DECAF_UNUSED) {
                 throw decaf::lang::exceptions::UnsupportedOperationException(
                         __FILE__, __LINE__, "Can't modify a const collection");
             }
@@ -1041,7 +1041,36 @@ namespace util {
         }
 
         virtual bool equals(const Map<K, V>& source) const {
-            return false;
+
+            if (this == &source) {
+                return true;
+            }
+
+            if (size() != source.size()) {
+                return false;
+            }
+
+            try {
+                decaf::lang::Pointer<Iterator<MapEntry<K, V> > > iter(entrySet().iterator());
+                while (iter->hasNext() ) {
+                    MapEntry<K, V> entry = iter->next();
+                    K key = entry.getKey();
+                    V mine = entry.getValue();
+
+                    if (!source.containsKey(key)) {
+                        return false;
+                    }
+
+                    if (source.get(key) != mine) {
+                        return false;
+                    }
+                }
+            } catch (decaf::lang::exceptions::NullPointerException& ignored) {
+                return false;
+            } catch (decaf::lang::exceptions::ClassCastException& ignored) {
+                return false;
+            }
+            return true;
         }
 
         virtual void copy(const Map<K, V>& source) {

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/UUID.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/UUID.cpp?rev=1457307&r1=1457306&r2=1457307&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/UUID.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/UUID.cpp Sat Mar 16 21:14:01 2013
@@ -17,18 +17,26 @@
 
 #include "UUID.h"
 #include <stdio.h>
-#include <apr_md5.h>
-#include <apr_uuid.h>
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+#include <decaf/lang/Pointer.h>
+#include <decaf/lang/Long.h>
 #include <decaf/internal/util/StringUtils.h>
 #include <decaf/lang/exceptions/RuntimeException.h>
 #include <decaf/lang/exceptions/UnsupportedOperationException.h>
 #include <decaf/lang/exceptions/IllegalArgumentException.h>
+#include <decaf/security/SecureRandom.h>
+#include <decaf/security/MessageDigest.h>
+#include <decaf/security/NoSuchAlgorithmException.h>
 
 using namespace std;
 using namespace decaf;
 using namespace decaf::util;
 using namespace decaf::internal::util;
 using namespace decaf::lang;
+using namespace decaf::lang::exceptions;
+using namespace decaf::security;
 
 ////////////////////////////////////////////////////////////////////////////////
 namespace decaf {
@@ -42,122 +50,93 @@ namespace util {
 
     public:
 
-        unsigned char data[16];
         unsigned long long mostSigBits;
         unsigned long long leastSigBits;
-        int uuidVersion;
 
-        UUIDImpl() : mostSigBits(0), leastSigBits(0), uuidVersion(0) {
+        int variant;
+        int version;
+        long long timestamp;
+        int clockSequence;
+        long long node;
+        int hash;
+
+        UUIDImpl() : mostSigBits(0), leastSigBits(0), variant(0),
+                     version(0), timestamp(0), clockSequence(0), node(0), hash(0) {
         }
 
         UUIDImpl(long long mostSigBits, long long leastSigBits) :
-            mostSigBits(mostSigBits), leastSigBits(leastSigBits), uuidVersion(0) {
-
-            memcpy(&data[0], &mostSigBits, sizeof(long long));
-            memcpy(&data[sizeof(long long)], &leastSigBits, sizeof(long long));
-
-            // Version indicator, set when a UUID is generated
-            this->uuidVersion = (int) (mostSigBits & 0x000000000000F000LL) >> 12;
-        }
+            mostSigBits(mostSigBits), leastSigBits(leastSigBits), variant(0),
+            version(0), timestamp(0), clockSequence(0), node(0), hash(0) {
 
-        void format(char *buffer) {
-            sprintf(buffer,
-                    "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
-                    data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7],
-                    data[8], data[9], data[10], data[11], data[12], data[13], data[14], data[15]);
+            init();
         }
 
     private:
 
-        /* convert a pair of hex digits to an integer value [0,255] */
-        #if 'A' == 65
-        static unsigned char parseHexpair(const char* s) {
-            int result;
-            int temp;
-
-            result = s[0] - '0';
-            if (result > 48) {
-                result = (result - 39) << 4;
-            } else if (result > 16) {
-                result = (result - 7) << 4;
-            } else {
-                result = result << 4;
-            }
+        void init() {
 
-            temp = s[1] - '0';
-            if (temp > 48) {
-                result |= temp - 39;
-            } else if (temp > 16) {
-                result |= temp - 7;
+            // setup hash field
+            int msbHash = (int) (mostSigBits ^ (mostSigBits >> 32));
+            int lsbHash = (int) (leastSigBits ^ (leastSigBits >> 32));
+            hash = msbHash ^ lsbHash;
+
+            // setup variant field
+            if ((leastSigBits & 0x8000000000000000ULL) == 0) {
+                // MSB0 not set, NCS backwards compatibility variant
+                variant = 0;
+            } else if ((leastSigBits & 0x4000000000000000ULL) != 0) {
+                // MSB1 set, either MS reserved or future reserved
+                variant = (int) ((leastSigBits & 0xE000000000000000ULL) >> 61);
             } else {
-                result |= temp;
+                // MSB1 not set, RFC 4122 variant
+                variant = 2;
             }
 
-            return (unsigned char)result;
-        }
-        #else
-        static unsigned char parseHexpair(const char* s) {
-            int result;
+            // setup version field
+            version = (int) ((mostSigBits & 0x000000000000F000ULL) >> 12);
 
-            if (isdigit(*s)) {
-                result = (*s - '0') << 4;
-            } else {
-                if (isupper(*s)) {
-                    result = (*s - 'A' + 10) << 4;
-                } else {
-                    result = (*s - 'a' + 10) << 4;
-                }
+            if (variant != 2 && version != 1) {
+                return;
             }
 
-            ++s;
-            if (isdigit(*s)) {
-                result |= (*s - '0');
-            } else {
-                if (isupper(*s)) {
-                    result |= (*s - 'A' + 10);
-                } else {
-                    result |= (*s - 'a' + 10);
-                }
-            }
+            // setup timestamp field
+            long long timeLow = (mostSigBits & 0xFFFFFFFF00000000ULL) >> 32;
+            long long timeMid = (mostSigBits & 0x00000000FFFF0000ULL) << 16;
+            long long timeHigh = (mostSigBits & 0x0000000000000FFFULL) << 48;
+            timestamp = timeLow | timeMid | timeHigh;
+
+            // setup clock sequence field
+            clockSequence = (int) ((leastSigBits & 0x3FFF000000000000ULL) >> 48);
 
-            return (unsigned char)result;
+            // setup node field
+            node = (leastSigBits & 0x0000FFFFFFFFFFFFL);
         }
-        #endif
 
     public:
 
-        void parse(const char* uuidString) {
-            int i;
-
-            for (i = 0; i < 36; ++i) {
-                char c = uuidString[i];
-                if (!isxdigit(c) && !(c == '-' && (i == 8 || i == 13 || i == 18 || i == 23)))
-                    throw lang::exceptions::IllegalArgumentException(
-                        __FILE__, __LINE__, "Invalid UUID String: ", uuidString);
-            }
-
-            if (uuidString[36] != '\0') {
-                throw lang::exceptions::IllegalArgumentException(
-                    __FILE__, __LINE__, "Invalid UUID String: ", uuidString);
+        std::string toString() const {
+            std::string builder;
+            std::string msbStr = Long::toHexString(mostSigBits);
+            if (msbStr.length() < 16) {
+                int diff = 16 - (int)msbStr.length();
+                for (int i = 0; i < diff; i++) {
+                    builder.append("0");
+                }
             }
-
-            data[0] = parseHexpair(&uuidString[0]);
-            data[1] = parseHexpair(&uuidString[2]);
-            data[2] = parseHexpair(&uuidString[4]);
-            data[3] = parseHexpair(&uuidString[6]);
-
-            data[4] = parseHexpair(&uuidString[9]);
-            data[5] = parseHexpair(&uuidString[11]);
-
-            data[6] = parseHexpair(&uuidString[14]);
-            data[7] = parseHexpair(&uuidString[16]);
-
-            data[8] = parseHexpair(&uuidString[19]);
-            data[9] = parseHexpair(&uuidString[21]);
-
-            for (i = 6; i--;) {
-                data[10 + i] = parseHexpair(&uuidString[i*2+24]);
+            builder.append(msbStr);
+            builder.insert(8, "-");
+            builder.insert(13, "-");
+            builder.append("-");
+            std::string lsbStr = Long::toHexString(leastSigBits);
+            if (lsbStr.length() < 16) {
+                int diff = 16 - (int)lsbStr.length();
+                for (int i = 0; i < diff; i++) {
+                    builder.append("0");
+                }
             }
+            builder.append(lsbStr);
+            builder.insert(23, "-");
+            return builder;
         }
     };
 
@@ -169,6 +148,18 @@ UUID::UUID(long long mostSigBits, long l
 }
 
 ////////////////////////////////////////////////////////////////////////////////
+UUID::UUID(const UUID& source) :
+    uuid(new UUIDImpl(source.getMostSignificantBits(), source.getLeastSignificantBits())) {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+UUID& UUID::operator= (const UUID& source) {
+    delete this->uuid;
+    this->uuid = new UUIDImpl(source.getMostSignificantBits(), source.getLeastSignificantBits());
+    return *this;
+}
+
+////////////////////////////////////////////////////////////////////////////////
 UUID::~UUID() {
     delete this->uuid;
 }
@@ -185,6 +176,11 @@ bool UUID::equals(const UUID& value) con
 }
 
 ////////////////////////////////////////////////////////////////////////////////
+int UUID::hashCode() const {
+    return this->uuid->hash;
+}
+
+////////////////////////////////////////////////////////////////////////////////
 bool UUID::operator==(const UUID& value) const {
     return this->equals(value);
 }
@@ -196,9 +192,7 @@ bool UUID::operator<(const UUID& value) 
 
 ////////////////////////////////////////////////////////////////////////////////
 std::string UUID::toString() const {
-    char buffer[37] = { 0 };
-    this->uuid->format(&buffer[0]);
-    return &buffer[0];
+    return this->uuid->toString();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -208,8 +202,6 @@ long long UUID::getLeastSignificantBits(
 
 ////////////////////////////////////////////////////////////////////////////////
 long long UUID::getMostSignificantBits() const {
-    long long result = 0;
-    memcpy(&result, &this->uuid->data[sizeof(long long)], sizeof(long long));
     return this->uuid->mostSigBits;
 }
 
@@ -269,53 +261,60 @@ int UUID::variant() {
 
 ////////////////////////////////////////////////////////////////////////////////
 int UUID::version() {
-    return this->uuid->uuidVersion;
+    return this->uuid->version;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 UUID UUID::randomUUID() {
 
-    apr_uuid_t temp;
-    // Generate some random bytes.
-    apr_uuid_get(&temp);
+    unsigned char data[16];
+    SecureRandom secRand;
+    secRand.nextBytes(data, 16);
 
     long long msb = 0;
     long long lsb = 0;
 
-    msb = (temp.data[0] & 0xFFLL) << 56;
-    msb |= (temp.data[1] & 0xFFLL) << 48;
-    msb |= (temp.data[2] & 0xFFLL) << 40;
-    msb |= (temp.data[3] & 0xFFLL) << 32;
-    msb |= (temp.data[4] & 0xFFLL) << 24;
-    msb |= (temp.data[5] & 0xFFLL) << 16;
-    msb |= (temp.data[6] & 0x0FLL) << 8;
+    msb = (data[0] & 0xFFLL) << 56;
+    msb |= (data[1] & 0xFFLL) << 48;
+    msb |= (data[2] & 0xFFLL) << 40;
+    msb |= (data[3] & 0xFFLL) << 32;
+    msb |= (data[4] & 0xFFLL) << 24;
+    msb |= (data[5] & 0xFFLL) << 16;
+    msb |= (data[6] & 0x0FLL) << 8;
     msb |= (0x4LL << 12); // set the version to 4
-    msb |= (temp.data[7] & 0xFFLL);
+    msb |= (data[7] & 0xFFLL);
 
-    lsb = (temp.data[8] & 0x3FLL) << 56;
+    lsb = (data[8] & 0x3FLL) << 56;
     lsb |= (0x2LL << 62); // set the variant to bits 01
-    lsb |= (temp.data[9] & 0xFFLL) << 48;
-    lsb |= (temp.data[10] & 0xFFLL) << 40;
-    lsb |= (temp.data[11] & 0xFFLL) << 32;
-    lsb |= (temp.data[12] & 0xFFLL) << 24;
-    lsb |= (temp.data[13] & 0xFFLL) << 16;
-    lsb |= (temp.data[14] & 0xFFLL) << 8;
-    lsb |= (temp.data[15] & 0xFFLL);
+    lsb |= (data[9] & 0xFFLL) << 48;
+    lsb |= (data[10] & 0xFFLL) << 40;
+    lsb |= (data[11] & 0xFFLL) << 32;
+    lsb |= (data[12] & 0xFFLL) << 24;
+    lsb |= (data[13] & 0xFFLL) << 16;
+    lsb |= (data[14] & 0xFFLL) << 8;
+    lsb |= (data[15] & 0xFFLL);
 
     return UUID(msb, lsb);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 UUID UUID::nameUUIDFromBytes(const std::vector<char>& name) {
-    return UUID::nameUUIDFromBytes(&name[0], name.size());
+    return UUID::nameUUIDFromBytes(&name[0], (int)name.size());
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-UUID UUID::nameUUIDFromBytes(const char* name, std::size_t size) {
+UUID UUID::nameUUIDFromBytes(const char* name, int size) {
+
+    if (name == NULL && size > 0) {
+        throw NullPointerException(__FILE__, __LINE__, "UUID name buffer was NULL");
+    }
 
-    apr_uuid_t temp;
+    std::vector<unsigned char> hash;
 
-    if (apr_md5(&temp.data[0], name, size) != APR_SUCCESS) {
+    try {
+        Pointer<MessageDigest> digest(MessageDigest::getInstance("MD5"));
+        hash = digest->digest((unsigned char*)name, size);
+    } catch (NoSuchAlgorithmException& ex) {
         throw exceptions::RuntimeException(
             __FILE__, __LINE__, "UUID::nameUUIDFromBytes - Failed to run MD5 encoder.");
     }
@@ -323,42 +322,74 @@ UUID UUID::nameUUIDFromBytes(const char*
     long long msb = 0;
     long long lsb = 0;
 
-    msb = (temp.data[0] & 0xFFLL) << 56;
-    msb |= (temp.data[1] & 0xFFLL) << 48;
-    msb |= (temp.data[2] & 0xFFLL) << 40;
-    msb |= (temp.data[3] & 0xFFLL) << 32;
-    msb |= (temp.data[4] & 0xFFLL) << 24;
-    msb |= (temp.data[5] & 0xFFLL) << 16;
-    msb |= (temp.data[6] & 0x0FLL) << 8;
+    msb = (hash[0] & 0xFFLL) << 56;
+    msb |= (hash[1] & 0xFFLL) << 48;
+    msb |= (hash[2] & 0xFFLL) << 40;
+    msb |= (hash[3] & 0xFFLL) << 32;
+    msb |= (hash[4] & 0xFFLL) << 24;
+    msb |= (hash[5] & 0xFFLL) << 16;
+    msb |= (hash[6] & 0x0FLL) << 8;
     msb |= (0x3LL << 12); // set the version to 3
-    msb |= (temp.data[7] & 0xFFLL);
+    msb |= (hash[7] & 0xFFLL);
 
-    lsb = (temp.data[8] & 0x3FLL) << 56;
+    lsb = (hash[8] & 0x3FLL) << 56;
     lsb |= (0x2LL << 62); // set the variant to bits 01
-    lsb |= (temp.data[9] & 0xFFLL) << 48;
-    lsb |= (temp.data[10] & 0xFFLL) << 40;
-    lsb |= (temp.data[11] & 0xFFLL) << 32;
-    lsb |= (temp.data[12] & 0xFFLL) << 24;
-    lsb |= (temp.data[13] & 0xFFLL) << 16;
-    lsb |= (temp.data[14] & 0xFFLL) << 8;
-    lsb |= (temp.data[15] & 0xFFLL);
+    lsb |= (hash[9] & 0xFFLL) << 48;
+    lsb |= (hash[10] & 0xFFLL) << 40;
+    lsb |= (hash[11] & 0xFFLL) << 32;
+    lsb |= (hash[12] & 0xFFLL) << 24;
+    lsb |= (hash[13] & 0xFFLL) << 16;
+    lsb |= (hash[14] & 0xFFLL) << 8;
+    lsb |= (hash[15] & 0xFFLL);
 
     return UUID(msb, lsb);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-UUID UUID::fromString(const std::string& name) {
+UUID UUID::fromString(const std::string& uuid) {
+
+    static const int POS_SIZE = 5;
+
+    int position[5];
+    int lastPosition = 1;
+    int startPosition = 0;
+
+    int i = 0;
+    for (; i < POS_SIZE && lastPosition > 0; i++) {
+        position[i] = (int)uuid.find("-", startPosition);
+        lastPosition = position[i];
+        startPosition = position[i] + 1;
+    }
 
-    UUIDImpl temp;
+    // should have and only can have four "-" in UUID
+    if (i != POS_SIZE || lastPosition != -1) {
+        throw IllegalArgumentException(__FILE__, __LINE__,
+            "Invalid UUID string %s", uuid.c_str());
+    }
 
-    temp.parse(name.c_str());
+    if (position[0] == 0) {
+        throw IllegalArgumentException(__FILE__, __LINE__,
+            "Invalid UUID string %s", uuid.c_str());
+    } else if (((position[1] - position[0]) - 1) <= 0) {
+        throw IllegalArgumentException(__FILE__, __LINE__,
+            "Invalid UUID string %s", uuid.c_str());
+    } else if (((position[2] - position[1]) - 1) <= 0) {
+        throw IllegalArgumentException(__FILE__, __LINE__,
+            "Invalid UUID string %s", uuid.c_str());
+    } else if ((position[3] + 1) >= (int)uuid.length()) {
+        throw IllegalArgumentException(__FILE__, __LINE__,
+            "Invalid UUID string %s", uuid.c_str());
+    }
 
-    long long mostSigBits = 0;
-    long long leastSigBits = 0;
+    long long m1 = Long::parseLong(uuid.substr(0, position[0]), 16);
+    long long m2 = Long::parseLong(uuid.substr(position[0] + 1, (position[1] - position[0]) - 1), 16);
+    long long m3 = Long::parseLong(uuid.substr(position[1] + 1, (position[2] - position[1]) - 1), 16);
 
-    // Extract to data from the uuid data
-    memcpy(&mostSigBits, &temp.data[0], sizeof(long long));
-    memcpy(&leastSigBits, &temp.data[sizeof(long long)], sizeof(long long));
+    long long lsb1 = Long::parseLong(uuid.substr(position[2] + 1, (position[3] - position[2]) - 1), 16);
+    long long lsb2 = Long::parseLong(uuid.substr(position[3] + 1), 16);
 
-    return UUID(mostSigBits, leastSigBits);
+    long long msb = (m1 << 32) | (m2 << 16) | m3;
+    long long lsb = (lsb1 << 48) | lsb2;
+
+    return UUID(msb, lsb);
 }

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/UUID.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/UUID.h?rev=1457307&r1=1457306&r2=1457307&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/UUID.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/UUID.h Sat Mar 16 21:14:01 2013
@@ -101,7 +101,7 @@ namespace util {
          *
          * @return type 3 UUID
          */
-        static UUID nameUUIDFromBytes(const char* name, std::size_t size);
+        static UUID nameUUIDFromBytes(const char* name, int size);
 
         /**
          * Creates a UUID from the string standard representation as described
@@ -128,6 +128,24 @@ namespace util {
          */
         UUID(long long mostSigBits, long long leastSigBits);
 
+        /**
+         * Create a copy of the source UUID
+         *
+         * @param source
+         *      The UUID whose value initializes this UUID
+         */
+        UUID(const UUID& source);
+
+        /**
+         * Copy the source UUID and return a reference to this UUID for chaining.
+         *
+         * @param source
+         *      The UUID whose value replaces the current values in this UUID
+         *
+         * @return a reference to this UUID
+         */
+        UUID& operator= (const UUID& source);
+
         virtual ~UUID();
 
         /**
@@ -147,6 +165,13 @@ namespace util {
         virtual bool equals(const UUID& value) const;
 
         /**
+         * Returns a Hash Code value for this UUID.
+         *
+         * @returns a Hash Code for this UUID
+         */
+        int hashCode() const;
+
+        /**
          * Compares equality between this object and the one passed.
          * @param value - the value to be compared to this one.
          * @return true if this object is equal to the one passed.
@@ -162,21 +187,38 @@ namespace util {
         virtual bool operator<(const UUID& value) const;
 
         /**
-         * Returns a String object representing this UUID.  UUID's are formatted
-         * as: 00112233-4455-6677-8899-AABBCCDDEEFF whose length is 36.
+         * Returns a String object representing this UUID.
+         *
+         * The UUID string representation is as described by this BNF :
+         *
+         *    UUID                   = <time_low> "-" <time_mid> "-"
+         *                             <time_high_and_version> "-"
+         *                             <variant_and_sequence> "-"
+         *                             <node>
+         *    time_low               = 4*<hexOctet>
+         *    time_mid               = 2*<hexOctet>
+         *    time_high_and_version  = 2*<hexOctet>
+         *    variant_and_sequence   = 2*<hexOctet>
+         *    node                   = 6*<hexOctet>
+         *    hexOctet               = <hexDigit><hexDigit>
+         *    hexDigit               =
+         *        "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
+         *      | "a" | "b" | "c" | "d" | "e" | "f"
+         *      | "A" | "B" | "C" | "D" | "E" | "F"
+         *
          * @returns formatted string for this UUID
          */
-        virtual std::string toString() const;
+        std::string toString() const;
 
         /**
          * @returns the most significant 64 bits of this UUID's 128 bit value.
          */
-        virtual long long getLeastSignificantBits() const;
+        long long getLeastSignificantBits() const;
 
         /**
          * @returns the most significant 64 bits of this UUID's 128 bit value.
          */
-        virtual long long getMostSignificantBits() const;
+        long long getMostSignificantBits() const;
 
         /**
          * The node value associated with this UUID.
@@ -193,7 +235,7 @@ namespace util {
          *
          * @throws UnsupportedOperationException if this UUID version does not support this operation.
          */
-        virtual long long node();
+        long long node();
 
         /**
          * The timestamp value associated with this UUID.
@@ -205,10 +247,12 @@ namespace util {
          * The timestamp value is only meaningful in a time-based UUID, which has
          * version type 1. If this UUID is not a time-based UUID then this method
          * throws UnsupportedOperationException.
+         *
          * @returns the timestamp associated with a V1 UUID
+         *
          * @throws UnsupportedOperationException if this UUID version does not support this operation.
          */
-        virtual long long timestamp();
+        long long timestamp();
 
         /**
          * The clock sequence value associated with this UUID.
@@ -220,10 +264,12 @@ namespace util {
          * The clockSequence value is only meaningful in a time-based UUID, which
          * has version type 1. If this UUID is not a time-based UUID then this
          * method throws UnsupportedOperationException.
+         *
          * @returns the clockSequeunce associated with a V1 UUID
+         *
          * @throws UnsupportedOperationException if this UUID version does not support this operation.
          */
-        virtual int clockSequence();
+        int clockSequence();
 
         /**
          * The variant number associated with this UUID. The variant number describes
@@ -238,7 +284,7 @@ namespace util {
          *
          * @throws UnsupportedOperationException if this UUID version does not support this operation.
          */
-        virtual int variant();
+        int variant();
 
         /**
          * The version number associated with this UUID. The version number describes
@@ -253,7 +299,7 @@ namespace util {
          *
          * @throws UnsupportedOperationException if this UUID version does not support this operation.
          */
-        virtual int version();
+        int version();
 
     };
 

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test/Makefile.am
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/Makefile.am?rev=1457307&r1=1457306&r2=1457307&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test/Makefile.am (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test/Makefile.am Sat Mar 16 21:14:01 2013
@@ -192,6 +192,7 @@ cc_sources = \
     decaf/net/URLEncoderTest.cpp \
     decaf/net/ssl/SSLSocketFactoryTest.cpp \
     decaf/nio/BufferTest.cpp \
+    decaf/security/MessageDigestTest.cpp \
     decaf/security/SecureRandomTest.cpp \
     decaf/util/AbstractCollectionTest.cpp \
     decaf/util/AbstractListTest.cpp \
@@ -435,6 +436,7 @@ h_sources = \
     decaf/net/URLEncoderTest.h \
     decaf/net/ssl/SSLSocketFactoryTest.h \
     decaf/nio/BufferTest.h \
+    decaf/security/MessageDigestTest.h \
     decaf/security/SecureRandomTest.h \
     decaf/util/AbstractCollectionTest.h \
     decaf/util/AbstractListTest.h \

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/security/MessageDigestTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/security/MessageDigestTest.cpp?rev=1457307&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/security/MessageDigestTest.cpp (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/security/MessageDigestTest.cpp Sat Mar 16 21:14:01 2013
@@ -0,0 +1,192 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "MessageDigestTest.h"
+
+#include <decaf/lang/Pointer.h>
+#include <decaf/lang/Integer.h>
+#include <decaf/security/MessageDigest.h>
+#include <decaf/security/Provider.h>
+#include <decaf/lang/exceptions/IllegalArgumentException.h>
+#include <decaf/lang/exceptions/NullPointerException.h>
+#include <decaf/security/NoSuchAlgorithmException.h>
+
+using namespace std;
+using namespace decaf;
+using namespace decaf::lang;
+using namespace decaf::lang::exceptions;
+using namespace decaf::security;
+
+////////////////////////////////////////////////////////////////////////////////
+MessageDigestTest::MessageDigestTest() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+MessageDigestTest::~MessageDigestTest() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void MessageDigestTest::testGetInstance1() {
+
+    MessageDigest* digest = MessageDigest::getInstance("MD5");
+
+    CPPUNIT_ASSERT(digest != NULL);
+    CPPUNIT_ASSERT_EQUAL(std::string("MD5"), digest->getAlgorithmName());
+    CPPUNIT_ASSERT_EQUAL(std::string("Decaf"), digest->getProvider()->getName());
+
+    delete digest;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void MessageDigestTest::testGetInstance2() {
+
+    MessageDigest* digest = MessageDigest::getInstance("MD4");
+
+    CPPUNIT_ASSERT(digest != NULL);
+    CPPUNIT_ASSERT_EQUAL(std::string("MD4"), digest->getAlgorithmName());
+    CPPUNIT_ASSERT_EQUAL(std::string("Decaf"), digest->getProvider()->getName());
+
+    delete digest;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void MessageDigestTest::testGetInstance3() {
+
+    MessageDigest* digest = MessageDigest::getInstance("SHA1");
+
+    CPPUNIT_ASSERT(digest != NULL);
+    CPPUNIT_ASSERT_EQUAL(std::string("SHA1"), digest->getAlgorithmName());
+    CPPUNIT_ASSERT_EQUAL(std::string("Decaf"), digest->getProvider()->getName());
+
+    delete digest;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void MessageDigestTest::testGetInstance4() {
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw a NoSuchAlgorithmException",
+        MessageDigest::getInstance("MD3"),
+        NoSuchAlgorithmException);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+namespace {
+
+    std::string toString(const std::vector<unsigned char>& digest) {
+        std::string result;
+        std::vector<unsigned char>::const_iterator iter = digest.begin();
+        std::string pad = "00";
+
+        for (; iter != digest.end(); ++iter) {
+            std::string hex = Integer::toHexString(*iter & 255);
+            result.append(pad.substr(hex.length())).append(hex);
+        }
+        return result;
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void MessageDigestTest::testResults1() {
+
+    Pointer<MessageDigest> digest(MessageDigest::getInstance("MD5"));
+
+    std::string bytes;
+    std::vector<unsigned char> result;
+
+    bytes = "";
+    result = digest->digest((const unsigned char*)bytes.data(), (int)bytes.size());
+    CPPUNIT_ASSERT_EQUAL(std::string("d41d8cd98f00b204e9800998ecf8427e"), toString(result));
+
+    bytes = "a";
+    result = digest->digest((const unsigned char*)bytes.data(), (int)bytes.size());
+    CPPUNIT_ASSERT_EQUAL(std::string("0cc175b9c0f1b6a831c399e269772661"), toString(result));
+
+    bytes = "abc";
+    result = digest->digest((const unsigned char*)bytes.data(), (int)bytes.size());
+    CPPUNIT_ASSERT_EQUAL(std::string("900150983cd24fb0d6963f7d28e17f72"), toString(result));
+
+    bytes = "message digest";
+    result = digest->digest((const unsigned char*)bytes.data(), (int)bytes.size());
+    CPPUNIT_ASSERT_EQUAL(std::string("f96b697d7cb7938d525a2f31aaf161d0"), toString(result));
+
+    bytes = "abcdefghijklmnopqrstuvwxyz";
+    result = digest->digest((const unsigned char*)bytes.data(), (int)bytes.size());
+    CPPUNIT_ASSERT_EQUAL(std::string("c3fcd3d76192e4007dfb496cca67e13b"), toString(result));
+
+    bytes = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
+    result = digest->digest((const unsigned char*)bytes.data(), (int)bytes.size());
+    CPPUNIT_ASSERT_EQUAL(std::string("d174ab98d277d9f5a5611c2c9f419d9f"), toString(result));
+
+    bytes = "12345678901234567890123456789012345678901234567890123456789012345678901234567890";
+    result = digest->digest((const unsigned char*)bytes.data(), (int)bytes.size());
+    CPPUNIT_ASSERT_EQUAL(std::string("57edf4a22be3c955ac49da2e2107b67a"), toString(result));
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void MessageDigestTest::testResults2() {
+
+    Pointer<MessageDigest> digest(MessageDigest::getInstance("MD4"));
+
+    std::string bytes;
+    std::vector<unsigned char> result;
+
+    bytes = "";
+    result = digest->digest((const unsigned char*)bytes.data(), (int)bytes.size());
+    CPPUNIT_ASSERT_EQUAL(std::string("31d6cfe0d16ae931b73c59d7e0c089c0"), toString(result));
+
+    bytes = "a";
+    result = digest->digest((const unsigned char*)bytes.data(), (int)bytes.size());
+    CPPUNIT_ASSERT_EQUAL(std::string("bde52cb31de33e46245e05fbdbd6fb24"), toString(result));
+
+    bytes = "abc";
+    result = digest->digest((const unsigned char*)bytes.data(), (int)bytes.size());
+    CPPUNIT_ASSERT_EQUAL(std::string("a448017aaf21d8525fc10ae87aa6729d"), toString(result));
+
+    bytes = "message digest";
+    result = digest->digest((const unsigned char*)bytes.data(), (int)bytes.size());
+    CPPUNIT_ASSERT_EQUAL(std::string("d9130a8164549fe818874806e1c7014b"), toString(result));
+
+    bytes = "abcdefghijklmnopqrstuvwxyz";
+    result = digest->digest((const unsigned char*)bytes.data(), (int)bytes.size());
+    CPPUNIT_ASSERT_EQUAL(std::string("d79e1c308aa5bbcdeea8ed63df412da9"), toString(result));
+
+    bytes = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
+    result = digest->digest((const unsigned char*)bytes.data(), (int)bytes.size());
+    CPPUNIT_ASSERT_EQUAL(std::string("043f8582f241db351ce627e153e7f0e4"), toString(result));
+
+    bytes = "12345678901234567890123456789012345678901234567890123456789012345678901234567890";
+    result = digest->digest((const unsigned char*)bytes.data(), (int)bytes.size());
+    CPPUNIT_ASSERT_EQUAL(std::string("e33b4ddc9c38f2199c3e7b164fcc0536"), toString(result));
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void MessageDigestTest::testResults3() {
+
+    Pointer<MessageDigest> digest(MessageDigest::getInstance("SHA1"));
+
+    std::string bytes;
+    std::vector<unsigned char> result;
+
+// TODO SHA1 not quite right yet
+//    bytes = "";
+//    result = digest->digest((const unsigned char*)bytes.data(), (int)bytes.size());
+//    CPPUNIT_ASSERT_EQUAL(std::string("da39a3ee5e6b4b0d3255bfef95601890afd80709"), toString(result));
+//
+//    bytes = "The quick brown fox jumps over the lazy dog";
+//    result = digest->digest((const unsigned char*)bytes.data(), (int)bytes.size());
+//    CPPUNIT_ASSERT_EQUAL(std::string("2fd4e1c67a2d28fced849ee1bb76e7391b93eb12"), toString(result));
+}

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/security/MessageDigestTest.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/security/MessageDigestTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/security/MessageDigestTest.h?rev=1457307&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/security/MessageDigestTest.h (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/security/MessageDigestTest.h Sat Mar 16 21:14:01 2013
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _DECAF_SECURITY_MESSAGEDIGESTTEST_H_
+#define _DECAF_SECURITY_MESSAGEDIGESTTEST_H_
+
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+namespace decaf {
+namespace security {
+
+    class MessageDigestTest : public CppUnit::TestFixture {
+
+        CPPUNIT_TEST_SUITE( MessageDigestTest );
+        CPPUNIT_TEST( testGetInstance1 );
+        CPPUNIT_TEST( testGetInstance2 );
+        CPPUNIT_TEST( testGetInstance3 );
+        CPPUNIT_TEST( testGetInstance4 );
+        CPPUNIT_TEST( testResults1 );
+        CPPUNIT_TEST( testResults2 );
+        CPPUNIT_TEST( testResults3 );
+        CPPUNIT_TEST_SUITE_END();
+
+    public:
+
+        MessageDigestTest();
+        virtual ~MessageDigestTest();
+
+        void testGetInstance1();
+        void testGetInstance2();
+        void testGetInstance3();
+        void testGetInstance4();
+
+        void testResults1();
+        void testResults2();
+        void testResults3();
+
+    };
+
+}}
+
+#endif /* _DECAF_SECURITY_MESSAGEDIGESTTEST_H_ */

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/security/MessageDigestTest.h
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/util/UUIDTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/util/UUIDTest.cpp?rev=1457307&r1=1457306&r2=1457307&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/util/UUIDTest.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/util/UUIDTest.cpp Sat Mar 16 21:14:01 2013
@@ -17,35 +17,385 @@
 
 #include "UUIDTest.h"
 
+#include <decaf/lang/Long.h>
 #include <decaf/util/UUID.h>
+#include <decaf/lang/exceptions/NumberFormatException.h>
+#include <decaf/lang/exceptions/UnsupportedOperationException.h>
+#include <decaf/lang/exceptions/IllegalArgumentException.h>
+#include <decaf/lang/exceptions/NullPointerException.h>
+#include <decaf/lang/exceptions/NumberFormatException.h>
 
 using namespace decaf;
 using namespace decaf::util;
+using namespace decaf::lang;
+using namespace decaf::lang::exceptions;
 
 ////////////////////////////////////////////////////////////////////////////////
 UUIDTest::UUIDTest() {
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void UUIDTest::test() {
+void UUIDTest::testConstructor1() {
+    UUID uuid(0xF81D4FAE7DEC11D0LL, 0xA76500A0C91E6BF6LL);
+    CPPUNIT_ASSERT_EQUAL(2, uuid.variant());
+    CPPUNIT_ASSERT_EQUAL(1, uuid.version());
+    CPPUNIT_ASSERT_EQUAL(0x1d07decf81d4faeLL, uuid.timestamp());
+    CPPUNIT_ASSERT_EQUAL(130742845922168750LL, uuid.timestamp());
+    CPPUNIT_ASSERT_EQUAL(0x2765, uuid.clockSequence());
+    CPPUNIT_ASSERT_EQUAL(0xA0C91E6BF6LL, uuid.node());
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void UUIDTest::testGetLeastSignificantBits() {
+    UUID uuid(0, 0);
+    CPPUNIT_ASSERT_EQUAL(0LL, uuid.getLeastSignificantBits());
+    uuid = UUID(0, Long::MIN_VALUE);
+    CPPUNIT_ASSERT_EQUAL(Long::MIN_VALUE, uuid.getLeastSignificantBits());
+    uuid = UUID(0, Long::MAX_VALUE);
+    CPPUNIT_ASSERT_EQUAL(Long::MAX_VALUE, uuid.getLeastSignificantBits());
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void UUIDTest::testGetMostSignificantBits() {
+    UUID uuid(0, 0);
+    CPPUNIT_ASSERT_EQUAL(0LL, uuid.getMostSignificantBits());
+    uuid = UUID(Long::MIN_VALUE, 0LL);
+    CPPUNIT_ASSERT_EQUAL(Long::MIN_VALUE, uuid.getMostSignificantBits());
+    uuid = UUID(Long::MAX_VALUE, 0LL);
+    CPPUNIT_ASSERT_EQUAL(Long::MAX_VALUE, uuid.getMostSignificantBits());
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void UUIDTest::testVersion() {
+    UUID uuid(0, 0);
+    CPPUNIT_ASSERT_EQUAL(0, uuid.version());
+    uuid = UUID(0x0000000000001000LL, 0);
+    CPPUNIT_ASSERT_EQUAL(1, uuid.version());
+    uuid = UUID(0x0000000000002000LL, 0);
+    CPPUNIT_ASSERT_EQUAL(2, uuid.version());
+    uuid = UUID(0x0000000000003000LL, 0);
+    CPPUNIT_ASSERT_EQUAL(3, uuid.version());
+    uuid = UUID(0x0000000000004000LL, 0);
+    CPPUNIT_ASSERT_EQUAL(4, uuid.version());
+    uuid = UUID(0x0000000000005000LL, 0);
+    CPPUNIT_ASSERT_EQUAL(5, uuid.version());
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void UUIDTest::testVariant() {
+    UUID uuid(0, 0x0000000000000000LL);
+    CPPUNIT_ASSERT_EQUAL(0, uuid.variant());
+    uuid = UUID(0, 0x7000000000000000LL);
+    CPPUNIT_ASSERT_EQUAL(0, uuid.variant());
+    uuid = UUID(0, 0x3000000000000000LL);
+    CPPUNIT_ASSERT_EQUAL(0, uuid.variant());
+    uuid = UUID(0, 0x1000000000000000LL);
+    CPPUNIT_ASSERT_EQUAL(0, uuid.variant());
+
+    uuid = UUID(0, 0x8000000000000000LL);
+    CPPUNIT_ASSERT_EQUAL(2, uuid.variant());
+    uuid = UUID(0, 0xB000000000000000LL);
+    CPPUNIT_ASSERT_EQUAL(2, uuid.variant());
+    uuid = UUID(0, 0xA000000000000000LL);
+    CPPUNIT_ASSERT_EQUAL(2, uuid.variant());
+    uuid = UUID(0, 0x9000000000000000LL);
+    CPPUNIT_ASSERT_EQUAL(2, uuid.variant());
+
+    uuid = UUID(0, 0xC000000000000000LL);
+    CPPUNIT_ASSERT_EQUAL(6, uuid.variant());
+    uuid = UUID(0, 0xD000000000000000LL);
+    CPPUNIT_ASSERT_EQUAL(6, uuid.variant());
+
+    uuid = UUID(0, 0xE000000000000000LL);
+    CPPUNIT_ASSERT_EQUAL(7, uuid.variant());
+    uuid = UUID(0, 0xF000000000000000LL);
+    CPPUNIT_ASSERT_EQUAL(7, uuid.variant());
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void UUIDTest::testTimestamp() {
+    UUID uuid(0x0000000000001000LL, 0x8000000000000000LL);
+    CPPUNIT_ASSERT_EQUAL(0x0LL, uuid.timestamp());
+
+    uuid = UUID(0x7777777755551333LL, 0x8000000000000000LL);
+    CPPUNIT_ASSERT_EQUAL(0x333555577777777LL, uuid.timestamp());
+
+    uuid = UUID(0x0000000000000000LL, 0x8000000000000000LL);
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw an UnsupportedOperationException exception",
+        uuid.timestamp(),
+        UnsupportedOperationException);
+
+    uuid = UUID(0x0000000000002000LL, 0x8000000000000000LL);
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw an UnsupportedOperationException exception",
+        uuid.timestamp(),
+        UnsupportedOperationException);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void UUIDTest::testClockSequence() {
+    UUID uuid(0x0000000000001000LL, 0x8000000000000000LL);
+    CPPUNIT_ASSERT_EQUAL(0x0, uuid.clockSequence());
+
+    uuid = UUID(0x0000000000001000L, 0x8FFF000000000000L);
+    CPPUNIT_ASSERT_EQUAL(0x0FFF, uuid.clockSequence());
+
+    uuid = UUID(0x0000000000001000LL, 0xBFFF000000000000LL);
+    CPPUNIT_ASSERT_EQUAL(0x3FFF, uuid.clockSequence());
+
+    uuid = UUID(0x0000000000000000LL, 0x8000000000000000LL);
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw an UnsupportedOperationException exception",
+        uuid.clockSequence(),
+        UnsupportedOperationException);
+
+    uuid = UUID(0x0000000000002000LL, 0x8000000000000000LL);
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw an UnsupportedOperationException exception",
+        uuid.clockSequence(),
+        UnsupportedOperationException);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void UUIDTest::testNode() {
+    UUID uuid(0x0000000000001000LL, 0x8000000000000000LL);
+    CPPUNIT_ASSERT_EQUAL(0x0LL, uuid.node());
+
+    uuid = UUID(0x0000000000001000LL, 0x8000FFFFFFFFFFFFLL);
+    CPPUNIT_ASSERT_EQUAL(0xFFFFFFFFFFFFLL, uuid.node());
+
+    uuid = UUID(0x0000000000000000LL, 0x8000000000000000LL);
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw an UnsupportedOperationException exception",
+        uuid.node(),
+        UnsupportedOperationException);
+
+    uuid = UUID(0x0000000000002000LL, 0x8000000000000000LL);
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw an UnsupportedOperationException exception",
+        uuid.node(),
+        UnsupportedOperationException);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void UUIDTest::testCompareTo() {
+    UUID uuid1(0, 0);
+    CPPUNIT_ASSERT_EQUAL(0, uuid1.compareTo(uuid1));
+    UUID uuid2(1, 0);
+    CPPUNIT_ASSERT_EQUAL(-1, uuid1.compareTo(uuid2));
+    CPPUNIT_ASSERT_EQUAL(1, uuid2.compareTo(uuid1));
+
+    uuid2 = UUID(0, 1);
+    CPPUNIT_ASSERT_EQUAL(-1, uuid1.compareTo(uuid2));
+    CPPUNIT_ASSERT_EQUAL(1, uuid2.compareTo(uuid1));
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void UUIDTest::testHashCode() {
+    UUID uuid(0, 0);
+    CPPUNIT_ASSERT_EQUAL(0, uuid.hashCode());
+    uuid = UUID(123, 123);
+    UUID uuidClone(123, 123);
+    CPPUNIT_ASSERT_EQUAL(uuid.hashCode(), uuidClone.hashCode());
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void UUIDTest::testEquals() {
+    UUID uuid1(0, 0);
+    CPPUNIT_ASSERT(uuid1.equals(uuid1));
+
+    UUID uuid2(0, 0);
+    CPPUNIT_ASSERT(uuid1.equals(uuid2));
+    CPPUNIT_ASSERT(uuid2.equals(uuid1));
+
+    uuid1 = UUID(0xf81d4fae7dec11d0LL, 0xa76500a0c91e6bf6LL);
+    uuid2 = UUID(0xf81d4fae7dec11d0LL, 0xa76500a0c91e6bf6LL);
+    CPPUNIT_ASSERT(uuid1.equals(uuid2));
+    CPPUNIT_ASSERT(uuid2.equals(uuid1));
+
+    uuid2 = UUID(0xf81d4fae7dec11d0LL, 0xa76500a0c91e6bf7LL);
+    CPPUNIT_ASSERT(!uuid1.equals(uuid2));
+    CPPUNIT_ASSERT(!uuid2.equals(uuid1));
+}
 
-    std::string bytes = "ASDASFSADGSDGSDASFA";
+////////////////////////////////////////////////////////////////////////////////
+void UUIDTest::testToString() {
+    UUID uuid(0xf81d4fae7dec11d0LL, 0xa76500a0c91e6bf6LL);
+    std::string actual = uuid.toString();
+    CPPUNIT_ASSERT_EQUAL(std::string("f81d4fae-7dec-11d0-a765-00a0c91e6bf6"), actual);
+
+    uuid = UUID(0x0000000000001000L, 0x8000000000000000L);
+    actual = uuid.toString();
+    CPPUNIT_ASSERT_EQUAL(std::string("00000000-0000-1000-8000-000000000000"), actual);
+}
 
-    UUID randId = UUID::randomUUID();
-    UUID bytesId = UUID::nameUUIDFromBytes( bytes.c_str(), bytes.size() );
+////////////////////////////////////////////////////////////////////////////////
+void UUIDTest::testRandomUUID() {
+    UUID uuid = UUID::randomUUID();
+    CPPUNIT_ASSERT_EQUAL(2, uuid.variant());
+    CPPUNIT_ASSERT_EQUAL(4, uuid.version());
+}
 
-    CPPUNIT_ASSERT( !( randId == bytesId ) );
-    CPPUNIT_ASSERT( !( randId.equals( bytesId ) ) );
-    CPPUNIT_ASSERT( randId.compareTo( bytesId ) != 0 );
+////////////////////////////////////////////////////////////////////////////////
+void UUIDTest::testNameUUIDFromBytes() {
+    char name[16] = {
+        (char) 0x6b, (char) 0xa7, (char) 0xb8, (char) 0x11,
+        (char) 0x9d, (char) 0xad, (char) 0x11, (char) 0xd1,
+        (char) 0x80, (char) 0xb4, (char) 0x00, (char) 0xc0,
+        (char) 0x4f, (char) 0xd4, (char) 0x30, (char) 0xc8 };
+
+    UUID uuid = UUID::nameUUIDFromBytes(&name[0], 16);
+
+    CPPUNIT_ASSERT_EQUAL(2, uuid.variant());
+    CPPUNIT_ASSERT_EQUAL(3, uuid.version());
+
+    CPPUNIT_ASSERT_EQUAL(0xaff565bc2f771745LL, (unsigned long long) uuid.getLeastSignificantBits());
+    CPPUNIT_ASSERT_EQUAL(0x14cdb9b4de013faaLL, uuid.getMostSignificantBits());
+
+    uuid = UUID::nameUUIDFromBytes(std::vector<char>());
+    CPPUNIT_ASSERT_EQUAL(2, uuid.variant());
+    CPPUNIT_ASSERT_EQUAL(3, uuid.version());
+
+    CPPUNIT_ASSERT_EQUAL(0xa9800998ecf8427eLL, (unsigned long long) uuid.getLeastSignificantBits());
+    CPPUNIT_ASSERT_EQUAL(0xd41d8cd98f003204LL, (unsigned long long) uuid.getMostSignificantBits());
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw an NullPointerException exception",
+        UUID::nameUUIDFromBytes(NULL, 1),
+        NullPointerException);
+}
 
-    std::string uuidStr = randId.toString();
-    UUID strId = UUID::fromString( uuidStr );
+////////////////////////////////////////////////////////////////////////////////
+void UUIDTest::testFromString() {
+    UUID actual = UUID::fromString("f81d4fae-7dec-11d0-a765-00a0c91e6bf6");
+    UUID expected = UUID(0xf81d4fae7dec11d0LL, 0xa76500a0c91e6bf6LL);
+    CPPUNIT_ASSERT(expected.equals(actual));
+
+    CPPUNIT_ASSERT_EQUAL(2, actual.variant());
+    CPPUNIT_ASSERT_EQUAL(1, actual.version());
+    CPPUNIT_ASSERT_EQUAL(130742845922168750LL, actual.timestamp());
+    CPPUNIT_ASSERT_EQUAL(10085, actual.clockSequence());
+    CPPUNIT_ASSERT_EQUAL(690568981494LL, actual.node());
+
+    actual = UUID::fromString("00000000-0000-1000-8000-000000000000");
+    expected = UUID(0x0000000000001000LL, 0x8000000000000000L);
+    CPPUNIT_ASSERT(expected.equals(actual));
+
+    CPPUNIT_ASSERT_EQUAL(2, actual.variant());
+    CPPUNIT_ASSERT_EQUAL(1, actual.version());
+    CPPUNIT_ASSERT_EQUAL(0LL, actual.timestamp());
+    CPPUNIT_ASSERT_EQUAL(0, actual.clockSequence());
+    CPPUNIT_ASSERT_EQUAL(0LL, actual.node());
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw an IllegalArgumentException exception",
+        UUID::fromString(""),
+        IllegalArgumentException);
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw an IllegalArgumentException exception",
+        UUID::fromString("f81d4fae_7dec-11d0-a765-00a0c91e6bf6"),
+        IllegalArgumentException);
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw an IllegalArgumentException exception",
+        UUID::fromString("f81d4fae-7dec_11d0-a765-00a0c91e6bf6"),
+        IllegalArgumentException);
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw an IllegalArgumentException exception",
+        UUID::fromString("f81d4fae-7dec-11d0_a765-00a0c91e6bf6"),
+        IllegalArgumentException);
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw an IllegalArgumentException exception",
+        UUID::fromString("f81d4fae-7dec-11d0-a765_00a0c91e6bf6"),
+        IllegalArgumentException);
+}
 
-    CPPUNIT_ASSERT( randId == strId );
-    CPPUNIT_ASSERT( randId.variant() == 2 );
+////////////////////////////////////////////////////////////////////////////////
+void UUIDTest::testFromStringStringException() {
 
-    UUID fromBits( randId.getMostSignificantBits(),
-                   randId.getLeastSignificantBits() );
+    UUID uuid = UUID::fromString("0-0-0-0-0");
 
-    CPPUNIT_ASSERT( randId.compareTo( fromBits) == 0 );
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw an IllegalArgumentException exception",
+        UUID::fromString("0-0-0-0-"),
+        IllegalArgumentException);
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw an IllegalArgumentException exception",
+        UUID::fromString("00000"),
+        IllegalArgumentException);
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw an IllegalArgumentException exception",
+        UUID::fromString("----"),
+        IllegalArgumentException);
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw an IllegalArgumentException exception",
+        UUID::fromString("-0-0-0-0-0"),
+        IllegalArgumentException);
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw an IllegalArgumentException exception",
+        UUID::fromString("-0-0-0-0"),
+        IllegalArgumentException);
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw an IllegalArgumentException exception",
+        UUID::fromString("-0-0-0-"),
+        IllegalArgumentException);
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw an IllegalArgumentException exception",
+        UUID::fromString("0--0-0-0"),
+        IllegalArgumentException);
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw an IllegalArgumentException exception",
+        UUID::fromString("0-0-0-0-"),
+        IllegalArgumentException);
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw an IllegalArgumentException exception",
+        UUID::fromString("-1-0-0-0-0"),
+        IllegalArgumentException);
+
+    uuid = UUID::fromString("123456789-0-0-0-0");
+    CPPUNIT_ASSERT_EQUAL(0x2345678900000000LL, uuid.getMostSignificantBits());
+    CPPUNIT_ASSERT_EQUAL(0x0LL, uuid.getLeastSignificantBits());
+
+    uuid = UUID::fromString("111123456789-0-0-0-0");
+    CPPUNIT_ASSERT_EQUAL(0x2345678900000000LL, uuid.getMostSignificantBits());
+    CPPUNIT_ASSERT_EQUAL(0x0LL, uuid.getLeastSignificantBits());
+
+    uuid = UUID::fromString("7fffffffffffffff-0-0-0-0");
+    CPPUNIT_ASSERT_EQUAL(0xffffffff00000000LL, (unsigned long long) uuid.getMostSignificantBits());
+    CPPUNIT_ASSERT_EQUAL(0x0LL, uuid.getLeastSignificantBits());
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw an IllegalArgumentException exception",
+        UUID::fromString("8000000000000000-0-0-0-0"),
+        NumberFormatException);
+
+    uuid = UUID::fromString("7fffffffffffffff-7fffffffffffffff-7fffffffffffffff-0-0");
+    CPPUNIT_ASSERT_EQUAL(0xffffffffffffffffLL, (unsigned long long) uuid.getMostSignificantBits());
+    CPPUNIT_ASSERT_EQUAL(0x0LL, uuid.getLeastSignificantBits());
+
+    uuid = UUID::fromString("0-0-0-7fffffffffffffff-7fffffffffffffff");
+    CPPUNIT_ASSERT_EQUAL(0x0LL, uuid.getMostSignificantBits());
+    CPPUNIT_ASSERT_EQUAL(0xffffffffffffffffLL, (unsigned long long) uuid.getLeastSignificantBits());
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw an IllegalArgumentException exception",
+        UUID::fromString("0-0-0-8000000000000000-0"),
+        NumberFormatException);
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw an IllegalArgumentException exception",
+        UUID::fromString("0-0-0-0-8000000000000000"),
+        NumberFormatException);
 }



Mime
View raw message