You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2008/04/29 22:52:37 UTC

svn commit: r652104 [17/29] - in /activemq/activemq-cpp/trunk: ./ m4/ src/examples/ src/examples/consumers/ src/main/ src/main/decaf/ src/main/decaf/internal/ src/main/decaf/internal/net/ src/main/decaf/internal/nio/ src/main/decaf/internal/util/ src/m...

Added: activemq/activemq-cpp/trunk/src/main/decaf/nio/ShortBuffer.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/decaf/nio/ShortBuffer.cpp?rev=652104&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/decaf/nio/ShortBuffer.cpp (added)
+++ activemq/activemq-cpp/trunk/src/main/decaf/nio/ShortBuffer.cpp Tue Apr 29 13:52:30 2008
@@ -0,0 +1,303 @@
+/*
+ * 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 "ShortBuffer.h"
+
+#include <decaf/lang/Float.h>
+#include <decaf/lang/Math.h>
+#include "decaf/internal/nio/BufferFactory.h"
+
+using namespace std;
+using namespace decaf;
+using namespace decaf::nio;
+using namespace decaf::lang;
+using namespace decaf::lang::exceptions;
+using namespace decaf::internal::nio;
+
+////////////////////////////////////////////////////////////////////////////////
+ShortBuffer::ShortBuffer( std::size_t capacity )
+ :  Buffer( capacity ) {
+
+}
+
+////////////////////////////////////////////////////////////////////////////////
+ShortBuffer* ShortBuffer::allocate( std::size_t capacity ) {
+
+    try{
+
+        return BufferFactory::createShortBuffer( capacity );
+    }
+    DECAF_CATCH_RETHROW( Exception )
+    DECAF_CATCHALL_THROW( Exception )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+ShortBuffer* ShortBuffer::wrap( short* buffer, std::size_t offset, std::size_t length )
+    throw( lang::exceptions::NullPointerException ) {
+
+    try{
+
+        if( buffer == NULL ) {
+            throw NullPointerException(
+                __FILE__, __LINE__,
+                "ShortBuffer::wrap - Passed Buffer is Null.");
+        }
+
+        return BufferFactory::createShortBuffer( buffer, offset, length );
+    }
+    DECAF_CATCH_RETHROW( NullPointerException )
+    DECAF_CATCH_EXCEPTION_CONVERT( Exception, NullPointerException )
+    DECAF_CATCHALL_THROW( NullPointerException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+ShortBuffer* ShortBuffer::wrap( std::vector<short>& buffer ) {
+
+    try{
+
+        if( buffer.empty() ) {
+            throw NullPointerException(
+                __FILE__, __LINE__,
+                "ShortBuffer::wrap - Passed Buffer is Empty.");
+        }
+
+        return BufferFactory::createShortBuffer( &buffer[0], 0, buffer.size() );
+    }
+    DECAF_CATCH_RETHROW( NullPointerException )
+    DECAF_CATCH_EXCEPTION_CONVERT( Exception, NullPointerException )
+    DECAF_CATCHALL_THROW( NullPointerException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::string ShortBuffer::toString() const {
+
+    std::ostringstream stream;
+
+    stream << "ShortBuffer, status: "
+           << "capacity =" << this->capacity()
+           << " position =" << this->position()
+           << " limit = " << this->limit();
+
+    return stream.str();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+ShortBuffer& ShortBuffer::get( std::vector<short> buffer )
+    throw ( BufferUnderflowException ) {
+
+    try{
+
+        if( !buffer.empty() ) {
+            this->get( &buffer[0], 0, buffer.size() );
+        }
+        return *this;
+    }
+    DECAF_CATCH_RETHROW( BufferUnderflowException )
+    DECAF_CATCH_EXCEPTION_CONVERT( Exception, BufferUnderflowException )
+    DECAF_CATCHALL_THROW( BufferUnderflowException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+ShortBuffer& ShortBuffer::get( short* buffer, std::size_t offset, std::size_t length )
+    throw( BufferUnderflowException,
+           lang::exceptions::NullPointerException ) {
+
+    try{
+
+        if( length == 0 ) {
+            return *this;
+        }
+
+        if( buffer == NULL ) {
+            throw NullPointerException(
+                __FILE__, __LINE__,
+                "ShortBuffer::get - Passed Buffer is Null" );
+        }
+
+        if( length > remaining() ) {
+            throw BufferUnderflowException(
+                __FILE__, __LINE__,
+                "ShortBuffer::get - Not enough data to fill length = %d", length );
+        }
+
+        for( std::size_t ix = 0; ix < length; ++ix ){
+            buffer[offset + ix] = this->get();
+        }
+
+        return *this;
+    }
+    DECAF_CATCH_RETHROW( BufferUnderflowException )
+    DECAF_CATCH_EXCEPTION_CONVERT( Exception, BufferUnderflowException )
+    DECAF_CATCHALL_THROW( BufferUnderflowException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+ShortBuffer& ShortBuffer::put( ShortBuffer& src )
+    throw( BufferOverflowException, ReadOnlyBufferException,
+           lang::exceptions::IllegalArgumentException ) {
+
+    try{
+
+        if( this == &src ) {
+            throw IllegalArgumentException(
+                __FILE__, __LINE__,
+                "ShortBuffer::put - Can't put Self" );
+        }
+
+        if( this->isReadOnly() ) {
+            throw ReadOnlyBufferException(
+                __FILE__, __LINE__,
+                "ShortBuffer::put - This buffer is Read Only.");
+        }
+
+        if( src.remaining() > this->remaining() ) {
+            throw BufferOverflowException(
+                __FILE__, __LINE__,
+                "ShortBuffer::put - Not enough space remaining to put src." );
+        }
+
+        while( src.hasRemaining() ) {
+            this->put( src.get() );
+        }
+
+        return *this;
+    }
+    DECAF_CATCH_RETHROW( BufferOverflowException )
+    DECAF_CATCH_RETHROW( ReadOnlyBufferException )
+    DECAF_CATCH_RETHROW( IllegalArgumentException )
+    DECAF_CATCH_EXCEPTION_CONVERT( Exception, BufferOverflowException )
+    DECAF_CATCHALL_THROW( BufferOverflowException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+ShortBuffer& ShortBuffer::put( const short* buffer, std::size_t offset, std::size_t length )
+    throw( BufferOverflowException, ReadOnlyBufferException,
+           lang::exceptions::NullPointerException ) {
+
+    try{
+
+        if( length == 0 ) {
+            return *this;
+        }
+
+        if( this->isReadOnly() ) {
+            throw ReadOnlyBufferException(
+                __FILE__, __LINE__,
+                "ShortBuffer::put - This buffer is Read Only.");
+        }
+
+        if( buffer == NULL ) {
+            throw NullPointerException(
+                __FILE__, __LINE__,
+                "ShortBuffer::put - Passed Buffer is Null.");
+        }
+
+        if( length > this->remaining() ) {
+            throw BufferOverflowException(
+                __FILE__, __LINE__,
+                "ShortBuffer::put - Not Enough space to store requested Data.");
+        }
+
+        // read length bytes starting from the offset
+        for( std::size_t ix = 0; ix < length; ++ix ) {
+            this->put( buffer[ix + offset] );
+        }
+
+        return *this;
+    }
+    DECAF_CATCH_RETHROW( BufferOverflowException )
+    DECAF_CATCH_RETHROW( ReadOnlyBufferException )
+    DECAF_CATCH_RETHROW( NullPointerException )
+    DECAF_CATCH_EXCEPTION_CONVERT( Exception, BufferOverflowException )
+    DECAF_CATCHALL_THROW( BufferOverflowException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+ShortBuffer& ShortBuffer::put( std::vector<short>& buffer )
+    throw( BufferOverflowException, ReadOnlyBufferException ) {
+
+    try{
+
+        if( !buffer.empty() ) {
+            this->put( &buffer[0], 0, buffer.size() );
+        }
+
+        return *this;
+    }
+    DECAF_CATCH_RETHROW( BufferOverflowException )
+    DECAF_CATCH_RETHROW( ReadOnlyBufferException )
+    DECAF_CATCH_EXCEPTION_CONVERT( Exception, BufferOverflowException )
+    DECAF_CATCHALL_THROW( BufferOverflowException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int ShortBuffer::compareTo( const ShortBuffer& value ) const {
+
+    int compareRemaining = Math::min( (int)remaining(), (int)value.remaining() );
+
+    std::size_t thisPos = this->position();
+    std::size_t otherPos = value.position();
+    short thisVal, otherVal;
+
+    while( compareRemaining > 0 ) {
+
+        thisVal = get( thisPos );
+        otherVal = value.get( otherPos );
+
+        if( thisVal != otherVal ) {
+            return thisVal < otherVal ? -1 : 1;
+        }
+
+        thisPos++;
+        otherPos++;
+        compareRemaining--;
+    }
+
+    return remaining() - value.remaining();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool ShortBuffer::equals( const ShortBuffer& value ) const {
+
+    if( &value == this ) {
+        return true;
+    }
+
+    if( this->remaining() != value.remaining() ) {
+        return false;
+    }
+
+    std::size_t myPosition = this->position();
+    std::size_t otherPosition = value.position();
+    bool equalSoFar = true;
+
+    while( equalSoFar && ( myPosition < this->limit() ) ) {
+        equalSoFar = get( myPosition++ ) == value.get( otherPosition++ );
+    }
+
+    return equalSoFar;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool ShortBuffer::operator==( const ShortBuffer& value ) const {
+    return this->equals( value );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool ShortBuffer::operator<( const ShortBuffer& value ) const {
+    return this->compareTo( value ) < 0 ? true : false;
+}

Added: activemq/activemq-cpp/trunk/src/main/decaf/nio/ShortBuffer.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/decaf/nio/ShortBuffer.h?rev=652104&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/decaf/nio/ShortBuffer.h (added)
+++ activemq/activemq-cpp/trunk/src/main/decaf/nio/ShortBuffer.h Tue Apr 29 13:52:30 2008
@@ -0,0 +1,388 @@
+/*
+ * 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_NIO_SHORTBUFFER_H_
+#define _DECAF_NIO_SHORTBUFFER_H_
+
+#include <decaf/nio/Buffer.h>
+#include <decaf/lang/Comparable.h>
+#include <decaf/lang/exceptions/NullPointerException.h>
+#include <decaf/lang/exceptions/IndexOutOfBoundsException.h>
+#include <decaf/nio/BufferUnderflowException.h>
+#include <decaf/nio/BufferOverflowException.h>
+#include <decaf/nio/ReadOnlyBufferException.h>
+
+namespace decaf{
+namespace nio{
+
+    /**
+     * This class defines four categories of operations upon short buffers:
+     *
+     * o Absolute and relative get and put methods that read and write single shorts;
+     * o Relative bulk get methods that transfer contiguous sequences of shorts from
+     *   this buffer into an array; and
+     * o Relative bulk put methods that transfer contiguous sequences of shorts from a
+     *   short array or some other short buffer into this buffer
+     * o Methods for compacting, duplicating, and slicing a short buffer.
+     *
+     * Double buffers can be created either by allocation, which allocates space for the
+     * buffer's content, by wrapping an existing short array into a buffer, or by
+     * creating a view of an existing byte buffer
+     *
+     * Methods in this class that do not otherwise have a value to return are specified
+     * to return the buffer upon which they are invoked. This allows method invocations
+     * to be chained.
+     */
+    class DECAF_API ShortBuffer : public Buffer,
+                                  public lang::Comparable<ShortBuffer> {
+    protected:
+
+        /**
+        * Creates a ShortBuffer object that has its backing array allocated internally
+        * and is then owned and deleted when this object is deleted.  The array is
+        * initially created with all elements initialized to zero.
+        * @param capacity - size and limit of the Buffer in doubles
+        */
+        ShortBuffer( std::size_t capacity );
+
+    public:
+
+        virtual ~ShortBuffer() {}
+
+        /**
+         * @returns a std::string describing this object
+         */
+        virtual std::string toString() const;
+
+        /**
+         * Returns the short array that backs this buffer  (optional operation).
+         * <p>
+         * Modifications to this buffer's content will cause the returned array's content
+         * to be modified, and vice versa.
+         * <p>
+         * Invoke the hasArray method before invoking this method in order to ensure that
+         * this buffer has an accessible backing array.
+         * @returns the array that backs this Buffer
+         * @throws ReadOnlyBufferException if this Buffer is read only.
+         * @throws UnsupportedOperationException if the underlying store has no array.
+         */
+        virtual short* array()
+            throw( decaf::lang::exceptions::UnsupportedOperationException,
+                   ReadOnlyBufferException ) = 0;
+
+        /**
+         * Returns the offset within this buffer's backing array of the first element of
+         * the buffer  (optional operation).
+         * <p>
+         * Invoke the hasArray method before invoking this method in order to ensure that
+         * this buffer has an accessible backing array.
+         * @returns The offset into the backing array where index zero starts.
+         * @throws ReadOnlyBufferException if this Buffer is read only.
+         * @throws UnsupportedOperationException if the underlying store has no array.
+         */
+        virtual std::size_t arrayOffset()
+            throw( decaf::lang::exceptions::UnsupportedOperationException,
+                   ReadOnlyBufferException ) = 0;
+
+        /**
+         * Creates a new, read-only short buffer that shares this buffer's content.
+         * <p>
+         * The content of the new buffer will be that of this buffer. Changes to this
+         * buffer's content will be visible in the new buffer; the new buffer itself,
+         * however, will be read-only and will not allow the shared content to be
+         * modified. The two buffers' position, limit, and mark values will be
+         * independent.
+         * <p>
+         * If this buffer is itself read-only then this method behaves in exactly the
+         * same way as the duplicate method.
+         * <p>
+         * The new buffer's capacity, limit, position, and mark values will be
+         * identical to those of this buffer.
+         * @return The new, read-only short buffer which the caller then owns.
+         */
+        virtual ShortBuffer* asReadOnlyBuffer() const = 0;
+
+        /**
+         * Compacts this buffer
+         * <p>
+         * The bytes between the buffer's current position and its limit, if any, are
+         * copied to the beginning of the buffer. That is, the byte at index
+         * p = position() is copied to index zero, the byte at index p + 1 is copied
+         * to index one, and so forth until the byte at index limit() - 1 is copied
+         * to index n = limit() - 1 - p. The buffer's position is then set to n+1 and
+         * its limit is set to its capacity. The mark, if defined, is discarded.
+         * <p>
+         * The buffer's position is set to the number of bytes copied, rather than to
+         * zero, so that an invocation of this method can be followed immediately by
+         * an invocation of another relative put method.
+         * @returns a reference to this ShortBuffer
+         * @throws ReadOnlyBufferException - If this buffer is read-only
+         */
+        virtual ShortBuffer& compact() throw( ReadOnlyBufferException ) = 0;
+
+        /**
+         * Creates a new short buffer that shares this buffer's content.
+         * <p>
+         * The content of the new buffer will be that of this buffer. Changes to this
+         * buffer's content will be visible in the new buffer, and vice versa; the two
+         * buffers' position, limit, and mark values will be independent.
+         * <p>
+         * The new buffer's capacity, limit, position, and mark values will be identical
+         * to those of this buffer. The new buffer will be read-only if, and only if,
+         * this buffer is read-only.
+         * @returns a new short Buffer which the caller owns.
+         */
+        virtual ShortBuffer* duplicate() = 0;
+
+        /**
+         * Relative get method. Reads the value at this buffer's current position,
+         * and then increments the position.
+         * @returns the short at the current position
+         * @throws BufferUnderflowException if there no more data to return
+         */
+        virtual short get() throw ( BufferUnderflowException ) = 0;
+
+        /**
+         * Absolute get method. Reads the value at the given index.
+         * @param index - the index in the Buffer where the short is to be read
+         * @returns the short that is located at the given index
+         * @throws IndexOutOfBoundsException - If index is not smaller than the
+         * buffer's limit
+         */
+        virtual short get( std::size_t index ) const
+            throw ( lang::exceptions::IndexOutOfBoundsException ) = 0;
+
+        /**
+         * Relative bulk get method.
+         * <p>
+         * This method transfers values from this buffer into the given destination
+         * vector. An invocation of this method of the form src.get(a) behaves in
+         * exactly the same way as the invocation.  The vector must be sized to the
+         * amount of data that is to be read, that is to say, the caller should call
+         * buffer.resize( N ) before calling this get method.
+         * @returns a reference to this Buffer
+         * @throws BufferUnderflowException - If there are fewer than length shorts
+         * remaining in this buffer
+         */
+        ShortBuffer& get( std::vector<short> buffer )
+            throw ( BufferUnderflowException );
+
+        /**
+         * Relative bulk get method.
+         * <p>
+         * This method transfers shorts from this buffer into the given destination array.
+         * If there are fewer shorts remaining in the buffer than are required to satisfy
+         * the request, that is, if length > remaining(), then no bytes are transferred
+         * and a BufferUnderflowException is thrown.
+         * <p>
+         * Otherwise, this method copies length shorts from this buffer into the given
+         * array, starting at the current position of this buffer and at the given offset
+         * in the array. The position of this buffer is then incremented by length.
+         * <p>
+         * @param buffer - pointer to an allocated buffer to fill
+         * @param offset - position in the buffer to start filling
+         * @param length - amount of data to put in the passed buffer
+         * @returns a reference to this Buffer
+         * @throws BufferUnderflowException - If there are fewer than length shorts
+         * remaining in this buffer
+         * @throws NullPointerException if the passed buffer is null.
+         */
+        ShortBuffer& get( short* buffer, std::size_t offset, std::size_t length )
+            throw( BufferUnderflowException,
+                   lang::exceptions::NullPointerException );
+
+        /**
+         * Tells whether or not this buffer is backed by an accessible short array.
+         * If this method returns true then the array and arrayOffset methods may safely
+         * be invoked.  Subclasses should override this method if they do not have a
+         * backing array as this class always returns true.
+         * @returns true if, and only if, this buffer is backed by an array and is not
+         * read-only
+         */
+        virtual bool hasArray() const = 0;
+
+        /**
+         * This method transfers the shorts remaining in the given source buffer into
+         * this buffer. If there are more shorts remaining in the source buffer than in
+         * this buffer, that is, if src.remaining() > remaining(), then no shorts are
+         * transferred and a BufferOverflowException is thrown.
+         * <p>
+         * Otherwise, this method copies n = src.remaining() shorts from the given
+         * buffer into this buffer, starting at each buffer's current position. The
+         * positions of both buffers are then incremented by n.
+         * @param src - the buffer to take shorts from an place in this one.
+         * @returns a reference to this buffer
+         * @throws BufferOverflowException - If there is insufficient space in this
+         * buffer for the remaining shorts in the source buffer
+         * @throws IllegalArgumentException - If the source buffer is this buffer
+         * @throws ReadOnlyBufferException - If this buffer is read-only
+         */
+        ShortBuffer& put( ShortBuffer& src )
+            throw( BufferOverflowException, ReadOnlyBufferException,
+                   lang::exceptions::IllegalArgumentException );
+
+        /**
+         * This method transfers shorts into this buffer from the given source array.
+         * If there are more shorts to be copied from the array than remain in this buffer,
+         * that is, if length > remaining(), then no shorts are transferred and a
+         * BufferOverflowException is thrown.
+         * <p>
+         * Otherwise, this method copies length bytes from the given array into this
+         * buffer, starting at the given offset in the array and at the current position
+         * of this buffer. The position of this buffer is then incremented by length.
+         * @param buffer- The array from which shorts are to be read
+         * @param offset- The offset within the array of the first short to be read;
+         * @param length - The number of shorts to be read from the given array
+         * @returns a reference to this buffer
+         * @throws BufferOverflowException - If there is insufficient space in this buffer
+         * @throws ReadOnlyBufferException - If this buffer is read-only
+         * @throws NullPointerException if the passed buffer is null.
+         */
+        ShortBuffer& put( const short* buffer, std::size_t offset, std::size_t length )
+            throw( BufferOverflowException, ReadOnlyBufferException,
+                   lang::exceptions::NullPointerException );
+
+        /**
+         * This method transfers the entire content of the given source shorts array into
+         * this buffer.  This is the same as calling put( &buffer[0], 0, buffer.size()
+         * @pparam buffer - The buffer whose contents are copied to this ShortBuffer
+         * @returns a reference to this buffer
+         * @throws BufferOverflowException - If there is insufficient space in this buffer
+         * @throws ReadOnlyBufferException - If this buffer is read-only
+         */
+        ShortBuffer& put( std::vector<short>& buffer )
+            throw( BufferOverflowException, ReadOnlyBufferException );
+
+        /**
+         * Writes the given shorts into this buffer at the current position, and then
+         * increments the position.
+         * @param value - the shorts value to be written
+         * @returns a reference to this buffer
+         * @throws BufferOverflowException - If this buffer's current position is not
+         * smaller than its limit
+         * @throws ReadOnlyBufferException - If this buffer is read-only
+         */
+        virtual ShortBuffer& put( short value )
+            throw( BufferOverflowException, ReadOnlyBufferException ) = 0;
+
+        /**
+         * Writes the given shorts into this buffer at the given index.
+         * @param index - position in the Buffer to write the data
+         * @param value - the shorts to write.
+         * @returns a reference to this buffer
+         * @throws IndexOutOfBoundsException - If index greater than the buffer's limit
+         * minus the size of the type being written.
+         * @throws ReadOnlyBufferException - If this buffer is read-only
+         */
+        virtual ShortBuffer& put( std::size_t index, short value )
+            throw( lang::exceptions::IndexOutOfBoundsException,
+                   ReadOnlyBufferException ) = 0;
+
+        /**
+         * Creates a new ShortBuffer whose content is a shared subsequence of this
+         * buffer's content.  The content of the new buffer will start at this buffer's
+         * current position. Changes to this buffer's content will be visible in the new
+         * buffer, and vice versa; the two buffers' position, limit, and mark values will
+         * be independent.
+         * <p>
+         * The new buffer's position will be zero, its capacity and its limit will be the
+         * number of bytes remaining in this buffer, and its mark will be undefined. The
+         * new buffer will be read-only if, and only if, this buffer is read-only.
+         * @returns the newly create ShortBuffer which the caller owns.
+         */
+        virtual ShortBuffer* slice() const = 0;
+
+    public:  // Comparable
+
+        /**
+         * Compares this object with the specified object for order. Returns a
+         * negative integer, zero, or a positive integer as this object is less
+         * than, equal to, or greater than the specified object.
+         * @param value - the Object to be compared.
+         * @returns a negative integer, zero, or a positive integer as this
+         * object is less than, equal to, or greater than the specified object.
+         */
+        virtual int compareTo( const ShortBuffer& value ) const;
+
+        /**
+         * @return true if this value is considered equal to the passed value.
+         */
+        virtual bool equals( const ShortBuffer& value ) 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.
+         */
+        virtual bool operator==( const ShortBuffer& value ) const;
+
+        /**
+         * Compares this object to another and returns true if this object
+         * is considered to be less than the one passed.  This
+         * @param value - the value to be compared to this one.
+         * @return true if this object is equal to the one passed.
+         */
+        virtual bool operator<( const ShortBuffer& value ) const;
+
+    public:   // Statics
+
+        /**
+         * Allocates a new Double buffer.
+         * <p>
+         * The new buffer's position will be zero, its limit will be its capacity, and
+         * its mark will be undefined. It will have a backing array, and its array offset
+         * will be zero.
+         * @param capacity - The size of the Double buffer in shorts
+         * @returns the ShortBuffer that was allocated, caller owns.
+         */
+        static ShortBuffer* allocate( std::size_t capacity );
+
+        /**
+         * Wraps the passed buffer with a new ShortBuffer.
+         * <p>
+         * The new buffer will be backed by the given short array; that is, modifications
+         * to the buffer will cause the array to be modified and vice versa. The new
+         * buffer's capacity will be array.length, its position will be offset, its limit
+         * will be offset + length, and its mark will be undefined. Its backing array
+         * will be the given array, and its array offset will be zero.
+         * @param buffer - The array that will back the new buffer
+         * @param offset - The offset of the subarray to be used
+         * @param length - The length of the subarray to be used
+         * @returns a new ShortBuffer that is backed by buffer, caller owns.
+         */
+        static ShortBuffer* wrap( short* array, std::size_t offset, std::size_t length )
+            throw( lang::exceptions::NullPointerException );
+
+        /**
+         * Wraps the passed STL short Vector in a ShortBuffer.
+         * <p>
+         * The new buffer will be backed by the given short array; modifications to the
+         * buffer will cause the array to be modified and vice versa. The new buffer's
+         * capacity and limit will be buffer.size(), its position will be zero, and its
+         * mark will be undefined. Its backing array will be the given array, and its
+         * array offset will be zero.
+         * @param buffer - The vector that will back the new buffer, the vector must
+         * have been sized to the desired size already by calling vector.resize( N ).
+         * @returns a new ShortBuffer that is backed by buffer, caller owns.
+         */
+        static ShortBuffer* wrap( std::vector<short>& buffer );
+
+    };
+
+}}
+
+#endif /*_DECAF_NIO_SHORTBUFFER_H_*/

Added: activemq/activemq-cpp/trunk/src/main/decaf/security/GeneralSecurityException.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/decaf/security/GeneralSecurityException.h?rev=652104&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/decaf/security/GeneralSecurityException.h (added)
+++ activemq/activemq-cpp/trunk/src/main/decaf/security/GeneralSecurityException.h Tue Apr 29 13:52:30 2008
@@ -0,0 +1,106 @@
+/*
+ * 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_GENERALSECURITYEXCEPTION_H_
+#define _DECAF_SECURITY_GENERALSECURITYEXCEPTION_H_
+
+#include <decaf/lang/Exception.h>
+
+namespace decaf{
+namespace security{
+
+    /*
+     * The GeneralSecurityException class is a generic security exception class 
+     * that provides type safety for all the security-related exception classes 
+     * that extend from it.
+     */
+    class DECAF_API GeneralSecurityException : public GeneralSecurityException
+    {
+    public:
+
+        /**
+         * Default Constructor
+         */
+        GeneralSecurityException() throw() {};
+
+        /**
+         * Conversion Constructor from some other Exception
+         * @param ex
+         *      An exception that should become this type of Exception
+         */
+        GeneralSecurityException(const Exception& ex) throw()
+        : Exception()
+        {
+            *(Exception*)this = ex;
+        }
+
+        /**
+         * Copy Constructor
+         * @param ex
+         *      An exception that should become this type of Exception
+         */
+        GeneralSecurityException(const GeneralSecurityException& ex) throw()
+        : Exception()
+        {
+            *(Exception*)this = ex;
+        }
+
+        /**
+         * Constructor - Initializes the file name and line number where
+         * this message occured.  Sets the message to report, using an
+         * optional list of arguments to parse into the message
+         * 
+         * @param file 
+         *      name where exception occurs
+         * @param lineNumber
+         *      line number where the exception occurred.
+         * @param msg
+         *      message to report
+         * @param ...
+         *      list of primitives that are formatted into the message
+         */
+        GeneralSecurityException( 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);
+        }
+
+        /**
+         * Clones this exception.  This is useful for cases where you need
+         * to preserve the type of the original exception as well as the message.
+         * All subclasses should override.
+         * 
+         * @return A deep copy of this exception.
+         */
+        virtual GeneralSecurityException* clone() const{
+            return new GeneralSecurityException(*this);
+        }
+
+        virtual ~GeneralSecurityException() throw() {}
+
+   };
+
+}}
+
+#endif /*_DECAF_SECURITY_GENERALSECURITYEXCEPTION_H_*/

Added: activemq/activemq-cpp/trunk/src/main/decaf/security/InvalidKeyException.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/decaf/security/InvalidKeyException.h?rev=652104&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/decaf/security/InvalidKeyException.h (added)
+++ activemq/activemq-cpp/trunk/src/main/decaf/security/InvalidKeyException.h Tue Apr 29 13:52:30 2008
@@ -0,0 +1,105 @@
+/*
+ * 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_INVALIDKEYEXCEPTION_H_
+#define _DECAF_SECURITY_INVALIDKEYEXCEPTION_H_
+
+#include <decaf/security/KeyException.h>
+
+namespace decaf{
+namespace security{
+
+    /*
+     * This is the exception for invalid Keys (invalid encoding, wrong length, 
+     * uninitialized, etc).
+     */
+    class DECAF_API InvalidKeyException : public KeyException
+    {
+    public:
+
+        /**
+         * Default Constructor
+         */
+        InvalidKeyException() throw() {};
+
+        /**
+         * Conversion Constructor from some other Exception
+         * @param ex
+         *      An exception that should become this type of Exception
+         */
+        InvalidKeyException(const Exception& ex) throw()
+        : Exception()
+        {
+            *(Exception*)this = ex;
+        }
+
+        /**
+         * Copy Constructor
+         * @param ex
+         *      An exception that should become this type of Exception
+         */
+        InvalidKeyException(const InvalidKeyException& ex) throw()
+        : Exception()
+        {
+            *(Exception*)this = ex;
+        }
+
+        /**
+         * Constructor - Initializes the file name and line number where
+         * this message occured.  Sets the message to report, using an
+         * optional list of arguments to parse into the message
+         * 
+         * @param file 
+         *      name where exception occurs
+         * @param lineNumber
+         *      line number where the exception occurred.
+         * @param msg
+         *      message to report
+         * @param ...
+         *      list of primitives that are formatted into the message
+         */
+        InvalidKeyException( 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);
+        }
+
+        /**
+         * Clones this exception.  This is useful for cases where you need
+         * to preserve the type of the original exception as well as the message.
+         * All subclasses should override.
+         * 
+         * @return A deep copy of this exception.
+         */
+        virtual InvalidKeyException* clone() const{
+            return new InvalidKeyException(*this);
+        }
+
+        virtual ~InvalidKeyException() throw() {}
+
+   };
+
+}}
+
+#endif /*_DECAF_SECURITY_INVALIDKEYEXCEPTION_H_*/

Added: activemq/activemq-cpp/trunk/src/main/decaf/security/Key.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/decaf/security/Key.h?rev=652104&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/decaf/security/Key.h (added)
+++ activemq/activemq-cpp/trunk/src/main/decaf/security/Key.h Tue Apr 29 13:52:30 2008
@@ -0,0 +1,103 @@
+/*
+ * 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_KEY_H
+#define _DECAF_SECURITY_KEY_H
+
+#include <vector>
+#include <string>
+
+namespace decaf {
+namespace security {
+
+    /**
+     * The Key interface is the top-level interface for all keys. It defines the 
+     * functionality shared by all key objects. All keys have three 
+     * characteristics:<br>
+     * <br>
+     * An Algorithm <br>
+     * This is the key algorithm for that key. The key algorithm is usually an 
+     * encryption or asymmetric operation algorithm (such as DSA or RSA), which 
+     * will work with those algorithms and with related algorithms (such as MD5 
+     * with RSA, SHA-1 with RSA, Raw DSA, etc.) The name of the algorithm of a 
+     * key is obtained using the getAlgorithm method.<br>
+     * <br>
+     * An Encoded Form <br>
+     * This is an external encoded form for the key used when a standard 
+     * representation of the key is needed outside the application, as 
+     * when transmitting the key to some other party. The key is encoded 
+     * according to a standard format (such as X.509 SubjectPublicKeyInfo or 
+     * PKCS#8), and is returned using the getEncoded method. Note: The syntax of 
+     * the ASN.1 type SubjectPublicKeyInfo is defined as follows:
+     * <br>
+     * SubjectPublicKeyInfo ::= SEQUENCE { <br>
+     *    algorithm AlgorithmIdentifier, <br>
+     *    subjectPublicKey BIT STRING } <br>
+     * <br>
+     * AlgorithmIdentifier ::= SEQUENCE { <br>
+     *    algorithm OBJECT IDENTIFIER, <br>
+     *    parameters ANY DEFINED BY algorithm OPTIONAL } <br>
+     * <br>
+     * For more information, see RFC 2459: Internet X.509 Public Key 
+     * Infrastructure Certificate and CRL Profile. <br>
+     * <br>
+     * A Format <br>
+     * This is the name of the format of the encoded key. It is returned by the
+     * getFormat method.
+     */
+    class DECAF_API Key {
+        
+    public:
+        
+        virtual ~Key() {}
+ 
+        /**
+         * Returns the standard algorithm name for this key. For example, "DSA" 
+         * would indicate that this key is a DSA key.
+         * 
+         * @return the name of the algorithm associated with this key.
+         */
+        virtual std::string getAlgorithm() const = 0;
+        
+        /**
+         * Provides the key in its primary encoding format, or nothing if this 
+         * key does not support encoding.
+         * 
+         * @param output
+         *      Receives the encoded key, or nothing if the key does not support 
+         *      encoding.
+         */
+        virtual void getEncoded( std::vector<unsigned char>& output) const = 0;
+        
+        /**
+         * Returns the name of the primary encoding format of this key, or 
+         * an empty string if this key does not support encoding. The primary 
+         * encoding format is named in terms of the appropriate ASN.1 data 
+         * format, if an ASN.1 specification for this key exists. For example, 
+         * the name of the ASN.1 data format for public keys is 
+         * SubjectPublicKeyInfo, as defined by the X.509 standard; in this 
+         * case, the returned format is "X.509". Similarly, the name of the 
+         * ASN.1 data format for private keys is PrivateKeyInfo, as defined by 
+         * the PKCS #8 standard; in this case, the returned format is "PKCS#8".
+         * 
+         * @return the primary encoding format of the key.
+         */
+        virtual std::string getFormat() const = 0;
+    };
+}}
+
+#endif /*_DECAF_SECURITY_KEY_H*/

Added: activemq/activemq-cpp/trunk/src/main/decaf/security/KeyException.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/decaf/security/KeyException.h?rev=652104&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/decaf/security/KeyException.h (added)
+++ activemq/activemq-cpp/trunk/src/main/decaf/security/KeyException.h Tue Apr 29 13:52:30 2008
@@ -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_SECURITY_KEYEXCEPTION_H_
+#define _DECAF_SECURITY_KEYEXCEPTION_H_
+
+#include <decaf/security/GeneralSecurityException.h>
+
+namespace decaf{
+namespace security{
+
+    /*
+     * A basic key exception
+     */
+    class DECAF_API KeyException : public GeneralSecurityException
+    {
+    public:
+
+        /**
+         * Default Constructor
+         */
+        KeyException() throw() {};
+
+        /**
+         * Conversion Constructor from some other Exception
+         * @param ex
+         *      An exception that should become this type of Exception
+         */
+        KeyException(const Exception& ex) throw()
+        : Exception()
+        {
+            *(Exception*)this = ex;
+        }
+
+        /**
+         * Copy Constructor
+         * @param ex
+         *      An exception that should become this type of Exception
+         */
+        KeyException(const KeyException& ex) throw()
+        : Exception()
+        {
+            *(Exception*)this = ex;
+        }
+
+        /**
+         * Constructor - Initializes the file name and line number where
+         * this message occured.  Sets the message to report, using an
+         * optional list of arguments to parse into the message
+         * 
+         * @param file 
+         *      name where exception occurs
+         * @param lineNumber
+         *      line number where the exception occurred.
+         * @param msg
+         *      message to report
+         * @param ...
+         *      list of primitives that are formatted into the message
+         */
+        KeyException( 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);
+        }
+
+        /**
+         * Clones this exception.  This is useful for cases where you need
+         * to preserve the type of the original exception as well as the message.
+         * All subclasses should override.
+         * 
+         * @return A deep copy of this exception.
+         */
+        virtual KeyException* clone() const{
+            return new KeyException(*this);
+        }
+
+        virtual ~KeyException() throw() {}
+
+   };
+
+}}
+
+#endif /*_DECAF_SECURITY_KEYEXCEPTION_H_*/

Added: activemq/activemq-cpp/trunk/src/main/decaf/security/NoSuchAlgorithmException.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/decaf/security/NoSuchAlgorithmException.h?rev=652104&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/decaf/security/NoSuchAlgorithmException.h (added)
+++ activemq/activemq-cpp/trunk/src/main/decaf/security/NoSuchAlgorithmException.h Tue Apr 29 13:52:30 2008
@@ -0,0 +1,105 @@
+/*
+ * 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_NOSUCHALGORITHMEXCEPTION_H_
+#define _DECAF_SECURITY_NOSUCHALGORITHMEXCEPTION_H_
+
+#include <decaf/security/GeneralSecurityException.h>
+
+namespace decaf{
+namespace security{
+
+    /*
+     * This exception is thrown when a particular cryptographic algorithm is 
+     * requested but is not available in the environment.
+     */
+    class DECAF_API NoSuchAlgorithmException : public GeneralSecurityException
+    {
+    public:
+
+        /**
+         * Default Constructor
+         */
+        NoSuchAlgorithmException() throw() {};
+
+        /**
+         * Conversion Constructor from some other Exception
+         * @param ex
+         *      An exception that should become this type of Exception
+         */
+        NoSuchAlgorithmException(const Exception& ex) throw()
+        : Exception()
+        {
+            *(Exception*)this = ex;
+        }
+
+        /**
+         * Copy Constructor
+         * @param ex
+         *      An exception that should become this type of Exception
+         */
+        NoSuchAlgorithmException(const NoSuchAlgorithmException& ex) throw()
+        : Exception()
+        {
+            *(Exception*)this = ex;
+        }
+
+        /**
+         * Constructor - Initializes the file name and line number where
+         * this message occured.  Sets the message to report, using an
+         * optional list of arguments to parse into the message
+         * 
+         * @param file 
+         *      name where exception occurs
+         * @param lineNumber
+         *      line number where the exception occurred.
+         * @param msg
+         *      message to report
+         * @param ...
+         *      list of primitives that are formatted into the message
+         */
+        NoSuchAlgorithmException( 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);
+        }
+
+        /**
+         * Clones this exception.  This is useful for cases where you need
+         * to preserve the type of the original exception as well as the message.
+         * All subclasses should override.
+         * 
+         * @return A deep copy of this exception.
+         */
+        virtual NoSuchAlgorithmException* clone() const{
+            return new NoSuchAlgorithmException(*this);
+        }
+
+        virtual ~NoSuchAlgorithmException() throw() {}
+
+   };
+
+}}
+
+#endif /*_DECAF_SECURITY_NOSUCHALGORITHMEXCEPTION_H_*/

Added: activemq/activemq-cpp/trunk/src/main/decaf/security/NoSuchProviderException.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/decaf/security/NoSuchProviderException.h?rev=652104&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/decaf/security/NoSuchProviderException.h (added)
+++ activemq/activemq-cpp/trunk/src/main/decaf/security/NoSuchProviderException.h Tue Apr 29 13:52:30 2008
@@ -0,0 +1,105 @@
+/*
+ * 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_NOSUCHPROVIDEREXCEPTION_H_
+#define _DECAF_SECURITY_NOSUCHPROVIDEREXCEPTION_H_
+
+#include <decaf/security/GeneralSecurityException.h>
+
+namespace decaf{
+namespace security{
+
+    /*
+     * This exception is thrown when a particular security provider is requested 
+     * but is not available in the environment.
+     */
+    class DECAF_API NoSuchProviderException : public GeneralSecurityException
+    {
+    public:
+
+        /**
+         * Default Constructor
+         */
+        NoSuchProviderException() throw() {};
+
+        /**
+         * Conversion Constructor from some other Exception
+         * @param ex
+         *      An exception that should become this type of Exception
+         */
+        NoSuchProviderException(const Exception& ex) throw()
+        : Exception()
+        {
+            *(Exception*)this = ex;
+        }
+
+        /**
+         * Copy Constructor
+         * @param ex
+         *      An exception that should become this type of Exception
+         */
+        NoSuchProviderException(const NoSuchProviderException& ex) throw()
+        : Exception()
+        {
+            *(Exception*)this = ex;
+        }
+
+        /**
+         * Constructor - Initializes the file name and line number where
+         * this message occured.  Sets the message to report, using an
+         * optional list of arguments to parse into the message
+         * 
+         * @param file 
+         *      name where exception occurs
+         * @param lineNumber
+         *      line number where the exception occurred.
+         * @param msg
+         *      message to report
+         * @param ...
+         *      list of primitives that are formatted into the message
+         */
+        NoSuchProviderException( 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);
+        }
+
+        /**
+         * Clones this exception.  This is useful for cases where you need
+         * to preserve the type of the original exception as well as the message.
+         * All subclasses should override.
+         * 
+         * @return A deep copy of this exception.
+         */
+        virtual NoSuchProviderException* clone() const{
+            return new NoSuchProviderException(*this);
+        }
+
+        virtual ~NoSuchProviderException() throw() {}
+
+   };
+
+}}
+
+#endif /*_DECAF_SECURITY_NOSUCHPROVIDEREXCEPTION_H_*/

Added: activemq/activemq-cpp/trunk/src/main/decaf/security/Principal.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/decaf/security/Principal.h?rev=652104&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/decaf/security/Principal.h (added)
+++ activemq/activemq-cpp/trunk/src/main/decaf/security/Principal.h Tue Apr 29 13:52:30 2008
@@ -0,0 +1,51 @@
+/*
+ * 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_PRINCIPAL_H_
+#define _DECAF_SECURITY_PRINCIPAL_H_
+
+namespace decaf {
+namespace security {
+
+    /**
+     * Base interface for a principal, which can represent an individual or 
+     * organization.
+     */
+    class Principal {        
+    public:
+        
+        virtual ~Principal() {}
+        
+        /**
+         * Compares two principals to see if they are the same.
+         * 
+         * @param another
+         *      A principal to be tested for equality to this one.
+         * @return true if the given principal is equivalent to this one.
+         */
+        virtual bool equals( const Principal& another ) const = 0;
+        
+        /**
+         * Provides the name of this principal.
+         * 
+         * @return the name of this principal.
+         */
+        virtual std::string getName() const = 0;        
+    };
+}}
+
+#endif /*_DECAF_SECURITY_PRINCIPAL_H_*/

Added: activemq/activemq-cpp/trunk/src/main/decaf/security/PublicKey.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/decaf/security/PublicKey.h?rev=652104&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/decaf/security/PublicKey.h (added)
+++ activemq/activemq-cpp/trunk/src/main/decaf/security/PublicKey.h Tue Apr 29 13:52:30 2008
@@ -0,0 +1,39 @@
+/*
+ * 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_PUBLICKEY_H_
+#define _DECAF_SECURITY_PUBLICKEY_H_
+
+#include <decaf/security/Key.h>
+
+namespace decaf {
+namespace security {
+
+    /**
+     * A public key. This interface contains no methods or constants. It merely 
+     * serves to group (and provide type safety for) all public key interfaces.
+     */
+    class DECAF_API PublicKey : public Key {
+        
+    public:
+        
+        virtual ~PublicKey() {}
+    };
+
+}}
+
+#endif /*_DECAF_SECURITY_PUBLICKEY_H_*/

Added: activemq/activemq-cpp/trunk/src/main/decaf/security/SignatureException.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/decaf/security/SignatureException.h?rev=652104&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/decaf/security/SignatureException.h (added)
+++ activemq/activemq-cpp/trunk/src/main/decaf/security/SignatureException.h Tue Apr 29 13:52:30 2008
@@ -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_SECURITY_SIGNATUREEXCEPTION_H_
+#define _DECAF_SECURITY_SIGNATUREEXCEPTION_H_
+
+#include <decaf/security/GeneralSecurityException.h>
+
+namespace decaf{
+namespace security{
+
+    /*
+     * Generic signature exception.
+     */
+    class DECAF_API SignatureException : public GeneralSecurityException
+    {
+    public:
+
+        /**
+         * Default Constructor
+         */
+        SignatureException() throw() {};
+
+        /**
+         * Conversion Constructor from some other Exception
+         * @param ex
+         *      An exception that should become this type of Exception
+         */
+        SignatureException(const Exception& ex) throw()
+        : Exception()
+        {
+            *(Exception*)this = ex;
+        }
+
+        /**
+         * Copy Constructor
+         * @param ex
+         *      An exception that should become this type of Exception
+         */
+        SignatureException(const SignatureException& ex) throw()
+        : Exception()
+        {
+            *(Exception*)this = ex;
+        }
+
+        /**
+         * Constructor - Initializes the file name and line number where
+         * this message occured.  Sets the message to report, using an
+         * optional list of arguments to parse into the message
+         * 
+         * @param file 
+         *      name where exception occurs
+         * @param lineNumber
+         *      line number where the exception occurred.
+         * @param msg
+         *      message to report
+         * @param ...
+         *      list of primitives that are formatted into the message
+         */
+        SignatureException( 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);
+        }
+
+        /**
+         * Clones this exception.  This is useful for cases where you need
+         * to preserve the type of the original exception as well as the message.
+         * All subclasses should override.
+         * 
+         * @return A deep copy of this exception.
+         */
+        virtual SignatureException* clone() const{
+            return new SignatureException(*this);
+        }
+
+        virtual ~SignatureException() throw() {}
+
+   };
+
+}}
+
+#endif /*_DECAF_SECURITY_SIGNATUREEXCEPTION_H_*/

Added: activemq/activemq-cpp/trunk/src/main/decaf/security/auth/x500/X500Principal.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/decaf/security/auth/x500/X500Principal.h?rev=652104&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/decaf/security/auth/x500/X500Principal.h (added)
+++ activemq/activemq-cpp/trunk/src/main/decaf/security/auth/x500/X500Principal.h Tue Apr 29 13:52:30 2008
@@ -0,0 +1,58 @@
+/*
+ * 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_AUTH_X500_X500PRINCIPAL_H_
+#define _DECAF_SECURITY_AUTH_X500_X500PRINCIPAL_H_
+
+#include <string>
+#include <vector>
+
+#include <decaf/security/Principal.h>
+#include <decaf/util/Map.h>
+#include <decaf/io/InputStream.h>
+
+namespace decaf {
+namespace security {
+namespace auth {
+namespace x500 {
+
+    class X500Principal : public Principal {
+    public:
+        
+        /*X500Principal( unsigned char* name, int offset, int len );
+        X500Principal( decaf::io::InputStream& is );
+        X500Principal( const std::string& name );
+        X500Principal( const std::string& name, 
+                const decaf::util::Map<std::string, std::string>& keywordMap );*/
+        
+        virtual ~X500Principal() {}        
+        
+        virtual std::string getName() const = 0;
+        
+        virtual void getEncoded( std::vector<unsigned char>& output ) const = 0;
+        
+        virtual int hashCode() const = 0;
+        
+        /*virtual std::string getName( const std::string& format ) const;
+        
+        virtual std::string getName(const std::string& format, 
+                const decaf::util::Map<std::string, std::string>& oldMap );*/                        
+    };
+    
+}}}}
+
+#endif /*_DECAF_SECURITY_AUTH_X500_X500PRINCIPAL_H_*/

Added: activemq/activemq-cpp/trunk/src/main/decaf/security/cert/Certificate.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/decaf/security/cert/Certificate.h?rev=652104&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/decaf/security/cert/Certificate.h (added)
+++ activemq/activemq-cpp/trunk/src/main/decaf/security/cert/Certificate.h Tue Apr 29 13:52:30 2008
@@ -0,0 +1,135 @@
+/*
+ * 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_CERT_CERTIFICATE_H_
+#define _DECAF_SECURITY_CERT_CERTIFICATE_H_
+
+#include <vector>
+
+#include <decaf/security/InvalidKeyException.h>
+#include <decaf/security/NoSuchAlgorithmException.h>
+#include <decaf/security/SignatureException.h>
+
+#include <decaf/security/cert/CertificateEncodingException.h>
+#include <decaf/security/cert/CertificateException.h>
+
+namespace decaf {
+namespace security {
+namespace cert {
+
+    /**
+     * Base interface for all identity certificates.
+     */
+    class DECAF_API Certificate {
+    
+    public:
+        
+        virtual ~Certificate() {}
+        
+        /**
+         * Compares the encoded form of the two certificates.
+         * 
+         * @param cert
+         *      The certificate to be tested for equality with this certificate.
+         * @return true if the given certificate is equal to this certificate.
+         */
+        virtual bool equals( const Certificate& cert ) const = 0;
+        
+        /**
+         * Provides the encoded form of this certificate.
+         * 
+         * @param output
+         *      Receives the encoded form of this certificate.
+         * @throws CertificateEncodingException if an encoding error occurs
+         */
+        virtual void getEncoded( std::vector<unsigned char>& output ) const 
+            throw ( CertificateEncodingException ) = 0;
+        
+        /**
+         * Returns the type of this certificate
+         * 
+         * @return the type of this certificate
+         */
+        virtual std::string getType() const = 0;
+        
+        /**
+         * Gets the public key of this certificate.
+         * 
+         * @return the public key
+         */
+        virtual PublicKey* getPublicKey() = 0;
+        
+        /**
+         * Gets the public key of this certificate.
+         * 
+         * @return the public key
+         */
+        virtual const PublicKey* getPublicKey() const = 0;
+        
+        /**
+         * Verifies that this certificate was signed with the private key
+         * that corresponds to the specified public key.
+         * 
+         * @param publicKey
+         *      The public key used to carry out the validation.
+         * @throws NoSuchAlgorithmException - on unsupported signature algorithms. 
+         * @throws InvalidKeyException - on incorrect key. 
+         * @throws NoSuchProviderException - if there's no default provider. 
+         * @throws SignatureException - on signature errors. 
+         * @throws CertificateException - on encoding errors.
+         */
+        virtual void verify( const PublicKey& publicKey ) const 
+            throw( NoSuchAlgorithmException, 
+                   InvalidKeyException, 
+                   NoSuchProviderException, 
+                   SignatureException, 
+                   CertificateException) = 0;
+        
+        /**
+         * Verifies that this certificate was signed with the private key
+         * that corresponds to the specified public key.  Uses the verification
+         * engine of the specified provider.
+         * 
+         * @param publicKey
+         *      The public key used to carry out the validation.
+         * @param sigProvider
+         *      The name of the signature provider
+         * @throws NoSuchAlgorithmException - on unsupported signature algorithms. 
+         * @throws InvalidKeyException - on incorrect key. 
+         * @throws NoSuchProviderException - if there's no default provider. 
+         * @throws SignatureException - on signature errors. 
+         * @throws CertificateException - on encoding errors.
+         */
+        virtual void verify( const PublicKey& publicKey, 
+                             const std::string& sigProvider ) const 
+                    throw( NoSuchAlgorithmException, 
+                           InvalidKeyException, 
+                           NoSuchProviderException, 
+                           SignatureException, 
+                           CertificateException) = 0;
+        
+        /**
+         * Returns a string representation of this certificate.
+         * 
+         * @return a string representation of this certificate
+         */
+        virtual std::string toString() const = 0;
+    };
+    
+}}}
+
+#endif /*_DECAF_SECURITY_CERT_CERTIFICATE_H_*/

Added: activemq/activemq-cpp/trunk/src/main/decaf/security/cert/CertificateEncodingException.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/decaf/security/cert/CertificateEncodingException.h?rev=652104&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/decaf/security/cert/CertificateEncodingException.h (added)
+++ activemq/activemq-cpp/trunk/src/main/decaf/security/cert/CertificateEncodingException.h Tue Apr 29 13:52:30 2008
@@ -0,0 +1,106 @@
+/*
+ * 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_CERT_CERTIFICATEENCODINGEXCEPTION_H_
+#define _DECAF_SECURITY_CERT_CERTIFICATEENCODINGEXCEPTION_H_
+
+#include <decaf/security/cert/CertificateException.h>
+
+namespace decaf{
+namespace security{
+namespace cert{
+
+    /*
+     * Certificate Encoding Exception. This is thrown whenever an error occurs 
+     * while attempting to encode a certificate.
+     */
+    class DECAF_API CertificateEncodingException : public CertificateException
+    {
+    public:
+
+        /**
+         * Default Constructor
+         */
+        CertificateEncodingException() throw() {};
+
+        /**
+         * Conversion Constructor from some other Exception
+         * @param ex
+         *      An exception that should become this type of Exception
+         */
+        CertificateEncodingException(const Exception& ex) throw()
+        : Exception()
+        {
+            *(Exception*)this = ex;
+        }
+
+        /**
+         * Copy Constructor
+         * @param ex
+         *      An exception that should become this type of Exception
+         */
+        CertificateEncodingException(const CertificateEncodingException& ex) throw()
+        : Exception()
+        {
+            *(Exception*)this = ex;
+        }
+
+        /**
+         * Constructor - Initializes the file name and line number where
+         * this message occured.  Sets the message to report, using an
+         * optional list of arguments to parse into the message
+         * 
+         * @param file 
+         *      name where exception occurs
+         * @param lineNumber
+         *      line number where the exception occurred.
+         * @param msg
+         *      message to report
+         * @param ...
+         *      list of primitives that are formatted into the message
+         */
+        CertificateEncodingException( 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);
+        }
+
+        /**
+         * Clones this exception.  This is useful for cases where you need
+         * to preserve the type of the original exception as well as the message.
+         * All subclasses should override.
+         * 
+         * @return A deep copy of this exception.
+         */
+        virtual CertificateEncodingException* clone() const{
+            return new CertificateEncodingException(*this);
+        }
+
+        virtual ~CertificateEncodingException() throw() {}
+
+   };
+
+}}}
+
+#endif /*_DECAF_SECURITY_CERT_CERTIFICATEENCODINGEXCEPTION_H_*/

Added: activemq/activemq-cpp/trunk/src/main/decaf/security/cert/CertificateException.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/decaf/security/cert/CertificateException.h?rev=652104&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/decaf/security/cert/CertificateException.h (added)
+++ activemq/activemq-cpp/trunk/src/main/decaf/security/cert/CertificateException.h Tue Apr 29 13:52:30 2008
@@ -0,0 +1,105 @@
+/*
+ * 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_CERT_CERTIFICATEEXCEPTION_H_
+#define _DECAF_SECURITY_CERT_CERTIFICATEEXCEPTION_H_
+
+#include <decaf/security/GeneralSecurityException.h>
+
+namespace decaf{
+namespace security{
+namespace cert{
+
+    /*
+     * Indicates one of a variety of certificate problems.
+     */
+    class DECAF_API CertificateException : public GeneralSecurityException
+    {
+    public:
+
+        /**
+         * Default Constructor
+         */
+        CertificateException() throw() {};
+
+        /**
+         * 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;
+        }
+
+        /**
+         * Copy Constructor
+         * @param ex
+         *      An exception that should become this type of Exception
+         */
+        CertificateException(const CertificateException& ex) throw()
+        : Exception()
+        {
+            *(Exception*)this = ex;
+        }
+
+        /**
+         * Constructor - Initializes the file name and line number where
+         * this message occured.  Sets the message to report, using an
+         * optional list of arguments to parse into the message
+         * 
+         * @param file 
+         *      name where exception occurs
+         * @param lineNumber
+         *      line number where the exception occurred.
+         * @param msg
+         *      message to report
+         * @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);
+        }
+
+        /**
+         * Clones this exception.  This is useful for cases where you need
+         * to preserve the type of the original exception as well as the message.
+         * All subclasses should override.
+         * 
+         * @return A deep copy of this exception.
+         */
+        virtual CertificateException* clone() const{
+            return new CertificateException(*this);
+        }
+
+        virtual ~CertificateException() throw() {}
+
+   };
+
+}}}
+
+#endif /*_DECAF_SECURITY_CERT_CERTIFICATEEXCEPTION_H_*/

Added: activemq/activemq-cpp/trunk/src/main/decaf/security/cert/CertificateExpiredException.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/decaf/security/cert/CertificateExpiredException.h?rev=652104&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/decaf/security/cert/CertificateExpiredException.h (added)
+++ activemq/activemq-cpp/trunk/src/main/decaf/security/cert/CertificateExpiredException.h Tue Apr 29 13:52:30 2008
@@ -0,0 +1,107 @@
+/*
+ * 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_CERT_CERTIFICATEEXPIREDEXCEPTION_H_
+#define _DECAF_SECURITY_CERT_CERTIFICATEEXPIREDEXCEPTION_H_
+
+#include <decaf/security/cert/CertificateException.h>
+
+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
+    {
+    public:
+
+        /**
+         * Default Constructor
+         */
+        CertificateExpiredException() throw() {};
+
+        /**
+         * 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;
+        }
+
+        /**
+         * Copy Constructor
+         * @param ex
+         *      An exception that should become this type of Exception
+         */
+        CertificateExpiredException(const CertificateExpiredException& ex) throw()
+        : Exception()
+        {
+            *(Exception*)this = ex;
+        }
+
+        /**
+         * Constructor - Initializes the file name and line number where
+         * this message occured.  Sets the message to report, using an
+         * optional list of arguments to parse into the message
+         * 
+         * @param file 
+         *      name where exception occurs
+         * @param lineNumber
+         *      line number where the exception occurred.
+         * @param msg
+         *      message to report
+         * @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);
+        }
+
+        /**
+         * Clones this exception.  This is useful for cases where you need
+         * to preserve the type of the original exception as well as the message.
+         * All subclasses should override.
+         * 
+         * @return A deep copy of this exception.
+         */
+        virtual CertificateExpiredException* clone() const{
+            return new CertificateExpiredException(*this);
+        }
+
+        virtual ~CertificateExpiredException() throw() {}
+
+   };
+
+}}}
+
+#endif /*_DECAF_SECURITY_CERT_CERTIFICATEEXPIREDEXCEPTION_H_*/

Added: activemq/activemq-cpp/trunk/src/main/decaf/security/cert/CertificateNotYetValidException.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/decaf/security/cert/CertificateNotYetValidException.h?rev=652104&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/decaf/security/cert/CertificateNotYetValidException.h (added)
+++ activemq/activemq-cpp/trunk/src/main/decaf/security/cert/CertificateNotYetValidException.h Tue Apr 29 13:52:30 2008
@@ -0,0 +1,107 @@
+/*
+ * 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_CERT_CERTIFICATENOTYETVALIDEXCEPTION_H_
+#define _DECAF_SECURITY_CERT_CERTIFICATENOTYETVALIDEXCEPTION_H_
+
+#include <decaf/security/cert/CertificateException.h>
+
+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
+    {
+    public:
+
+        /**
+         * Default Constructor
+         */
+        CertificateNotYetValidException() throw() {};
+
+        /**
+         * 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;
+        }
+
+        /**
+         * Copy Constructor
+         * @param ex
+         *      An exception that should become this type of Exception
+         */
+        CertificateNotYetValidException(const CertificateNotYetValidException& ex) throw()
+        : Exception()
+        {
+            *(Exception*)this = ex;
+        }
+
+        /**
+         * Constructor - Initializes the file name and line number where
+         * this message occured.  Sets the message to report, using an
+         * optional list of arguments to parse into the message
+         * 
+         * @param file 
+         *      name where exception occurs
+         * @param lineNumber
+         *      line number where the exception occurred.
+         * @param msg
+         *      message to report
+         * @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);
+        }
+
+        /**
+         * Clones this exception.  This is useful for cases where you need
+         * to preserve the type of the original exception as well as the message.
+         * All subclasses should override.
+         * 
+         * @return A deep copy of this exception.
+         */
+        virtual CertificateNotYetValidException* clone() const{
+            return new CertificateNotYetValidException(*this);
+        }
+
+        virtual ~CertificateNotYetValidException() throw() {}
+
+   };
+
+}}}
+
+#endif /*_DECAF_SECURITY_CERT_CERTIFICATENOTYETVALIDEXCEPTION_H_*/