You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by nm...@apache.org on 2007/11/16 07:29:30 UTC
svn commit: r595573 [1/2] - in
/activemq/activemq-cpp/decaf/trunk/src/main/decaf: security/ security/auth/
security/auth/x500/ security/cert/ security_provider/
security_provider/unix/ security_provider/unix/openssl/
security_provider/windows/
Author: nmittler
Date: Thu Nov 15 22:29:28 2007
New Revision: 595573
URL: http://svn.apache.org/viewvc?rev=595573&view=rev
Log:
Adding the beginnings of some basic security classes with OpenSSL implementations.
Added:
activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/
activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/GeneralSecurityException.h
activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/InvalidKeyException.h
activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/Key.h
activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/KeyException.h
activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/NoSuchAlgorithmException.h
activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/NoSuchProviderException.h
activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/Principal.h
activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/PublicKey.h
activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/SignatureException.h
activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/auth/
activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/auth/x500/
activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/auth/x500/X500Principal.h
activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/cert/
activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/cert/Certificate.h
activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/cert/CertificateEncodingException.h
activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/cert/CertificateException.h
activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/cert/CertificateExpiredException.h
activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/cert/CertificateNotYetValidException.h
activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/cert/CertificateParsingException.h
activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/cert/X509Certificate.h
activemq/activemq-cpp/decaf/trunk/src/main/decaf/security_provider/
activemq/activemq-cpp/decaf/trunk/src/main/decaf/security_provider/SecurityProvider.h
activemq/activemq-cpp/decaf/trunk/src/main/decaf/security_provider/SecurityProviderMap.cpp
activemq/activemq-cpp/decaf/trunk/src/main/decaf/security_provider/SecurityProviderMap.h
activemq/activemq-cpp/decaf/trunk/src/main/decaf/security_provider/SecurityProviderRegistrar.h
activemq/activemq-cpp/decaf/trunk/src/main/decaf/security_provider/unix/
activemq/activemq-cpp/decaf/trunk/src/main/decaf/security_provider/unix/openssl/
activemq/activemq-cpp/decaf/trunk/src/main/decaf/security_provider/unix/openssl/OpenSSLX500Principal.cpp
activemq/activemq-cpp/decaf/trunk/src/main/decaf/security_provider/unix/openssl/OpenSSLX500Principal.h
activemq/activemq-cpp/decaf/trunk/src/main/decaf/security_provider/unix/openssl/OpenSSLX509Certificate.h
activemq/activemq-cpp/decaf/trunk/src/main/decaf/security_provider/windows/
Added: activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/GeneralSecurityException.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/GeneralSecurityException.h?rev=595573&view=auto
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/GeneralSecurityException.h (added)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/GeneralSecurityException.h Thu Nov 15 22:29:28 2007
@@ -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/decaf/trunk/src/main/decaf/security/InvalidKeyException.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/InvalidKeyException.h?rev=595573&view=auto
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/InvalidKeyException.h (added)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/InvalidKeyException.h Thu Nov 15 22:29:28 2007
@@ -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/decaf/trunk/src/main/decaf/security/Key.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/Key.h?rev=595573&view=auto
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/Key.h (added)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/Key.h Thu Nov 15 22:29:28 2007
@@ -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/decaf/trunk/src/main/decaf/security/KeyException.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/KeyException.h?rev=595573&view=auto
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/KeyException.h (added)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/KeyException.h Thu Nov 15 22:29:28 2007
@@ -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/decaf/trunk/src/main/decaf/security/NoSuchAlgorithmException.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/NoSuchAlgorithmException.h?rev=595573&view=auto
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/NoSuchAlgorithmException.h (added)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/NoSuchAlgorithmException.h Thu Nov 15 22:29:28 2007
@@ -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/decaf/trunk/src/main/decaf/security/NoSuchProviderException.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/NoSuchProviderException.h?rev=595573&view=auto
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/NoSuchProviderException.h (added)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/NoSuchProviderException.h Thu Nov 15 22:29:28 2007
@@ -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/decaf/trunk/src/main/decaf/security/Principal.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/Principal.h?rev=595573&view=auto
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/Principal.h (added)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/Principal.h Thu Nov 15 22:29:28 2007
@@ -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/decaf/trunk/src/main/decaf/security/PublicKey.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/PublicKey.h?rev=595573&view=auto
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/PublicKey.h (added)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/PublicKey.h Thu Nov 15 22:29:28 2007
@@ -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/decaf/trunk/src/main/decaf/security/SignatureException.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/SignatureException.h?rev=595573&view=auto
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/SignatureException.h (added)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/SignatureException.h Thu Nov 15 22:29:28 2007
@@ -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/decaf/trunk/src/main/decaf/security/auth/x500/X500Principal.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/auth/x500/X500Principal.h?rev=595573&view=auto
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/auth/x500/X500Principal.h (added)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/auth/x500/X500Principal.h Thu Nov 15 22:29:28 2007
@@ -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/decaf/trunk/src/main/decaf/security/cert/Certificate.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/cert/Certificate.h?rev=595573&view=auto
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/cert/Certificate.h (added)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/cert/Certificate.h Thu Nov 15 22:29:28 2007
@@ -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/decaf/trunk/src/main/decaf/security/cert/CertificateEncodingException.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/cert/CertificateEncodingException.h?rev=595573&view=auto
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/cert/CertificateEncodingException.h (added)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/cert/CertificateEncodingException.h Thu Nov 15 22:29:28 2007
@@ -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/decaf/trunk/src/main/decaf/security/cert/CertificateException.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/cert/CertificateException.h?rev=595573&view=auto
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/cert/CertificateException.h (added)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/cert/CertificateException.h Thu Nov 15 22:29:28 2007
@@ -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/decaf/trunk/src/main/decaf/security/cert/CertificateExpiredException.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/cert/CertificateExpiredException.h?rev=595573&view=auto
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/cert/CertificateExpiredException.h (added)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/cert/CertificateExpiredException.h Thu Nov 15 22:29:28 2007
@@ -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/decaf/trunk/src/main/decaf/security/cert/CertificateNotYetValidException.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/cert/CertificateNotYetValidException.h?rev=595573&view=auto
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/cert/CertificateNotYetValidException.h (added)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/cert/CertificateNotYetValidException.h Thu Nov 15 22:29:28 2007
@@ -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_*/
Added: activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/cert/CertificateParsingException.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/cert/CertificateParsingException.h?rev=595573&view=auto
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/cert/CertificateParsingException.h (added)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/cert/CertificateParsingException.h Thu Nov 15 22:29:28 2007
@@ -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_CERTIFICATEPARSINGEXCEPTION_H_
+#define _DECAF_SECURITY_CERT_CERTIFICATEPARSINGEXCEPTION_H_
+
+#include <decaf/security/cert/CertificateException.h>
+
+namespace decaf{
+namespace security{
+namespace cert{
+
+ /*
+ * Certificate Parsing Exception. This is thrown whenever an invalid
+ * DER-encoded certificate is parsed or unsupported DER features are found
+ * in the Certificate.
+ */
+ class DECAF_API CertificateParsingException : public CertificateException
+ {
+ public:
+
+ /**
+ * Default Constructor
+ */
+ CertificateParsingException() throw() {};
+
+ /**
+ * Conversion Constructor from some other Exception
+ * @param ex
+ * An exception that should become this type of Exception
+ */
+ CertificateParsingException(const Exception& ex) throw()
+ : Exception()
+ {
+ *(Exception*)this = ex;
+ }
+
+ /**
+ * Copy Constructor
+ * @param ex
+ * An exception that should become this type of Exception
+ */
+ CertificateParsingException(const CertificateParsingException& 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
+ */
+ CertificateParsingException( const char* file,
+ const int lineNumber,
+ const char* msg, ...) throw()
+ : Exception()
+ {
+ va_list vargs;
+ va_start(vargs, msg);
+ buildMessage(msg, vargs);
+
+ // Set the first mark for this exception.
+ setMark(file, lineNumber);
+ }
+
+ /**
+ * 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 CertificateParsingException* clone() const{
+ return new CertificateParsingException(*this);
+ }
+
+ virtual ~CertificateParsingException() throw() {}
+
+ };
+
+}}}
+
+#endif /*_DECAF_SECURITY_CERT_CERTIFICATEPARSINGEXCEPTION_H_*/
Added: activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/cert/X509Certificate.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/cert/X509Certificate.h?rev=595573&view=auto
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/cert/X509Certificate.h (added)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/security/cert/X509Certificate.h Thu Nov 15 22:29:28 2007
@@ -0,0 +1,78 @@
+/*
+ * 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_X509CERTIFICATE_H_
+#define _DECAF_SECURITY_CERT_X509CERTIFICATE_H_
+
+#include <decaf/security/cert/Certificate.h>
+
+#include <decaf/util/Date.h>
+
+namespace decaf {
+namespace security {
+namespace cert {
+
+ /**
+ * Base interface for all identity certificates.
+ */
+ class DECAF_API X509Certificate : public Certificate {
+
+ public:
+
+ virtual ~X509Certificate() {}
+
+ virtual void checkValidity() const
+ throw(CertificateExpiredException, CertificateNotYetValidException) = 0;
+
+ virtual void checkValidity(const decaf::util::Date& date) const
+ throw(CertificateExpiredException, CertificateNotYetValidException) = 0;
+
+ virtual int getBasicConstraints() const = 0;
+
+ virtual void getIssuerUniqueID( std::vector<bool>& output ) const = 0;
+
+ virtual const X500Principal* getIssuerX500Principal() const = 0;
+
+ virtual void getKeyUsage( std::vector<unsigned char>& output ) const = 0;
+
+ virtual Date getNotAfter() const = 0;
+
+ virtual Date getNotBefore() const = 0;
+
+ //virtual BigInteger getSerialNumber() const = 0;
+
+ virtual std::string getSigAlgName() const = 0;
+
+ virtual std::string getSigAlgOID() const = 0;
+
+ virtual void getSigAlgParams( std::vector<unsigned char>& output ) const = 0;
+
+ virtual void getSignature( std::vector<unsigned char>& output ) const = 0;
+
+ virtual void getSubjectUniqueID( std::vector<bool>& output ) const = 0;
+
+ virtual const X500Principal* getSubjectX500Principal() const = 0;
+
+ virtual void getTBSCertificate( std::vector<unsigned char>& output ) const
+ throw( CertificateEncodingException ) = 0;
+
+ virtual int getVersion() const = 0;
+ };
+
+}}}
+
+#endif /*_DECAF_SECURITY_CERT_X509CERTIFICATE_H_*/
Added: activemq/activemq-cpp/decaf/trunk/src/main/decaf/security_provider/SecurityProvider.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/security_provider/SecurityProvider.h?rev=595573&view=auto
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/security_provider/SecurityProvider.h (added)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/security_provider/SecurityProvider.h Thu Nov 15 22:29:28 2007
@@ -0,0 +1,35 @@
+/*
+ * 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_PROVIDER_SECURITYPROVIDER_H_
+#define _DECAF_SECURITY_PROVIDER_SECURITYPROVIDER_H_
+
+namespace decaf {
+namespace security_provider {
+
+ class SecurityProvider {
+ public:
+
+ virtual ~SecurityProvider() {}
+
+ virtual X500Principal* createX500Principal( const std::string& name ) = 0;
+ virtual X500Principal* createX500Principal( InputStream& is ) = 0;
+ virtual X500Principal* createX500Principal( unsigned char* buffer, int offset, int len ) = 0;
+ };
+}}
+
+#endif /*_DECAF_SECURITY_PROVIDER_SECURITYPROVIDER_H_*/
Added: activemq/activemq-cpp/decaf/trunk/src/main/decaf/security_provider/SecurityProviderMap.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/security_provider/SecurityProviderMap.cpp?rev=595573&view=auto
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/security_provider/SecurityProviderMap.cpp (added)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/security_provider/SecurityProviderMap.cpp Thu Nov 15 22:29:28 2007
@@ -0,0 +1,73 @@
+/*
+ * 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 "SecurityProviderMap.h"
+
+using namespace decaf::security_provider;
+
+////////////////////////////////////////////////////////////////////////////////
+SecurityProviderMap* SecurityProviderMap::getInstance()
+{
+ // Static instance of this Map, create here so that one will
+ // always exist, the one and only Connector Map.
+ static SecurityProviderMap instance;
+
+ return &instance;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void SecurityProviderMap::registerSecurityProvider( const std::string& name,
+ SecurityProvider* provider )
+{
+ providerMap[name] = provider;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void SecurityProviderMap::unregisterSecurityProvider( const std::string& name )
+{
+ providerMap.erase( name );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+SecurityProvider* SecurityProviderMap::lookup( const std::string& name )
+{
+ std::map<std::string, SecurityProvider*>::const_iterator itr =
+ providerMap.find( name );
+
+ if( itr != providerMap.end() )
+ {
+ return itr->second;
+ }
+
+ // Didn't find it, return nothing, not a single thing.
+ return NULL;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::size_t SecurityProviderMap::getFactoryNames(
+ std::vector<std::string>& factoryList )
+{
+ std::map<std::string, SecurityProvider*>::const_iterator itr =
+ providerMap.begin();
+
+ for( ; itr != providerMap.end(); ++itr )
+ {
+ providerMap.insert( factoryList.end(), itr->first );
+ }
+
+ return providerMap.size();
+}
Added: activemq/activemq-cpp/decaf/trunk/src/main/decaf/security_provider/SecurityProviderMap.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/security_provider/SecurityProviderMap.h?rev=595573&view=auto
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/security_provider/SecurityProviderMap.h (added)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/security_provider/SecurityProviderMap.h Thu Nov 15 22:29:28 2007
@@ -0,0 +1,113 @@
+/*
+ * 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_PROVIDER_SECURITYPROVIDERMAP_H
+#define _DECAF_SECURITY_PROVIDER_SECURITYPROVIDERMAP_H
+
+#include <map>
+#include <vector>
+#include <string>
+
+#include <activemq/exceptions/ActiveMQException.h>
+#include <activemq/connector/ConnectorFactory.h>
+
+namespace activemq{
+namespace connector{
+
+ /**
+ * Lookup Map for Connector Factories. Use the Connector name to
+ * find the associated factory. This class does not take ownership
+ * of the stored factories, they must be deallocated somewhere.
+ */
+ class SecurityProviderMap
+ {
+ private:
+
+ /**
+ * Map of Factories
+ */
+ std::map< std::string, SecurityProvider* > providerMap;
+
+ /**
+ * Hidden Contrustor, prevents instantiation
+ */
+ SecurityProviderMap() {};
+
+ /**
+ * Hidden Destructor.
+ */
+ virtual ~SecurityProviderMap() {};
+
+ /**
+ * Hidden Copy Constructore
+ */
+ SecurityProviderMap( const ConnectorFactoryMap& factoryMap );
+
+ /**
+ * Hidden Assignment operator
+ */
+ SecurityProviderMap operator=( const ConnectorFactoryMap& factoryMap );
+
+ public:
+
+ /**
+ * Gets a singleton instance of this class.
+ */
+ static SecurityProviderMap* getInstance();
+
+ /**
+ * Registers a new provider with this map
+ *
+ * @param name
+ * A name to associate the provider with
+ * @param provider
+ * the provider object to store in the map.
+ */
+ void registerSecurityProvider( const std::string& name,
+ SecurityProvider* provider );
+
+ /**
+ * Unregisters a provider from this map
+ *
+ * @param name
+ * the name of the provider to remove
+ */
+ void unregisterSecurityProvider( const std::string& name );
+
+ /**
+ * Lookup the named provider in the Map
+ *
+ * @param name
+ * the provider name to lookup
+ * @return the provider assciated with the name, or NULL
+ */
+ SecurityProvider* lookup( const std::string& name );
+
+ /**
+ * Fetch a list of provider names that this Map contains
+ *
+ * @param providers
+ * A vector object to receive the list
+ * @returns count of providers.
+ */
+ std::size_t getSecurityProviderNames( std::vector< std::string >& providers );
+
+ };
+
+}}
+
+#endif /*_DECAF_SECURITY_PROVIDER_SECURITYPROVIDERMAP_H*/
Added: activemq/activemq-cpp/decaf/trunk/src/main/decaf/security_provider/SecurityProviderRegistrar.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/security_provider/SecurityProviderRegistrar.h?rev=595573&view=auto
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/security_provider/SecurityProviderRegistrar.h (added)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/security_provider/SecurityProviderRegistrar.h Thu Nov 15 22:29:28 2007
@@ -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.
+ */
+
+#ifndef _DECAF_SECURITY_PROVIDER_SECURITYPROVIDERREGISTRAR_H
+#define _DECAF_SECURITY_PROVIDER_SECURITYPROVIDERREGISTRAR_H
+
+#include <string>
+
+#include <decaf/security_provider/SecurityProviderMap.h>
+
+namespace decaf{
+namespace security_provider{
+
+ /**
+ * Registers the passed in provider into the provider map, this class
+ * can manage the lifetime of the registered provider (default behaviour).
+ */
+ class SecurityProviderRegistrar {
+ private:
+
+ /**
+ * Unique name used to identify this provider in the map.
+ */
+ std::string name;
+
+ /**
+ * The provider object.
+ */
+ SecurityProvider* provider;
+
+ /**
+ * Indicates whether or not the provider will be destroyed
+ * when this registrar object is destroyed.
+ */
+ bool manageLifetime;
+
+ public:
+
+ /**
+ * Creates a registrar and registers the provider with
+ * the provider map.
+ *
+ * @param name
+ * name of the provider to register
+ * @param provider
+ * the provider object
+ * @param manageLifetime
+ * boolean indicating if this object manages the
+ * lifetime of the factory that is being registered.
+ */
+ SecurityProviderRegistrar( const std::string& name,
+ SecurityProvider* provider,
+ bool manageLifetime = true ) {
+ // Register it in the map.
+ SecurityProviderMap::getInstance()->
+ registerSecurityProvider(name, provider);
+
+ // Store for later deletion
+ this->provider = provider;
+ this->manageLifetime = manageLifetime;
+ this->name = name;
+ }
+
+ /**
+ * Unregisters the provider from the provider map and
+ * destroys it if <code>manageLifetime</code> is set.
+ */
+ virtual ~SecurityProviderRegistrar() {
+
+ try {
+
+ // UnRegister it in the map.
+ SecurityProviderMap::getInstance()->
+ unregisterSecurityProvider( name );
+
+ if( manageLifetime ) {
+ delete provider;
+ }
+
+ }
+ catch( ... ) {
+ // Destructors should not propagate exceptions.
+ }
+ }
+
+ /**
+ * get a reference to the factory that this class is holding
+ * @return reference to a factory class
+ */
+ virtual SecurityProvider* getProvider() {
+ return provider;
+ }
+
+ };
+
+}}
+
+#endif /*_DECAF_SECURITY_PROVIDER_SECURITYPROVIDERREGISTRAR_H*/
Added: activemq/activemq-cpp/decaf/trunk/src/main/decaf/security_provider/unix/openssl/OpenSSLX500Principal.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/security_provider/unix/openssl/OpenSSLX500Principal.cpp?rev=595573&view=auto
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/security_provider/unix/openssl/OpenSSLX500Principal.cpp (added)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/security_provider/unix/openssl/OpenSSLX500Principal.cpp Thu Nov 15 22:29:28 2007
@@ -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.
+ */
+
+#include "OpenSSLX500Principal.h"
+
+using namespace decaf::security_provider::unix::openssl;
+using namespace decaf::security;
+using namespace std;
+
+////////////////////////////////////////////////////////////////////////////////
+OpenSSLX500Principal::OpenSSLX500Principal( X509_NAME* name ) {
+
+ // Save the X509 name
+ this->x509Name = name;
+
+ // Indicate that the cached values have not yet been stored.
+ cachedNameString = false;
+ cachedEncoded = false;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool OpenSSLX500Principal::equals( const Principal& another ) const {
+
+ // Cast the principal to the correct type.
+ const OpenSSLX500Principal* other =
+ dynamic_cast<const OpenSSLX500Principal*>(&another);
+ if( other == NULL || x509Name == NULL || other->x509Name == NULL ) {
+ return false;
+ }
+
+ // Compare the underlying X509_NAME structures.
+ int value = X509_NAME_cmp(x509Name, other->x509Name);
+
+ // Return true if they match.
+ return (value == 0);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void OpenSSLX500Principal::getEncoded( X509_NAME* name,
+ std::vector<unsigned char>& output ) {
+
+ // Allocate the out buffer and store the encoded data there.
+ char* buffer = NULL;
+ int len = i2d_X509_NAME(name, NULL);
+ if( len < 0 ) {
+
+ // Error - should never get here since we already have a valid certificate.
+ return;
+ }
+
+ // Resize the output buffer and copy over the encoded data.
+ output.resize(len);
+ for( int ix=0; ix<len; ++ix ) {
+ output[ix] = buffer[ix];
+ }
+
+ // Destroy the allocated buffer.
+ delete [] buffer;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+string OpenSSLX500Principal::toString(X509_NAME* name) const {
+
+ string retVal;
+ if( name == null ) {
+ return retVal;
+ }
+
+ // Create an in-memory BIO structure to be the target
+ // of the conversion.
+ BIO* bio = BIO_new( BIO_s_mem() );
+ if( bio != NULL ) {
+
+ // Print the name to the BIO buffer, using RFC2253 formatting
+ if( X509_NAME_print_ex(bio, name, 2, XN_FLAG_RFC2253) ) {
+
+ // Get a pointer to the internal buffer and the length.
+ char* chars = NULL;
+ size_t len = (size_t)BIO_get_mem_ptr(bio, &chars);
+
+ // Add the characters to the output string.
+ retVal.append(chars, len);
+ }
+
+ // Free the BIO structure.
+ BIO_free(bio);
+ }
+
+ // Return the string
+ return retVal;
+}