activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1457307 [1/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
Author: tabish
Date: Sat Mar 16 21:14:01 2013
New Revision: 1457307

URL: http://svn.apache.org/r1457307
Log:
Code updates, fixes.  Implements some of the security classes needed to remove dependency on apr-util

Added:
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/Engine.cpp   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/Engine.h   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/SecurityRuntime.cpp   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/SecurityRuntime.h   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/ServiceRegistry.cpp   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/ServiceRegistry.h   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/DefaultMessageDigestProviderService.cpp   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/DefaultMessageDigestProviderService.h   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/DefaultProvider.cpp   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/DefaultProvider.h   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/DefaultSecureRandomProviderService.cpp   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/DefaultSecureRandomProviderService.h   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/crypto/
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/crypto/MD4MessageDigestSpi.cpp   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/crypto/MD4MessageDigestSpi.h   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/crypto/MD5MessageDigestSpi.cpp   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/crypto/MD5MessageDigestSpi.h   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/crypto/SHA1MessageDigestSpi.cpp   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/crypto/SHA1MessageDigestSpi.h   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/exceptions/CloneNotSupportedException.cpp   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/exceptions/CloneNotSupportedException.h   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/DigestException.cpp   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/DigestException.h   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/GeneralSecurityException.cpp   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/InvalidKeyException.cpp   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/Key.cpp   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/KeyException.cpp   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/KeyManagementException.cpp   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/MessageDigest.cpp   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/MessageDigest.h   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/MessageDigestSpi.cpp   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/MessageDigestSpi.h   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/NoSuchAlgorithmException.cpp   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/NoSuchProviderException.cpp   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/Principal.cpp   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/Provider.cpp   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/Provider.h   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/ProviderException.cpp   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/ProviderException.h   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/ProviderService.cpp   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/ProviderService.h   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/PublicKey.cpp   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/Security.cpp   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/Security.h   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/SecuritySpi.cpp   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/SecuritySpi.h   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/SignatureException.cpp   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/auth/x500/X500Principal.cpp   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/cert/Certificate.cpp   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/cert/CertificateEncodingException.cpp   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/cert/CertificateException.cpp   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/cert/CertificateExpiredException.cpp   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/cert/CertificateNotYetValidException.cpp   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/cert/CertificateParsingException.cpp   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/cert/X509Certificate.cpp   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/security/MessageDigestTest.cpp   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/security/MessageDigestTest.h   (with props)
Modified:
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/DecafRuntime.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/Network.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/Network.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Byte.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Byte.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Double.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Double.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Float.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Float.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Integer.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Integer.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Long.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Long.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Short.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Short.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/GeneralSecurityException.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/InvalidKeyException.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/Key.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/KeyException.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/KeyManagementException.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/NoSuchAlgorithmException.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/NoSuchProviderException.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/Principal.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/PublicKey.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/SecureRandomSpi.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/SecureRandomSpi.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/SignatureException.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/auth/x500/X500Principal.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/cert/Certificate.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/cert/CertificateEncodingException.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/cert/CertificateException.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/cert/CertificateExpiredException.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/cert/CertificateNotYetValidException.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/cert/CertificateParsingException.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/security/cert/X509Certificate.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/HashMap.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/UUID.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/UUID.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/test/Makefile.am
    activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/util/UUIDTest.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/util/UUIDTest.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/test/testRegistry.cpp

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am?rev=1457307&r1=1457306&r2=1457307&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am Sat Mar 16 21:14:01 2013
@@ -354,6 +354,15 @@ cc_sources = \
     decaf/internal/nio/IntArrayBuffer.cpp \
     decaf/internal/nio/LongArrayBuffer.cpp \
     decaf/internal/nio/ShortArrayBuffer.cpp \
+    decaf/internal/security/Engine.cpp \
+    decaf/internal/security/SecurityRuntime.cpp \
+    decaf/internal/security/ServiceRegistry.cpp \
+    decaf/internal/security/provider/DefaultMessageDigestProviderService.cpp \
+    decaf/internal/security/provider/DefaultProvider.cpp \
+    decaf/internal/security/provider/DefaultSecureRandomProviderService.cpp \
+    decaf/internal/security/provider/crypto/MD4MessageDigestSpi.cpp \
+    decaf/internal/security/provider/crypto/MD5MessageDigestSpi.cpp \
+    decaf/internal/security/provider/crypto/SHA1MessageDigestSpi.cpp \
     decaf/internal/security/unix/SecureRandomImpl.cpp \
     decaf/internal/util/ByteArrayAdapter.cpp \
     decaf/internal/util/GenericResource.cpp \
@@ -433,6 +442,7 @@ cc_sources = \
     decaf/lang/Throwable.cpp \
     decaf/lang/Types.cpp \
     decaf/lang/exceptions/ClassCastException.cpp \
+    decaf/lang/exceptions/CloneNotSupportedException.cpp \
     decaf/lang/exceptions/IllegalArgumentException.cpp \
     decaf/lang/exceptions/IllegalMonitorStateException.cpp \
     decaf/lang/exceptions/IllegalStateException.cpp \
@@ -495,8 +505,34 @@ cc_sources = \
     decaf/nio/LongBuffer.cpp \
     decaf/nio/ReadOnlyBufferException.cpp \
     decaf/nio/ShortBuffer.cpp \
+    decaf/security/DigestException.cpp \
+    decaf/security/GeneralSecurityException.cpp \
+    decaf/security/InvalidKeyException.cpp \
+    decaf/security/Key.cpp \
+    decaf/security/KeyException.cpp \
+    decaf/security/KeyManagementException.cpp \
+    decaf/security/MessageDigest.cpp \
+    decaf/security/MessageDigestSpi.cpp \
+    decaf/security/NoSuchAlgorithmException.cpp \
+    decaf/security/NoSuchProviderException.cpp \
+    decaf/security/Principal.cpp \
+    decaf/security/Provider.cpp \
+    decaf/security/ProviderException.cpp \
+    decaf/security/ProviderService.cpp \
+    decaf/security/PublicKey.cpp \
     decaf/security/SecureRandom.cpp \
     decaf/security/SecureRandomSpi.cpp \
+    decaf/security/Security.cpp \
+    decaf/security/SecuritySpi.cpp \
+    decaf/security/SignatureException.cpp \
+    decaf/security/auth/x500/X500Principal.cpp \
+    decaf/security/cert/Certificate.cpp \
+    decaf/security/cert/CertificateEncodingException.cpp \
+    decaf/security/cert/CertificateException.cpp \
+    decaf/security/cert/CertificateExpiredException.cpp \
+    decaf/security/cert/CertificateNotYetValidException.cpp \
+    decaf/security/cert/CertificateParsingException.cpp \
+    decaf/security/cert/X509Certificate.cpp \
     decaf/util/AbstractCollection.cpp \
     decaf/util/AbstractList.cpp \
     decaf/util/AbstractMap.cpp \
@@ -957,6 +993,15 @@ h_sources = \
     decaf/internal/nio/IntArrayBuffer.h \
     decaf/internal/nio/LongArrayBuffer.h \
     decaf/internal/nio/ShortArrayBuffer.h \
+    decaf/internal/security/Engine.h \
+    decaf/internal/security/SecurityRuntime.h \
+    decaf/internal/security/ServiceRegistry.h \
+    decaf/internal/security/provider/DefaultMessageDigestProviderService.h \
+    decaf/internal/security/provider/DefaultProvider.h \
+    decaf/internal/security/provider/DefaultSecureRandomProviderService.h \
+    decaf/internal/security/provider/crypto/MD4MessageDigestSpi.h \
+    decaf/internal/security/provider/crypto/MD5MessageDigestSpi.h \
+    decaf/internal/security/provider/crypto/SHA1MessageDigestSpi.h \
     decaf/internal/security/unix/SecureRandomImpl.h \
     decaf/internal/security/windows/SecureRandomImpl.h \
     decaf/internal/util/ByteArrayAdapter.h \
@@ -1043,6 +1088,7 @@ h_sources = \
     decaf/lang/Throwable.h \
     decaf/lang/Types.h \
     decaf/lang/exceptions/ClassCastException.h \
+    decaf/lang/exceptions/CloneNotSupportedException.h \
     decaf/lang/exceptions/ExceptionDefines.h \
     decaf/lang/exceptions/IllegalArgumentException.h \
     decaf/lang/exceptions/IllegalMonitorStateException.h \
@@ -1106,17 +1152,25 @@ h_sources = \
     decaf/nio/LongBuffer.h \
     decaf/nio/ReadOnlyBufferException.h \
     decaf/nio/ShortBuffer.h \
+    decaf/security/DigestException.h \
     decaf/security/GeneralSecurityException.h \
     decaf/security/InvalidKeyException.h \
     decaf/security/Key.h \
     decaf/security/KeyException.h \
     decaf/security/KeyManagementException.h \
+    decaf/security/MessageDigest.h \
+    decaf/security/MessageDigestSpi.h \
     decaf/security/NoSuchAlgorithmException.h \
     decaf/security/NoSuchProviderException.h \
     decaf/security/Principal.h \
+    decaf/security/Provider.h \
+    decaf/security/ProviderException.h \
+    decaf/security/ProviderService.h \
     decaf/security/PublicKey.h \
     decaf/security/SecureRandom.h \
     decaf/security/SecureRandomSpi.h \
+    decaf/security/Security.h \
+    decaf/security/SecuritySpi.h \
     decaf/security/SignatureException.h \
     decaf/security/auth/x500/X500Principal.h \
     decaf/security/cert/Certificate.h \

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/DecafRuntime.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/DecafRuntime.cpp?rev=1457307&r1=1457306&r2=1457307&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/DecafRuntime.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/DecafRuntime.cpp Sat Mar 16 21:14:01 2013
@@ -24,11 +24,13 @@
 #include <decaf/lang/System.h>
 #include <decaf/lang/Thread.h>
 #include <decaf/internal/net/Network.h>
+#include <decaf/internal/security/SecurityRuntime.h>
 #include <decaf/internal/util/concurrent/Threading.h>
 
 using namespace decaf;
 using namespace decaf::internal;
 using namespace decaf::internal::net;
+using namespace decaf::internal::security;
 using namespace decaf::internal::util::concurrent;
 using namespace decaf::lang;
 using namespace decaf::util::concurrent;
@@ -71,18 +73,13 @@ void Runtime::initializeRuntime(int argc
     apr_pool_create_ex(&aprPool, NULL, NULL, NULL);
 
     Runtime::getRuntime();
-
-    // Initialize any Platform specific Threading primitives
     Threading::initialize();
 
-    // Create the global Lock object now that Threading is started.
     globalLock = new Mutex;
 
-    // Initialize the System Class to make things like Properties available.
     System::initSystem(argc, argv);
-
-    // Initialize the Networking layer.
     Network::initializeNetworking();
+    SecurityRuntime::initializeSecurity();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -93,12 +90,12 @@ void Runtime::initializeRuntime() {
 ////////////////////////////////////////////////////////////////////////////////
 void Runtime::shutdownRuntime() {
 
+    SecurityRuntime::shutdownSecurity();
+
     // Shutdown the networking layer before Threading, many network routines need
     // to be thread safe and require Threading primitives.
     Network::shutdownNetworking();
 
-    // Shutdown the System class so that the Properties and other resources are
-    // cleaned up.
     System::shutdownSystem();
 
     // This must go away before Threading is shutdown.

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/Network.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/Network.cpp?rev=1457307&r1=1457306&r2=1457307&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/Network.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/Network.cpp Sat Mar 16 21:14:01 2013
@@ -39,15 +39,15 @@ using namespace decaf::util::concurrent;
 Network* Network::networkRuntime = NULL;
 
 ////////////////////////////////////////////////////////////////////////////////
-namespace decaf{
-namespace internal{
-namespace net{
+namespace decaf {
+namespace internal {
+namespace net {
 
     class NetworkData {
     private:
 
-        NetworkData( const NetworkData& );
-        NetworkData& operator=( const NetworkData& );
+        NetworkData(const NetworkData&);
+        NetworkData& operator=(const NetworkData&);
 
     public:
 
@@ -55,49 +55,48 @@ namespace net{
         Mutex lock;
         LinkedList<Runnable*> shutdownTasks;
 
-        NetworkData() : resources(), lock(), shutdownTasks() {
-        }
+        NetworkData() : resources(), lock(), shutdownTasks() {}
 
         ~NetworkData() {
-            try{
-                std::auto_ptr< Iterator<Runnable*> > iter( shutdownTasks.iterator() );
-                while( iter->hasNext() ) {
+            try {
+                std::auto_ptr<Iterator<Runnable*> > iter(shutdownTasks.iterator());
+                while (iter->hasNext()) {
                     Runnable* task = iter->next();
-                    try{
+                    try {
                         task->run();
                         delete task;
-                    } catch(...) {}
+                    } catch (...) {
+                    }
                 }
-            } catch(...) {}
+            } catch (...) {
+            }
         }
     };
 
 }}}
 
 ////////////////////////////////////////////////////////////////////////////////
-Network::Network() : data( new NetworkData() ) {
+Network::Network() : data(new NetworkData()) {
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 Network::~Network() {
-    try{
+    try {
         delete this->data;
     }
-    DECAF_CATCH_NOTHROW( Exception )
-    DECAF_CATCHALL_NOTHROW()
-}
+    DECAF_CATCH_NOTHROW( Exception)
+    DECAF_CATCHALL_NOTHROW()}
 
 ////////////////////////////////////////////////////////////////////////////////
-void Network::addNetworkResource( Resource* value ) {
-    this->data->resources.addResource( value );
+void Network::addNetworkResource(Resource* value) {
+    this->data->resources.addResource(value);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 Network* Network::getNetworkRuntime() {
 
-    if( Network::networkRuntime == NULL ) {
-        throw IllegalStateException(
-            __FILE__, __LINE__, "Network Runtime is not Initialized." );
+    if (Network::networkRuntime == NULL) {
+        throw IllegalStateException(__FILE__, __LINE__, "Network Runtime is not Initialized.");
     }
 
     return Network::networkRuntime;
@@ -105,8 +104,7 @@ Network* Network::getNetworkRuntime() {
 
 ////////////////////////////////////////////////////////////////////////////////
 Mutex* Network::getRuntimeLock() {
-
-    return &( this->data->lock );
+    return &(this->data->lock);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -115,23 +113,20 @@ void Network::initializeNetworking() {
 #ifndef WIN32
     // Remove the SIGPIPE so that the application isn't aborted if a connected
     // socket breaks during a read or write.
-    apr_signal_block( SIGPIPE );
+    apr_signal_block(SIGPIPE);
 #endif
 
-    // Create the Network Runtime
     Network::networkRuntime = new Network();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 void Network::shutdownNetworking() {
-
-    // Destory the Network Runtime.
     delete Network::networkRuntime;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void Network::addShutdownTask( decaf::lang::Runnable* task ) {
-    if( task != NULL ) {
-        this->data->shutdownTasks.add( task );
+void Network::addShutdownTask(decaf::lang::Runnable* task) {
+    if (task != NULL) {
+        this->data->shutdownTasks.add(task);
     }
 }

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/Network.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/Network.h?rev=1457307&r1=1457306&r2=1457307&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/Network.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/Network.h Sat Mar 16 21:14:01 2013
@@ -45,8 +45,8 @@ namespace net {
 
     private:
 
-        Network( const Network& );
-        Network& operator= ( const Network& );
+        Network(const Network&);
+        Network& operator=(const Network&);
 
     protected:
 
@@ -78,13 +78,12 @@ namespace net {
          *
          * @throw NullPointerException if the Resource value passed is null.
          */
-        void addNetworkResource( decaf::internal::util::Resource* value );
+        void addNetworkResource(decaf::internal::util::Resource* value);
 
         template<typename T>
-        void addAsResource( T* value ) {
-
-            util::GenericResource<T>* resource = new util::GenericResource<T>( value );
-            this->addNetworkResource( resource );
+        void addAsResource(T* value) {
+            util::GenericResource<T>* resource = new util::GenericResource<T>(value);
+            this->addNetworkResource(resource);
         }
 
         /**
@@ -94,7 +93,7 @@ namespace net {
          * to the NetworkRuntime to guarantee the timing of resource cleanup.
          *
          * The cleanup tasks are run at a critical time in the Shutdown process and should
-         * be as simple as possible and make every attempt to no throw any exceptions.  If an
+         * be as simple as possible and make every attempt to not throw any exceptions.  If an
          * exception is thrown it is ignored and processing of the next task is started.
          *
          * The tasks should not assume that any Network resources are still available and
@@ -103,7 +102,7 @@ namespace net {
          * @param task
          *      Pointer to a Runnable object that will now be owned by the Network Runtime.
          */
-        void addShutdownTask( decaf::lang::Runnable* task );
+        void addShutdownTask(decaf::lang::Runnable* task);
 
     public:   // Static methods
 

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/Engine.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/Engine.cpp?rev=1457307&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/Engine.cpp (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/Engine.cpp Sat Mar 16 21:14:01 2013
@@ -0,0 +1,68 @@
+/*
+ * 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 "Engine.h"
+
+#include <decaf/security/SecuritySpi.h>
+#include <decaf/security/Provider.h>
+#include <decaf/security/ProviderService.h>
+#include <decaf/security/NoSuchAlgorithmException.h>
+
+#include <decaf/internal/security/SecurityRuntime.h>
+#include <decaf/internal/security/ServiceRegistry.h>
+
+using namespace decaf;
+using namespace decaf::security;
+using namespace decaf::internal;
+using namespace decaf::internal::security;
+
+////////////////////////////////////////////////////////////////////////////////
+Engine::Engine(const std::string& serviceName) : serviceName(serviceName), provider(NULL) {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+Engine::~Engine() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+SecuritySpi* Engine::newInstance(const std::string& algorithmName) {
+
+    if (algorithmName.empty()) {
+        throw NoSuchAlgorithmException(__FILE__, __LINE__, "Null algorithm name");
+    }
+
+    SecurityRuntime* runtime = SecurityRuntime::getSecurityRuntime();
+    SecuritySpi* spi = NULL;
+
+    synchronized(runtime->getRuntimeLock()) {
+        std::string providerServiceName = serviceName + "." + algorithmName;
+
+        ServiceRegistry* registry = runtime->getServiceRegistry();
+        ProviderService* service = registry->getService(providerServiceName);
+
+        if (service == NULL) {
+            throw NoSuchAlgorithmException(__FILE__, __LINE__,
+                "%s Implementation not found", providerServiceName.c_str());
+        }
+
+        this->provider = service->getProvider();
+
+        spi = service->newInstance();
+    }
+
+    return spi;
+}

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

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/Engine.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/Engine.h?rev=1457307&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/Engine.h (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/Engine.h Sat Mar 16 21:14:01 2013
@@ -0,0 +1,93 @@
+/*
+ * 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_INTERNAL_SECURITY_ENGINE_H_
+#define _DECAF_INTERNAL_SECURITY_ENGINE_H_
+
+#include <decaf/util/Config.h>
+
+#include <string>
+
+namespace decaf {
+namespace security {
+    class Provider;
+    class SecuritySpi;
+}
+namespace internal {
+namespace security {
+
+    /**
+     * The Engine class serves as a convenience class for classes in the
+     * Decaf Security package.  An engine can be created for a given service
+     * type, "MessageDigest" for instance and reused to create different
+     * algorithms for that type.  The Engine class takes care of the details
+     * of looking up a ProviderService in the Security Runtime, using correct
+     * locking and exception handling so that the higher level classes don't
+     * need to implement that logic over again.
+     */
+    class DECAF_API Engine {
+    private:
+
+        std::string serviceName;
+        const decaf::security::Provider* provider;
+
+    private:
+
+        Engine(const Engine&);
+        Engine operator= (const Engine&);
+
+    public:
+
+        Engine(const std::string& serviceName);
+
+        virtual ~Engine();
+
+        /**
+         * Returns the name of the service type that this Engine will be a
+         * builder of SecuritySpi instances for.
+         *
+         * @returns the service class name of this engine, e.g. MessageDigest.
+         */
+        std::string getServiceName() const {
+            return this->serviceName;
+        }
+
+        /**
+         * Returns the Provider associated with this Engine.
+         *
+         * The pointer returned by this method remains the property of the Security framework
+         * and should be deleted by the calling application at any time.
+         *
+         * @return the provider associated with this MessageDigest.
+         */
+        const decaf::security::Provider* getProvider() const {
+            return this->provider;
+        }
+
+        /**
+         * Return a new instance of the SercuritySpi implementation that is named by
+         * this engine's serviceName and the passed algorithmName.
+         *
+         * @returns a new instance of the SecuritySpi provided by serviceName.algorithmName
+         */
+        decaf::security::SecuritySpi* newInstance(const std::string& algorithmName);
+
+    };
+
+}}}
+
+#endif /* _DECAF_INTERNAL_SECURITY_ENGINE_H_ */

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/Engine.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/SecurityRuntime.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/SecurityRuntime.cpp?rev=1457307&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/SecurityRuntime.cpp (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/SecurityRuntime.cpp Sat Mar 16 21:14:01 2013
@@ -0,0 +1,112 @@
+/*
+ * 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 "SecurityRuntime.h"
+
+#include <decaf/lang/exceptions/IllegalStateException.h>
+#include <decaf/internal/security/ServiceRegistry.h>
+#include <decaf/internal/security/provider/DefaultProvider.h>
+
+using namespace decaf;
+using namespace decaf::security;
+using namespace decaf::internal;
+using namespace decaf::internal::security;
+using namespace decaf::internal::security::provider;
+using namespace decaf::lang;
+using namespace decaf::lang::exceptions;
+using namespace decaf::util;
+using namespace decaf::util::concurrent;
+
+////////////////////////////////////////////////////////////////////////////////
+SecurityRuntime* SecurityRuntime::securityRuntime = NULL;
+
+////////////////////////////////////////////////////////////////////////////////
+namespace decaf {
+namespace internal {
+namespace security {
+
+    class SecurityRuntimeImpl {
+    private:
+
+        SecurityRuntimeImpl(const SecurityRuntimeImpl&);
+        SecurityRuntimeImpl& operator=(const SecurityRuntimeImpl&);
+
+    public:
+
+        Mutex lock;
+        ServiceRegistry* registry;
+        Provider* defaultProvider;
+
+        SecurityRuntimeImpl() : lock(), registry(), defaultProvider() {
+            registry = new ServiceRegistry();
+        }
+
+        ~SecurityRuntimeImpl() {
+            delete registry;
+            delete defaultProvider;
+        }
+    };
+
+}}}
+
+////////////////////////////////////////////////////////////////////////////////
+SecurityRuntime::SecurityRuntime() : impl(new SecurityRuntimeImpl) {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+SecurityRuntime::~SecurityRuntime() {
+    try {
+        delete this->impl;
+    }
+    DECAF_CATCHALL_NOTHROW()
+}
+
+////////////////////////////////////////////////////////////////////////////////
+SecurityRuntime* SecurityRuntime::getSecurityRuntime() {
+
+    if( SecurityRuntime::securityRuntime == NULL ) {
+        throw IllegalStateException(
+            __FILE__, __LINE__, "SecurityRuntime Runtime is not Initialized." );
+    }
+
+    return SecurityRuntime::securityRuntime;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+Mutex* SecurityRuntime::getRuntimeLock() {
+    return &(this->impl->lock);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+ServiceRegistry* SecurityRuntime::getServiceRegistry() {
+    return this->impl->registry;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void SecurityRuntime::initializeSecurity() {
+    SecurityRuntime::securityRuntime = new SecurityRuntime();
+
+    DefaultProvider* defaultProvider = new DefaultProvider();
+    securityRuntime->impl->defaultProvider = defaultProvider;
+    defaultProvider->initialize();
+    securityRuntime->impl->registry->addProvider(defaultProvider);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void SecurityRuntime::shutdownSecurity() {
+    delete SecurityRuntime::securityRuntime;
+}

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

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/SecurityRuntime.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/SecurityRuntime.h?rev=1457307&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/SecurityRuntime.h (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/SecurityRuntime.h Sat Mar 16 21:14:01 2013
@@ -0,0 +1,104 @@
+/*
+ * 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_INTERNAL_SECURITYRUNTIME_H_
+#define _DECAF_INTERNAL_SECURITYRUNTIME_H_
+
+#include <decaf/util/Config.h>
+
+#include <decaf/util/concurrent/Mutex.h>
+
+namespace decaf {
+namespace internal {
+namespace security {
+
+    class SecurityRuntimeImpl;
+    class ServiceRegistry;
+
+    /**
+     * Internal class used to manage Security related resources and hide platform
+     * dependent calls from the higher level API.
+     *
+     * @since 1.0
+     */
+    class DECAF_API SecurityRuntime {
+    private:
+
+        SecurityRuntimeImpl* impl;
+
+        static SecurityRuntime* securityRuntime;
+
+    private:
+
+        SecurityRuntime(const SecurityRuntime&);
+        SecurityRuntime& operator=(const SecurityRuntime&);
+
+    protected:
+
+        SecurityRuntime();
+
+    public:
+
+        virtual ~SecurityRuntime();
+
+        /**
+         * Return the Security Framework's Service Registry.
+         *
+         * @returns a pointer to the frameworks Service Registry.
+         */
+        ServiceRegistry* getServiceRegistry();
+
+        /**
+         * Gets a pointer to the Security Runtime's Lock object, this can be used by
+         * Security layer APIs to synchronize around certain actions such as adding
+         * a resource to the Security layer, etc.
+         *
+         * The pointer returned is owned by the Security runtime and should not be
+         * deleted or copied by the caller.
+         *
+         * @returns a pointer to the Security Runtime's single Lock instance.
+         */
+        decaf::util::concurrent::Mutex* getRuntimeLock();
+
+    public:   // Static methods
+
+        /**
+         * Gets the one and only instance of the Security class, if this is called before
+         * the Security layer has been initialized or after it has been shutdown then an
+         * IllegalStateException is thrown.
+         *
+         * @return pointer to the Security runtime for the Decaf library.
+         */
+        static SecurityRuntime* getSecurityRuntime();
+
+        /**
+         * Initialize the Security layer.
+         */
+        static void initializeSecurity();
+
+        /**
+         * Shutdown the Security layer and free any associated resources, classes in the
+         * Decaf library that use the Security layer will now fail if used after calling
+         * the shutdown method.
+         */
+        static void shutdownSecurity();
+
+    };
+
+}}}
+
+#endif /* _DECAF_INTERNAL_SECURITY_H_ */

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/SecurityRuntime.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/ServiceRegistry.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/ServiceRegistry.cpp?rev=1457307&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/ServiceRegistry.cpp (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/ServiceRegistry.cpp Sat Mar 16 21:14:01 2013
@@ -0,0 +1,97 @@
+/*
+ * 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 "ServiceRegistry.h"
+
+#include <decaf/lang/Pointer.h>
+#include <decaf/util/ArrayList.h>
+#include <decaf/util/HashMap.h>
+#include <decaf/security/Provider.h>
+#include <decaf/security/ProviderService.h>
+
+using namespace decaf;
+using namespace decaf::lang;
+using namespace decaf::util;
+using namespace decaf::security;
+using namespace decaf::internal;
+using namespace decaf::internal::security;
+
+////////////////////////////////////////////////////////////////////////////////
+namespace decaf {
+namespace internal {
+namespace security {
+
+    class ServiceRegistryImpl {
+    private:
+
+        ServiceRegistryImpl(const ServiceRegistryImpl&);
+        ServiceRegistryImpl& operator= (const ServiceRegistryImpl&);
+
+    public:
+
+        ArrayList<const Provider*> providers;
+        HashMap<std::string, ProviderService*> services;
+
+    public:
+
+        ServiceRegistryImpl() : providers(), services() {
+        }
+    };
+
+}}}
+
+////////////////////////////////////////////////////////////////////////////////
+ServiceRegistry::ServiceRegistry() : impl(new ServiceRegistryImpl) {
+
+}
+
+////////////////////////////////////////////////////////////////////////////////
+ServiceRegistry::~ServiceRegistry() {
+    delete this->impl;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void ServiceRegistry::addProvider(const Provider* provider) {
+
+    if (provider == NULL) {
+        return;
+    }
+
+    this->impl->providers.add(provider);
+
+    Pointer< Iterator<ProviderService*> > iter(provider->getServices().iterator());
+    while (iter->hasNext()) {
+        ProviderService* service = iter->next();
+
+        std::string type = service->getType();
+        std::string algorithm = service->getAlgorithm();
+        std::string name = type + "." + algorithm;
+
+        if (!this->impl->services.containsKey(name)) {
+            this->impl->services.put(name, service);
+        }
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+ProviderService* ServiceRegistry::getService(const std::string& name) {
+    if (this->impl->services.containsKey(name)) {
+        return this->impl->services.get(name);
+    }
+
+    return NULL;
+}

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

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/ServiceRegistry.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/ServiceRegistry.h?rev=1457307&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/ServiceRegistry.h (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/ServiceRegistry.h Sat Mar 16 21:14:01 2013
@@ -0,0 +1,80 @@
+/*
+ * 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_INTERNAL_SECURITY_SERVICEREGISTRY_H_
+#define _DECAF_INTERNAL_SECURITY_SERVICEREGISTRY_H_
+
+#include <decaf/util/Config.h>
+
+#include <string>
+
+namespace decaf {
+namespace security {
+    class Provider;
+    class ProviderService;
+}
+namespace internal {
+namespace security {
+
+    class ServiceRegistryImpl;
+
+    /**
+     * Serves as a registry for all the Providers for services using the naming
+     * format of "ServiceName.Algorithm".
+     */
+    class DECAF_API ServiceRegistry {
+    private:
+
+        ServiceRegistryImpl* impl;
+
+    private:
+
+        ServiceRegistry(const ServiceRegistry&);
+        ServiceRegistry& operator=(const ServiceRegistry&);
+
+    public:
+
+        ServiceRegistry();
+
+        virtual ~ServiceRegistry();
+
+        /**
+         * Adds the Provider into the registry so that its services can be looked up
+         * by the registry clients.
+         *
+         * @param provider
+         *      The instance of the Provider which is to be added to the registry
+         */
+        void addProvider(const decaf::security::Provider* provider);
+
+        /**
+         * Attempts to locate a ProviderService implementation for the named service and
+         * return a new instance of the service.  If no service exists for the given name
+         * this method returns NULL.
+         *
+         * @param name
+         *      The name of the service to find, format is "serviceName.algorithmName"
+         *
+         * @returns a caller owned pointer to a new ProviderService for the named service.
+         */
+        decaf::security::ProviderService* getService(const std::string& name);
+
+    };
+
+}}}
+
+#endif /* _DECAF_INTERNAL_SECURITY_SERVICEREGISTRY_H_ */

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/ServiceRegistry.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/DefaultMessageDigestProviderService.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/DefaultMessageDigestProviderService.cpp?rev=1457307&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/DefaultMessageDigestProviderService.cpp (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/DefaultMessageDigestProviderService.cpp Sat Mar 16 21:14:01 2013
@@ -0,0 +1,53 @@
+/*
+ * 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 "DefaultMessageDigestProviderService.h"
+
+#include <decaf/internal/security/provider/crypto/MD4MessageDigestSpi.h>
+#include <decaf/internal/security/provider/crypto/MD5MessageDigestSpi.h>
+#include <decaf/internal/security/provider/crypto/SHA1MessageDigestSpi.h>
+
+using namespace decaf;
+using namespace decaf::security;
+using namespace decaf::internal;
+using namespace decaf::internal::security;
+using namespace decaf::internal::security::provider;
+using namespace decaf::internal::security::provider::crypto;
+
+////////////////////////////////////////////////////////////////////////////////
+DefaultMessageDigestProviderService::DefaultMessageDigestProviderService(
+    const Provider* provider, const std::string& algorithmName) :
+        ProviderService(provider, "MessageDigest", algorithmName) {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+DefaultMessageDigestProviderService::~DefaultMessageDigestProviderService() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+SecuritySpi* DefaultMessageDigestProviderService::newInstance() {
+
+    if (getAlgorithm() == "MD4") {
+        return new MD4MessageDigestSpi();
+    } else if (getAlgorithm() == "MD5") {
+        return new MD5MessageDigestSpi();
+    } else {
+        return new SHA1MessageDigestSpi();
+    }
+
+    return NULL;
+}

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/DefaultMessageDigestProviderService.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/DefaultMessageDigestProviderService.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/DefaultMessageDigestProviderService.h?rev=1457307&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/DefaultMessageDigestProviderService.h (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/DefaultMessageDigestProviderService.h Sat Mar 16 21:14:01 2013
@@ -0,0 +1,55 @@
+/*
+ * 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_INTERNAL_SECURITY_PROVIDER_DEFAULTMESSAGEDIGESTPROVIDERSERVICE_H_
+#define _DECAF_INTERNAL_SECURITY_PROVIDER_DEFAULTMESSAGEDIGESTPROVIDERSERVICE_H_
+
+#include <decaf/util/Config.h>
+#include <decaf/security/ProviderService.h>
+#include <string>
+
+namespace decaf {
+namespace internal {
+namespace security {
+namespace provider {
+
+    /**
+     * Decaf's Default Message Digest Security provider used to create instances of the
+     * built-in Message Digest algorithm SPI classes.
+     *
+     * @since 1.0
+     */
+    class DECAF_API DefaultMessageDigestProviderService : public decaf::security::ProviderService {
+    private:
+
+        DefaultMessageDigestProviderService(const DefaultMessageDigestProviderService&);
+        DefaultMessageDigestProviderService& operator= (const DefaultMessageDigestProviderService&);
+
+    public:
+
+        DefaultMessageDigestProviderService(const decaf::security::Provider* provider,
+                                            const std::string& algorithmName);
+
+        virtual ~DefaultMessageDigestProviderService();
+
+        virtual decaf::security::SecuritySpi* newInstance();
+
+    };
+
+}}}}
+
+#endif /* _DECAF_INTERNAL_SECURITY_PROVIDER_DEFAULTMESSAGEDIGESTPROVIDERSERVICE_H_ */

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/DefaultMessageDigestProviderService.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/DefaultProvider.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/DefaultProvider.cpp?rev=1457307&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/DefaultProvider.cpp (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/DefaultProvider.cpp Sat Mar 16 21:14:01 2013
@@ -0,0 +1,49 @@
+/*
+ * 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 "DefaultProvider.h"
+
+#include <decaf/lang/Exception.h>
+
+#include <decaf/internal/security/provider/DefaultMessageDigestProviderService.h>
+#include <decaf/internal/security/provider/DefaultSecureRandomProviderService.h>
+
+using namespace decaf;
+using namespace decaf::lang;
+using namespace decaf::security;
+using namespace decaf::internal;
+using namespace decaf::internal::security;
+using namespace decaf::internal::security::provider;
+
+////////////////////////////////////////////////////////////////////////////////
+DefaultProvider::DefaultProvider() : Provider("Decaf", 1.0, "Default Decaf Security Provider") {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+DefaultProvider::~DefaultProvider() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void DefaultProvider::initialize() {
+    try {
+        this->addService(new DefaultMessageDigestProviderService(this, "MD4"));
+        this->addService(new DefaultMessageDigestProviderService(this, "MD5"));
+        this->addService(new DefaultMessageDigestProviderService(this, "SHA1"));
+        this->addService(new DefaultSecureRandomProviderService(this, "Default"));
+    }
+    DECAF_CATCHALL_THROW(Exception)
+}

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/DefaultProvider.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/DefaultProvider.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/DefaultProvider.h?rev=1457307&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/DefaultProvider.h (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/DefaultProvider.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_INTERNAL_SECURITY_PROVIDER_DEFAULTPROVIDER_H_
+#define _DECAF_INTERNAL_SECURITY_PROVIDER_DEFAULTPROVIDER_H_
+
+#include <decaf/util/Config.h>
+
+#include <decaf/security/Provider.h>
+
+namespace decaf {
+namespace internal {
+namespace security {
+    class SecurityRuntime;
+namespace provider {
+
+    /**
+     * Implements the Security Provider interface for the Decaf library.
+     *
+     * @since 1.0
+     */
+    class DECAF_API DefaultProvider : public decaf::security::Provider {
+    private:
+
+        friend class decaf::internal::security::SecurityRuntime;
+
+    protected:
+
+        DefaultProvider();
+
+    public:
+
+        virtual ~DefaultProvider();
+
+    protected:
+
+        virtual void initialize();
+
+    };
+
+}}}}
+
+#endif /* _DECAF_INTERNAL_SECURITY_PROVIDER_DEFAULTPROVIDER_H_ */

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/DefaultProvider.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/DefaultSecureRandomProviderService.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/DefaultSecureRandomProviderService.cpp?rev=1457307&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/DefaultSecureRandomProviderService.cpp (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/DefaultSecureRandomProviderService.cpp Sat Mar 16 21:14:01 2013
@@ -0,0 +1,45 @@
+/*
+ * 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 "DefaultSecureRandomProviderService.h"
+
+#ifdef HAVE_PTHREAD_H
+#include <decaf/internal/security/unix/SecureRandomImpl.h>
+#else
+#include <decaf/internal/security/windows/SecureRandomImpl.h>
+#endif
+
+using namespace decaf;
+using namespace decaf::security;
+using namespace decaf::internal;
+using namespace decaf::internal::security;
+using namespace decaf::internal::security::provider;
+
+////////////////////////////////////////////////////////////////////////////////
+DefaultSecureRandomProviderService::DefaultSecureRandomProviderService(
+    const Provider* provider, const std::string& algorithmName) :
+        ProviderService(provider, "SecureRandom", algorithmName) {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+DefaultSecureRandomProviderService::~DefaultSecureRandomProviderService() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+SecuritySpi* DefaultSecureRandomProviderService::newInstance() {
+    return new SecureRandomImpl();
+}

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/DefaultSecureRandomProviderService.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/DefaultSecureRandomProviderService.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/DefaultSecureRandomProviderService.h?rev=1457307&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/DefaultSecureRandomProviderService.h (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/DefaultSecureRandomProviderService.h Sat Mar 16 21:14:01 2013
@@ -0,0 +1,55 @@
+/*
+ * 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_INTERNAL_SECURITY_PROVIDER_DEFAULTSECURERANDOMPROVIDERSERVICE_H_
+#define _DECAF_INTERNAL_SECURITY_PROVIDER_DEFAULTSECURERANDOMPROVIDERSERVICE_H_
+
+#include <decaf/util/Config.h>
+#include <decaf/security/ProviderService.h>
+#include <string>
+
+namespace decaf {
+namespace internal {
+namespace security {
+namespace provider {
+
+    /**
+     * Decaf's Default Secure Random Security provider used to create instances of the
+     * built-in Secure Random algorithm SPI classes.
+     *
+     * @since 1.0
+     */
+    class DECAF_API DefaultSecureRandomProviderService : public decaf::security::ProviderService {
+    private:
+
+        DefaultSecureRandomProviderService(const DefaultSecureRandomProviderService&);
+        DefaultSecureRandomProviderService& operator= (const DefaultSecureRandomProviderService&);
+
+    public:
+
+        DefaultSecureRandomProviderService(const decaf::security::Provider* provider,
+                                            const std::string& algorithmName);
+
+        virtual ~DefaultSecureRandomProviderService();
+
+        virtual decaf::security::SecuritySpi* newInstance();
+
+    };
+
+}}}}
+
+#endif /* _DECAF_INTERNAL_SECURITY_PROVIDER_DEFAULTSECURERANDOMPROVIDERSERVICE_H_ */

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/DefaultSecureRandomProviderService.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/crypto/MD4MessageDigestSpi.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/crypto/MD4MessageDigestSpi.cpp?rev=1457307&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/crypto/MD4MessageDigestSpi.cpp (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/crypto/MD4MessageDigestSpi.cpp Sat Mar 16 21:14:01 2013
@@ -0,0 +1,451 @@
+/*
+ * This is work is derived from material Copyright RSA Data Security, Inc.
+ *
+ * The RSA copyright statement and Licence for that original material is
+ * included below. This is followed by the Apache copyright statement and
+ * licence for the modifications made to that material.
+ *
+ * Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
+ * rights reserved.
+ *
+ * License to copy and use this software is granted provided that it
+ * is identified as the "RSA Data Security, Inc. MD4 Message-Digest
+ * Algorithm" in all material mentioning or referencing this software
+ * or this function.
+ *
+ * License is also granted to make and use derivative works provided
+ * that such works are identified as "derived from the RSA Data
+ * Security, Inc. MD4 Message-Digest Algorithm" in all material
+ * mentioning or referencing the derived work.
+ *
+ * RSA Data Security, Inc. makes no representations concerning either
+ * the merchantability of this software or the suitability of this
+ * software for any particular purpose. It is provided "as is"
+ * without express or implied warranty of any kind.
+ *
+ * These notices must be retained in any copies of any part of this
+ * documentation and/or software.
+ */
+
+/* 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 "MD4MessageDigestSpi.h"
+
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
+#include <decaf/lang/System.h>
+#include <decaf/security/DigestException.h>
+
+using namespace decaf;
+using namespace decaf::lang;
+using namespace decaf::security;
+using namespace decaf::internal;
+using namespace decaf::internal::security;
+using namespace decaf::internal::security::provider;
+using namespace decaf::internal::security::provider::crypto;
+
+////////////////////////////////////////////////////////////////////////////////
+namespace {
+
+#define DECAF_MD4_DIGESTSIZE 16
+
+#define S11 3
+#define S12 7
+#define S13 11
+#define S14 19
+#define S21 3
+#define S22 5
+#define S23 9
+#define S24 13
+#define S31 3
+#define S32 9
+#define S33 11
+#define S34 15
+
+static const unsigned char PADDING[64] = {
+    0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+// F, G and I are basic MD4 functions.
+#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
+#define G(x, y, z) (((x) & (y)) | ((x) & (z)) | ((y) & (z)))
+#define H(x, y, z) ((x) ^ (y) ^ (z))
+
+// ROTATE_LEFT rotates x left n bits.
+#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
+
+// FF, GG and HH are transformations for rounds 1, 2 and 3 */
+// Rotation is separate from addition to prevent recomputation */
+#define FF(a, b, c, d, x, s) { \
+    (a) += F ((b), (c), (d)) + (x); \
+    (a) = ROTATE_LEFT ((a), (s)); \
+}
+#define GG(a, b, c, d, x, s) { \
+    (a) += G ((b), (c), (d)) + (x) + (apr_uint32_t)0x5a827999; \
+    (a) = ROTATE_LEFT ((a), (s)); \
+}
+#define HH(a, b, c, d, x, s) { \
+    (a) += H ((b), (c), (d)) + (x) + (apr_uint32_t)0x6ed9eba1; \
+    (a) = ROTATE_LEFT ((a), (s)); \
+}
+
+}
+
+////////////////////////////////////////////////////////////////////////////////
+namespace decaf {
+namespace internal {
+namespace security {
+namespace provider {
+namespace crypto {
+
+    class MD4MessageDigestSpiImpl {
+    public:
+
+        // state (ABCD)
+        apr_uint32_t state[4];
+        // number of bits, modulo 2^64 (lsb first)
+        unsigned int count[2];
+        // Digest Input buffer
+        unsigned char buffer[64];
+
+    public:
+
+        MD4MessageDigestSpiImpl() : state(), count(), buffer() {
+            reset();
+        }
+
+        void reset() {
+            count[0] = count[1] = 0;
+
+            // Load magic initialization constants.
+            state[0] = 0x67452301;
+            state[1] = 0xefcdab89;
+            state[2] = 0x98badcfe;
+            state[3] = 0x10325476;
+
+            memset(buffer, 0, 64);
+        }
+
+        // MD4 block update operation. Continues an MD4 message-digest
+        // operation, processing another message block, and updating the
+        // context.
+        void update(const unsigned char* vinput, int inputLen) {
+            const unsigned char *input = vinput;
+            int i;
+            int idx;
+            int partLen;
+
+            // Compute number of bytes mod 64
+            idx = (unsigned int)((count[0] >> 3) & 0x3F);
+
+            // Update number of bits
+            if ((count[0] += ((unsigned int)inputLen << 3)) < ((unsigned int)inputLen << 3)) {
+                count[1]++;
+            }
+
+            count[1] += (unsigned int)inputLen >> 29;
+
+            partLen = 64 - idx;
+
+            // Transform as many times as possible.
+            if (inputLen >= partLen) {
+                memcpy(&buffer[idx], input, partLen);
+                MD4Transform(state, buffer);
+
+                for (i = partLen; i + 63 < inputLen; i += 64) {
+                    MD4Transform(state, &input[i]);
+                }
+
+                idx = 0;
+            } else {
+                i = 0;
+            }
+
+            // Buffer remaining input
+            memcpy(&buffer[idx], &input[i], inputLen - i);
+        }
+
+        // MD4 finalization. Ends an MD4 message-digest operation, writing the
+        // the message digest and then reset.
+        void finalize(unsigned char digest[DECAF_MD4_DIGESTSIZE]) {
+            unsigned char bits[8];
+            unsigned int idx;
+            unsigned int padLen;
+
+            // Save number of bits
+            encode(bits, count, 8);
+
+            // Pad out to 56 mod 64.
+            idx = (unsigned int)((count[0] >> 3) & 0x3f);
+            padLen = (idx < 56) ? (56 - idx) : (120 - idx);
+            update(PADDING, padLen);
+
+            // Append length (before padding)
+            update(bits, 8);
+
+            // Store state in digest
+            encode(digest, state, DECAF_MD4_DIGESTSIZE);
+
+            reset();
+        }
+
+    private:
+
+        // MD4 basic transformation. Transforms state based on block.
+        static void MD4Transform(unsigned int state[4], const unsigned char block[64]) {
+            unsigned int a = state[0];
+            unsigned int b = state[1];
+            unsigned int c = state[2];
+            unsigned int d = state[3];
+            unsigned int x[DECAF_MD4_DIGESTSIZE];
+
+            decode(x, block, 64);
+
+            /* Round 1 */
+            FF (a, b, c, d, x[ 0], S11); /* 1 */
+            FF (d, a, b, c, x[ 1], S12); /* 2 */
+            FF (c, d, a, b, x[ 2], S13); /* 3 */
+            FF (b, c, d, a, x[ 3], S14); /* 4 */
+            FF (a, b, c, d, x[ 4], S11); /* 5 */
+            FF (d, a, b, c, x[ 5], S12); /* 6 */
+            FF (c, d, a, b, x[ 6], S13); /* 7 */
+            FF (b, c, d, a, x[ 7], S14); /* 8 */
+            FF (a, b, c, d, x[ 8], S11); /* 9 */
+            FF (d, a, b, c, x[ 9], S12); /* 10 */
+            FF (c, d, a, b, x[10], S13); /* 11 */
+            FF (b, c, d, a, x[11], S14); /* 12 */
+            FF (a, b, c, d, x[12], S11); /* 13 */
+            FF (d, a, b, c, x[13], S12); /* 14 */
+            FF (c, d, a, b, x[14], S13); /* 15 */
+            FF (b, c, d, a, x[15], S14); /* 16 */
+
+            /* Round 2 */
+            GG (a, b, c, d, x[ 0], S21); /* 17 */
+            GG (d, a, b, c, x[ 4], S22); /* 18 */
+            GG (c, d, a, b, x[ 8], S23); /* 19 */
+            GG (b, c, d, a, x[12], S24); /* 20 */
+            GG (a, b, c, d, x[ 1], S21); /* 21 */
+            GG (d, a, b, c, x[ 5], S22); /* 22 */
+            GG (c, d, a, b, x[ 9], S23); /* 23 */
+            GG (b, c, d, a, x[13], S24); /* 24 */
+            GG (a, b, c, d, x[ 2], S21); /* 25 */
+            GG (d, a, b, c, x[ 6], S22); /* 26 */
+            GG (c, d, a, b, x[10], S23); /* 27 */
+            GG (b, c, d, a, x[14], S24); /* 28 */
+            GG (a, b, c, d, x[ 3], S21); /* 29 */
+            GG (d, a, b, c, x[ 7], S22); /* 30 */
+            GG (c, d, a, b, x[11], S23); /* 31 */
+            GG (b, c, d, a, x[15], S24); /* 32 */
+
+            /* Round 3 */
+            HH (a, b, c, d, x[ 0], S31); /* 33 */
+            HH (d, a, b, c, x[ 8], S32); /* 34 */
+            HH (c, d, a, b, x[ 4], S33); /* 35 */
+            HH (b, c, d, a, x[12], S34); /* 36 */
+            HH (a, b, c, d, x[ 2], S31); /* 37 */
+            HH (d, a, b, c, x[10], S32); /* 38 */
+            HH (c, d, a, b, x[ 6], S33); /* 39 */
+            HH (b, c, d, a, x[14], S34); /* 40 */
+            HH (a, b, c, d, x[ 1], S31); /* 41 */
+            HH (d, a, b, c, x[ 9], S32); /* 42 */
+            HH (c, d, a, b, x[ 5], S33); /* 43 */
+            HH (b, c, d, a, x[13], S34); /* 44 */
+            HH (a, b, c, d, x[ 3], S31); /* 45 */
+            HH (d, a, b, c, x[11], S32); /* 46 */
+            HH (c, d, a, b, x[ 7], S33); /* 47 */
+            HH (b, c, d, a, x[15], S34); /* 48 */
+
+            state[0] += a;
+            state[1] += b;
+            state[2] += c;
+            state[3] += d;
+
+            // clear any sensitive information.
+            memset(x, 0, sizeof(x));
+        }
+
+        static void decode(unsigned int* output, const unsigned char* input, unsigned int length) {
+            unsigned int i, j;
+
+            for (i = 0, j = 0; j < length; i++, j += 4)
+                output[i] = ((unsigned int)input[j])             |
+                            (((unsigned int)input[j + 1]) << 8)  |
+                            (((unsigned int)input[j + 2]) << 16) |
+                            (((unsigned int)input[j + 3]) << 24);
+        }
+
+        static void encode(unsigned char* output, const unsigned int* input, unsigned int length) {
+            unsigned int i, j;
+            unsigned int k;
+
+            for (i = 0, j = 0; j < length; i++, j += 4) {
+                k = input[i];
+                output[j]     = (unsigned char)(k & 0xff);
+                output[j + 1] = (unsigned char)((k >> 8) & 0xff);
+                output[j + 2] = (unsigned char)((k >> 16) & 0xff);
+                output[j + 3] = (unsigned char)((k >> 24) & 0xff);
+            }
+        }
+    };
+
+}}}}}
+
+////////////////////////////////////////////////////////////////////////////////
+MD4MessageDigestSpi::MD4MessageDigestSpi() : MessageDigestSpi(), impl(new MD4MessageDigestSpiImpl) {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+MD4MessageDigestSpi::~MD4MessageDigestSpi() {
+    delete this->impl;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+MessageDigestSpi* MD4MessageDigestSpi::clone() {
+    MD4MessageDigestSpi* clone = new MD4MessageDigestSpi;
+
+    System::arraycopy(clone->impl->state, 0, this->impl->state, 0, 4);
+    System::arraycopy(clone->impl->count, 0, this->impl->count, 0, 2);
+    System::arraycopy(clone->impl->buffer, 0, this->impl->buffer, 0, 64);
+
+    return clone;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int MD4MessageDigestSpi::engineGetDigestLength() {
+    return DECAF_MD4_DIGESTSIZE;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void MD4MessageDigestSpi::engineUpdate(unsigned char input) {
+    this->impl->update(&input, 1);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void MD4MessageDigestSpi::engineUpdate(const unsigned char* input, int size, int offset, int length) {
+
+    if (input == NULL && size > 0) {
+        throw DigestException(__FILE__, __LINE__, "Null buffer parameter.");
+    }
+
+    if (size <= 0) {
+        return;
+    }
+
+    if (offset < 0 || length < 0) {
+        engineReset();
+        throw DigestException(__FILE__, __LINE__, "Incorrect offset or length value.");
+    }
+
+    if (offset + length > size) {
+        engineReset();
+        throw DigestException(__FILE__, __LINE__, "Incorrect offset or length value.");
+    }
+
+    this->impl->update(&input[offset], length);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void MD4MessageDigestSpi::engineUpdate(const std::vector<unsigned char>& input) {
+
+    if (input.empty()) {
+        return;
+    }
+
+    this->impl->update(&input[0], (int)input.size());
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void MD4MessageDigestSpi::engineUpdate(decaf::nio::ByteBuffer& input) {
+
+    if (!input.hasRemaining()) {
+        return;
+    }
+    unsigned char* temp;
+    if (input.hasArray()) {
+        temp = input.array();
+        int offset = input.arrayOffset();
+        int position = input.position();
+        int limit = input.limit();
+        engineUpdate(temp, limit - position, offset + position, limit - position);
+        input.position(limit);
+    } else {
+        int length = input.limit() - input.position();
+        temp = new unsigned char[length];
+        input.get(temp, length, 0, length);
+        engineUpdate(temp, length, 0, length);
+        delete temp;
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void MD4MessageDigestSpi::engineReset() {
+    this->impl->reset();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::vector<unsigned char> MD4MessageDigestSpi::engineDigest() {
+
+    std::vector<unsigned char> buffer;
+    buffer.resize(DECAF_MD4_DIGESTSIZE);
+    this->impl->finalize(&buffer[0]);
+
+    return buffer;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int MD4MessageDigestSpi::engineDigest(unsigned char* buffer, int size, int offset, int length) {
+
+    if (buffer == NULL) {
+        engineReset();
+        throw DigestException(__FILE__, __LINE__, "Null buffer parameter.");
+    }
+
+    if (size < engineGetDigestLength()) {
+        engineReset();
+        throw DigestException(__FILE__, __LINE__,
+            "The value of size parameter is less than the actual digest length.");
+    }
+
+    if (length < engineGetDigestLength()) {
+        engineReset();
+        throw DigestException(__FILE__, __LINE__,
+            "The value of length parameter is less than the actual digest length.");
+    }
+
+    if (offset < 0) {
+        engineReset();
+        throw DigestException(__FILE__, __LINE__, "Invalid negative offset.");
+    }
+
+    if (offset + length > size) {
+        engineReset();
+        throw DigestException(__FILE__, __LINE__, "Incorrect offset or length value.");
+    }
+
+    std::vector<unsigned char> temp = engineDigest();
+    if (length < (int)temp.size()) {
+        throw DigestException(__FILE__, __LINE__,
+            "The value of length parameter is less than the actual digest length..");
+    }
+
+    System::arraycopy(&temp[0], 0, buffer, offset, temp.size());
+    return (int)temp.size();
+}

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/crypto/MD4MessageDigestSpi.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/crypto/MD4MessageDigestSpi.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/crypto/MD4MessageDigestSpi.h?rev=1457307&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/crypto/MD4MessageDigestSpi.h (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/crypto/MD4MessageDigestSpi.h Sat Mar 16 21:14:01 2013
@@ -0,0 +1,80 @@
+/*
+ * 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_INTERNAL_SECURITY_PROVIDER_CRYPTO_MD4MESSAGEDIGESTSPI_H_
+#define _DECAF_INTERNAL_SECURITY_PROVIDER_CRYPTO_MD4MESSAGEDIGESTSPI_H_
+
+#include <decaf/util/Config.h>
+
+#include <decaf/security/MessageDigestSpi.h>
+
+namespace decaf {
+namespace internal {
+namespace security {
+namespace provider {
+namespace crypto {
+
+    class MD4MessageDigestSpiImpl;
+
+    /**
+     * MD4 MessageDigestSpi
+     *
+     * @since 1.0
+     */
+    class DECAF_API MD4MessageDigestSpi : public decaf::security::MessageDigestSpi {
+    private:
+
+        MD4MessageDigestSpi(const MD4MessageDigestSpi&);
+        MD4MessageDigestSpi& operator= (const MD4MessageDigestSpi&);
+
+        MD4MessageDigestSpiImpl* impl;
+
+    public:
+
+        MD4MessageDigestSpi();
+
+        virtual ~MD4MessageDigestSpi();
+
+    public:
+
+        virtual bool isCloneable() const {
+            return true;
+        }
+
+        virtual MessageDigestSpi* clone();
+
+        virtual int engineGetDigestLength();
+
+        virtual void engineUpdate(unsigned char input);
+
+        virtual void engineUpdate(const unsigned char* input, int size, int offset, int length);
+
+        virtual void engineReset();
+
+        virtual void engineUpdate(const std::vector<unsigned char>& input);
+
+        virtual void engineUpdate(decaf::nio::ByteBuffer& input);
+
+        virtual std::vector<unsigned char> engineDigest();
+
+        virtual int engineDigest(unsigned char* buffer, int size, int offset, int length);
+
+    };
+
+}}}}}
+
+#endif /* _DECAF_INTERNAL_SECURITY_PROVIDER_CRYPTO_MD4MESSAGEDIGESTSPI_H_ */

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/crypto/MD4MessageDigestSpi.h
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message