summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOssama Othman <ossama-othman@users.noreply.github.com>2003-08-07 21:03:50 +0000
committerOssama Othman <ossama-othman@users.noreply.github.com>2003-08-07 21:03:50 +0000
commitf0147d905fa21738ab7efe630b7448d6c2eac35b (patch)
tree0bb0bd9c9540569e493c1bb0fce52882668f4471
parent9f6f6a2c267119f26ea4c3bbef1e0c98796b743c (diff)
downloadATCD-f0147d905fa21738ab7efe630b7448d6c2eac35b.tar.gz
*** empty log message ***
-rw-r--r--TAO/ChangeLog20
-rw-r--r--TAO/orbsvcs/orbsvcs/CSI.idl201
-rw-r--r--TAO/orbsvcs/orbsvcs/CSIIOP.idl152
-rw-r--r--TAO/orbsvcs/orbsvcs/CSIv2/CSI_Utils.cpp66
-rw-r--r--TAO/orbsvcs/orbsvcs/CSIv2/CSI_Utils.h49
-rw-r--r--TAO/orbsvcs/orbsvcs/CSIv2/CSS_ORBInitializer.cpp41
-rw-r--r--TAO/orbsvcs/orbsvcs/CSIv2/CSS_ORBInitializer.h73
-rw-r--r--TAO/orbsvcs/orbsvcs/CSIv2/CSS_RequestInterceptor.cpp245
-rw-r--r--TAO/orbsvcs/orbsvcs/CSIv2/CSS_RequestInterceptor.h109
-rw-r--r--TAO/orbsvcs/orbsvcs/CSIv2/TSS_IORInterceptor.cpp88
-rw-r--r--TAO/orbsvcs/orbsvcs/CSIv2/TSS_IORInterceptor.h101
-rw-r--r--TAO/orbsvcs/orbsvcs/CSIv2/TSS_ORBInitializer.cpp41
-rw-r--r--TAO/orbsvcs/orbsvcs/CSIv2/TSS_ORBInitializer.h73
-rw-r--r--TAO/orbsvcs/orbsvcs/CSIv2/TSS_RequestInterceptor.cpp381
-rw-r--r--TAO/orbsvcs/orbsvcs/CSIv2/TSS_RequestInterceptor.h126
-rw-r--r--TAO/orbsvcs/orbsvcs/GSSUP.idl63
16 files changed, 1829 insertions, 0 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog
index d5d5b985320..22d752fa38c 100644
--- a/TAO/ChangeLog
+++ b/TAO/ChangeLog
@@ -1,3 +1,23 @@
+Thu Aug 7 1:51:27 2003 <Ossama Othman <ossama@dre.vanderbilt.edu>>
+
+ * orbsvcs/orbsvcs/CSI.idl:
+ * orbsvcs/orbsvcs/CSIIOP.idl:
+ * orbsvcs/orbsvcs/GSSUP.idl:
+ * orbsvcs/orbsvcs/CSIv2/CSI_Utils.cpp:
+ * orbsvcs/orbsvcs/CSIv2/CSI_Utils.h:
+ * orbsvcs/orbsvcs/CSIv2/CSS_ORBInitializer.cpp:
+ * orbsvcs/orbsvcs/CSIv2/CSS_ORBInitializer.h:
+ * orbsvcs/orbsvcs/CSIv2/CSS_RequestInterceptor.cpp:
+ * orbsvcs/orbsvcs/CSIv2/CSS_RequestInterceptor.h:
+ * orbsvcs/orbsvcs/CSIv2/TSS_IORInterceptor.cpp:
+ * orbsvcs/orbsvcs/CSIv2/TSS_IORInterceptor.h:
+ * orbsvcs/orbsvcs/CSIv2/TSS_ORBInitializer.cpp:
+ * orbsvcs/orbsvcs/CSIv2/TSS_ORBInitializer.h:
+ * orbsvcs/orbsvcs/CSIv2/TSS_RequestInterceptor.cpp:
+ * orbsvcs/orbsvcs/CSIv2/TSS_RequestInterceptor.h:
+
+ New core CSIv2 implementation for TAO.
+
Thu Aug 7 12:06:13 2003 Ossama Othman <ossama@dre.vanderbilt.edu>
* tao/Object.h:
diff --git a/TAO/orbsvcs/orbsvcs/CSI.idl b/TAO/orbsvcs/orbsvcs/CSI.idl
new file mode 100644
index 00000000000..0847e2460d5
--- /dev/null
+++ b/TAO/orbsvcs/orbsvcs/CSI.idl
@@ -0,0 +1,201 @@
+// -*- IDL -*-
+
+//=============================================================================
+/**
+ * @file CSI.idl
+ *
+ * $Id$
+ *
+ * @author Object Management Group
+ */
+//=============================================================================
+
+
+#ifndef _CSI_IDL_
+#define _CSI_IDL_
+
+// #include <IOP.idl>
+#include <IOP_IOR.pidl>
+
+module IOP
+{
+ const ServiceId SecurityAttributeService = 15;
+};
+
+module CSI {
+ typeprefix CSI "omg.org";
+
+ // The OMG VMCID; same value as CORBA::OMGVMCID. Do not change ever.
+ const unsigned long OMGVMCID = 0x4F4D0;
+
+ // An X509CertificateChain contains an ASN.1 BER encoded SEQUENCE
+ // [1..MAX] OF X.509 certificates encapsulated in a sequence of octets. The
+ // subject's certificate shall come first in the list. Each following
+ // certificate shall directly certify the one preceding it. The ASN.1
+ // representation of Certificate is as defined in [IETF RFC 2459].
+ typedef sequence <octet> X509CertificateChain;
+
+ // an X.501 type name or Distinguished Name encapsulated in a sequence of
+ // octets containing the ASN.1 encoding.
+ typedef sequence <octet> X501DistinguishedName;
+
+ // UTF-8 Encoding of String
+ typedef sequence <octet> UTF8String;
+
+ // ASN.1 Encoding of an OBJECT IDENTIFIER
+ typedef sequence <octet> OID;
+ typedef sequence <OID> OIDList;
+
+ // A sequence of octets containing a GSStoken. Initial context tokens are
+ // ASN.1 encoded as defined in [IETF RFC 2743] Section 3.1,
+ // "Mechanism-Independent token Format", pp. 81-82. Initial context tokens
+ // contain an ASN.1 tag followed by a token length, a mechanism identifier,
+ // and a mechanism-specific token (i.e. a GSSUP::InitialContextToken). The
+ // encoding of all other GSS tokens (e.g. error tokens and final context
+ // tokens) is mechanism dependent.
+ typedef sequence <octet> GSSToken;
+
+ // An encoding of a GSS Mechanism-Independent Exported Name Object as
+ // defined in [IETF RFC 2743] Section 3.2, "GSS Mechanism-Independent
+ // Exported Name Object Format," p. 84.
+ typedef sequence <octet> GSS_NT_ExportedName;
+ typedef sequence <GSS_NT_ExportedName> GSS_NT_ExportedNameList;
+
+ // The MsgType enumeration defines the complete set of service context
+ // message types used by the CSI context management protocols, including
+ // those message types pertaining only to the stateful application of the
+ // protocols (to insure proper alignment of the identifiers between
+ // stateless and stateful implementations). Specifically, the
+ // MTMessageInContext is not sent by stateless clients (although it may
+ // be received by stateless targets).
+ typedef short MsgType;
+
+ const MsgType MTEstablishContext = 0;
+ const MsgType MTCompleteEstablishContext = 1;
+ const MsgType MTContextError = 4;
+ const MsgType MTMessageInContext = 5;
+
+ // The ContextId type is used carry session identifiers. A stateless
+ // application of the service context protocol is indicated by a session
+ // identifier value of 0.
+ typedef unsigned long long ContextId;
+
+ // The AuthorizationElementType defines the contents and encoding of
+ // the_element field of the AuthorizationElement.
+ // The high order 20-bits of each AuthorizationElementType constant
+ // shall contain the Vendor Minor Codeset ID (VMCID) of the
+ // organization that defined the element type. The low order 12 bits
+ // shall contain the organization-scoped element type identifier. The
+ // high-order 20 bits of all element types defined by the OMG shall
+ // contain the VMCID allocated to the OMG (that is, 0x4F4D0).
+ typedef unsigned long AuthorizationElementType;
+
+ // An AuthorizationElementType of X509AttributeCertChain indicates
+ // that the_element field of the AuthorizationElement contains an
+ // ASN.1 BER SEQUENCE composed of an (X.509) AttributeCertificate
+ // followed by a SEQUENCE OF (X.509) Certificate. The two-part
+ // SEQUENCE is encapsulated in an octet stream. The chain of
+ // identity certificates is provided to certify the attribute
+ // certificate. Each certificate in the chain shall directly certify
+ // the one preceding it. The first certificate in the chain shall
+ // certify the attribute certificate. The ASN.1 representation of
+ // (X.509) Certificate is as defined in [IETF RFC 2459]. The ASN.1
+ // representation of (X.509) AttributeCertificate is as defined in
+ // [IETF ID PKIXAC].
+ const AuthorizationElementType X509AttributeCertChain = OMGVMCID | 1;
+
+ typedef sequence <octet> AuthorizationElementContents;
+
+ // The AuthorizationElement contains one element of an authorization token.
+ // Each element of an authorization token is logically a PAC.
+ struct AuthorizationElement {
+ AuthorizationElementType the_type;
+ AuthorizationElementContents the_element;
+ };
+
+ // The AuthorizationToken is made up of a sequence of
+ // AuthorizationElements
+ typedef sequence <AuthorizationElement> AuthorizationToken;
+ typedef unsigned long IdentityTokenType;
+
+ // Additional standard identity token types shall only be defined by the
+ // OMG. All IdentityTokenType constants shall be a power of 2.
+ const IdentityTokenType ITTAbsent = 0;
+ const IdentityTokenType ITTAnonymous = 1;
+ const IdentityTokenType ITTPrincipalName = 2;
+ const IdentityTokenType ITTX509CertChain = 4;
+ const IdentityTokenType ITTDistinguishedName = 8;
+
+ typedef sequence <octet> IdentityExtension;
+
+ union IdentityToken switch ( IdentityTokenType ) {
+ case ITTAbsent: boolean absent;
+ case ITTAnonymous: boolean anonymous;
+ case ITTPrincipalName: GSS_NT_ExportedName principal_name;
+ case ITTX509CertChain: X509CertificateChain certificate_chain;
+ case ITTDistinguishedName: X501DistinguishedName dn;
+ default: IdentityExtension id;
+ };
+
+ struct EstablishContext {
+ ContextId client_context_id;
+ AuthorizationToken authorization_token;
+ IdentityToken identity_token;
+ GSSToken client_authentication_token;
+ };
+
+ struct CompleteEstablishContext {
+ ContextId client_context_id;
+ boolean context_stateful;
+ GSSToken final_context_token;
+ };
+
+ struct ContextError {
+ ContextId client_context_id;
+ long major_status;
+ long minor_status;
+ GSSToken error_token;
+ };
+
+ // Not sent by stateless clients. If received by a stateless server, a
+ // ContextError message should be returned, indicating the session does
+ // not exist.
+ struct MessageInContext {
+ ContextId client_context_id;
+ boolean discard_context;
+ };
+
+ union SASContextBody switch ( MsgType ) {
+ case MTEstablishContext: EstablishContext establish_msg;
+ case MTCompleteEstablishContext: CompleteEstablishContext
+ complete_msg;
+ case MTContextError: ContextError error_msg;
+ case MTMessageInContext: MessageInContext in_context_msg;
+ };
+
+ // The following type represents the string representation of an ASN.1
+ // OBJECT IDENTIFIER (OID). OIDs are represented by the string "oid:"
+ // followed by the integer base 10 representation of the OID separated
+ // by dots. For example, the OID corresponding to the OMG is represented
+ // as: "oid:2.23.130"
+ typedef string StringOID;
+
+ // The GSS Object Identifier for the KRB5 mechanism is:
+ // { iso(1) member-body(2) United States(840) mit(113554) infosys(1)
+ // gssapi(2) krb5(2) }
+ const StringOID KRB5MechOID = "oid:1.2.840.113554.1.2.2";
+
+ // The GSS Object Identifier for name objects of the Mechanism-independent
+ // Exported Name Object type is:
+ // { iso(1) org(3) dod(6) internet(1) security(5) nametypes(6)
+ // gss-api-exported-name(4) }
+ const StringOID GSS_NT_Export_Name_OID = "oid:1.3.6.1.5.6.4";
+
+ // The GSS Object Identifier for the scoped-username name form is:
+ // { iso-itu-t (2) international-organization (23) omg (130) security (1)
+ // naming (2) scoped-username(1) }
+ const StringOID GSS_NT_Scoped_Username_OID = "oid:2.23.130.1.2.1";
+
+}; // CSI
+
+#endif
diff --git a/TAO/orbsvcs/orbsvcs/CSIIOP.idl b/TAO/orbsvcs/orbsvcs/CSIIOP.idl
new file mode 100644
index 00000000000..ee3609bdc49
--- /dev/null
+++ b/TAO/orbsvcs/orbsvcs/CSIIOP.idl
@@ -0,0 +1,152 @@
+// -*- IDL -*-
+
+//=============================================================================
+/**
+ * @file CSIIOP.idl
+ *
+ * $Id$
+ *
+ * @author Object Management Group
+ */
+//=============================================================================
+
+#ifndef _CSIIOP_IDL_
+#define _CSIIOP_IDL_
+
+//#include <IOP.pidl>
+#include <IOP_IOR.pidl>
+#include <CSI.idl>
+//import ::IOP
+//import ::CSI
+
+module IOP
+{
+ const ComponentId TAG_CSI_SEC_MECH_LIST = 33;
+ const ComponentId TAG_NULL_TAG = 34;
+ const ComponentId TAG_SECIOP_SEC_TRANS = 35;
+ const ComponentId TAG_TLS_SEC_TRANS = 36;
+};
+
+module CSIIOP {
+ typeprefix CSIIOP "omg.org";
+
+ // Association options
+ typedef unsigned short AssociationOptions;
+
+ const AssociationOptions NoProtection = 1;
+ const AssociationOptions Integrity = 2;
+ const AssociationOptions Confidentiality = 4;
+ const AssociationOptions DetectReplay = 8;
+ const AssociationOptions DetectMisordering = 16;
+ const AssociationOptions EstablishTrustInTarget = 32;
+ const AssociationOptions EstablishTrustInClient = 64;
+ const AssociationOptions NoDelegation = 128;
+ const AssociationOptions SimpleDelegation = 256;
+ const AssociationOptions CompositeDelegation = 512;
+ const AssociationOptions IdentityAssertion = 1024;
+ const AssociationOptions DelegationByClient = 2048;
+
+ // The high order 20-bits of each ServiceConfigurationSyntax constant
+ // shall contain the Vendor Minor Codeset ID (VMCID) of the
+ // organization that defined the syntax. The low order 12 bits shall
+ // contain the organization-scoped syntax identifier. The high-order 20
+ // bits of all syntaxes defined by the OMG shall contain the VMCID
+ // allocated to the OMG (that is, 0x4F4D0).
+ typedef unsigned long ServiceConfigurationSyntax;
+
+ const ServiceConfigurationSyntax SCS_GeneralNames = CSI::OMGVMCID | 0;
+ const ServiceConfigurationSyntax SCS_GSSExportedName = CSI::OMGVMCID | 1;
+
+ typedef sequence <octet> ServiceSpecificName;
+
+ // The name field of the ServiceConfiguration structure identifies a
+ // privilege authority in the format identified in the syntax field. If the
+ // syntax is SCS_GeneralNames, the name field contains an ASN.1 (BER)
+ // SEQUENCE [1..MAX] OF GeneralName, as defined by the type GeneralNames in
+ // [IETF RFC 2459]. If the syntax is SCS_GSSExportedName, the name field
+ // contains a GSS exported name encoded according to the rules in
+ // [IETF RFC 2743] Section 3.2, "Mechanism-Independent Exported Name
+ // Object Format," p. 84.
+
+ struct ServiceConfiguration {
+ ServiceConfigurationSyntax syntax;
+ ServiceSpecificName name;
+ };
+
+ typedef sequence <ServiceConfiguration> ServiceConfigurationList;
+
+ // The body of the TAG_NULL_TAG component is a sequence of octets of
+ // length 0.
+ // type used to define AS layer functionality within a compound mechanism
+ // definition
+
+ struct AS_ContextSec {
+ AssociationOptions target_supports;
+ AssociationOptions target_requires;
+ CSI::OID client_authentication_mech;
+ CSI::GSS_NT_ExportedName target_name;
+ };
+
+ // type used to define SAS layer functionality within a compound mechanism
+ // definition
+
+ struct SAS_ContextSec {
+ AssociationOptions target_supports;
+ AssociationOptions target_requires;
+ ServiceConfigurationList privilege_authorities;
+ CSI::OIDList supported_naming_mechanisms;
+ CSI::IdentityTokenType supported_identity_types;
+ };
+
+ // type used in the body of a TAG_CSI_SEC_MECH_LIST component to
+ // describe a compound mechanism
+
+ struct CompoundSecMech {
+ AssociationOptions target_requires;
+ IOP::TaggedComponent transport_mech;
+ AS_ContextSec as_context_mech;
+ SAS_ContextSec sas_context_mech;
+ };
+
+ typedef sequence <CompoundSecMech> CompoundSecMechanisms;
+
+ // type corresponding to the body of a TAG_CSI_SEC_MECH_LIST
+ // component
+
+ struct CompoundSecMechList {
+ boolean stateful;
+ CompoundSecMechanisms mechanism_list;
+ };
+
+ struct TransportAddress {
+ string host_name;
+ unsigned short port;
+ };
+
+ typedef sequence <TransportAddress> TransportAddressList;
+
+ // Tagged component for configuring SECIOP as a CSIv2 transport mechanism
+
+ const IOP::ComponentId TAG_SECIOP_SEC_TRANS = 35;
+
+ struct SECIOP_SEC_TRANS {
+ AssociationOptions target_supports;
+ AssociationOptions target_requires;
+ CSI::OID mech_oid;
+ CSI::GSS_NT_ExportedName target_name;
+ TransportAddressList addresses;
+ };
+
+ // tagged component for configuring TLS/SSL as a CSIv2 transport mechanism
+
+ const IOP::ComponentId TAG_TLS_SEC_TRANS = 36;
+
+ struct TLS_SEC_TRANS {
+ AssociationOptions target_supports;
+ AssociationOptions target_requires;
+ TransportAddressList addresses;
+ };
+
+}; //CSIIOP
+
+#endif
diff --git a/TAO/orbsvcs/orbsvcs/CSIv2/CSI_Utils.cpp b/TAO/orbsvcs/orbsvcs/CSIv2/CSI_Utils.cpp
new file mode 100644
index 00000000000..8e9c5b72870
--- /dev/null
+++ b/TAO/orbsvcs/orbsvcs/CSIv2/CSI_Utils.cpp
@@ -0,0 +1,66 @@
+// $Id$
+
+#include "CSI_Utils.h"
+#include "orbsvcs/CSIC.h"
+
+
+ACE_RCSID (CSIv2,
+ CSI_Utils,
+ "$Id$")
+
+
+void
+TAO::CSI_Utils:create_sas_service_context (
+ const CSI::SASContextBody & sas_context,
+ IOP::ServiceContext & sc)
+{
+ // Marshal CSI::SASContextBody union into an octet sequence suitable
+ // for placement in an IOP::ServiceContext.
+ // (TAO's compiled marshaling is used for performance reasons.)
+
+ TAO_OutputCDR cdr;
+ cdr << TAO_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER);
+
+ cdr << sas_context;
+
+ sc.context_id = IOP::SecurityAttributeService;
+
+ // TAO extension, replace the contents of the octet sequence with
+ // the CDR stream.
+ const CORBA::ULong len = cdr.total_length ();
+ sc.context_data.length (len);
+ CORBA::Octet * buf = sc.context_data.get_buffer ();
+ for (const ACE_Message_Block * i = cdr.begin ();
+ i != 0;
+ i = i->cont ())
+ {
+ ACE_OS::memcpy (buf, i->rd_ptr (), i->length ());
+ buf += i->length ();
+ }
+}
+
+int
+TAO::CSI_Utils::extract_sas_service_context (
+ const IOP::ServiceContext & sc,
+ CSI::SASContextBody & sas_context)
+{
+ // Demarshal CSI::SASContextBody union from ServiceContext.
+ // (TAO's compiled marshaling is used for performance reasons.)
+
+ TAO_InputCDR cdr (ACE_reinterpret_cast (
+ const char*,
+ sc.context_data.get_buffer ()),
+ sc.context_data.length ());
+
+ CORBA::Boolean byte_order;
+
+ if (!(cdr >> ACE_InputCDR::to_boolean (byte_order)))
+ return 0;
+
+ cdr.reset_byte_order (ACE_static_cast (int, byte_order));
+
+ if (!(cdr >> sas_context))
+ return 0;
+
+ return 1;
+}
diff --git a/TAO/orbsvcs/orbsvcs/CSIv2/CSI_Utils.h b/TAO/orbsvcs/orbsvcs/CSIv2/CSI_Utils.h
new file mode 100644
index 00000000000..038e6523979
--- /dev/null
+++ b/TAO/orbsvcs/orbsvcs/CSIv2/CSI_Utils.h
@@ -0,0 +1,49 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file CSI_Util.h
+ *
+ * $Id$
+ *
+ * @author Ossama Othman <ossama@dre.vanderbilt.edu>
+ */
+//=============================================================================
+
+
+#ifndef TAO_CSI_UTILS_H
+#define TAO_CSI_UTILS_H
+
+// No need to include "ace/pre.h" and "ace/post.h". This header and
+// the declared types/variables are not meant to be used outside TAO's
+// CSIv2 implementation.
+
+// Forward declarations
+namespace IOP
+{
+ class ServiceContext;
+}
+
+namespace CSI
+{
+ class SASContextBody;
+}
+
+namespace TAO
+{
+ namespace CSI_Util
+ {
+ /// Populate given IOP::ServiceContext with given CSI::SASContextBody.
+ void create_sas_service_context (const CSI::SASContextBody & sas_context,
+ IOP::ServiceContext & sc);
+
+ /// Extract CSI::SASContextBody from given IOP::ServiceContext.
+ /**
+ * @return Success == 1, Failure == 0.
+ */
+ int extract_sas_service_context (const IOP::ServiceContext & sc,
+ CSI::SASContextBody & sas_context);
+ }
+}
+
+#endif /* TAO_CSI_UTILS_H */
diff --git a/TAO/orbsvcs/orbsvcs/CSIv2/CSS_ORBInitializer.cpp b/TAO/orbsvcs/orbsvcs/CSIv2/CSS_ORBInitializer.cpp
new file mode 100644
index 00000000000..97cd9ed975a
--- /dev/null
+++ b/TAO/orbsvcs/orbsvcs/CSIv2/CSS_ORBInitializer.cpp
@@ -0,0 +1,41 @@
+// $Id$
+
+#include "CSS_ORBInitializer.h"
+#include "CSS_RequestInterceptor.h"
+
+
+ACE_RCSID (CSIv2,
+ CSS_ORBInitializer,
+ "$Id$")
+
+
+void
+TAO::CSS_ORBInitializer::pre_init (
+ PortableInterceptor::ORBInitInfo_ptr /* info */
+ ACE_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+}
+
+void
+TAO::CSS_ORBInitializer::post_init (
+ PortableInterceptor::ORBInitInfo_ptr info
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ PortableInterceptor::ClientRequestInterceptor_ptr i;
+ ACE_NEW_THROW_EX (i,
+ TAO::CSS_RequestInterceptor,
+ CORBA::NO_MEMORY (
+ CORBA::SystemException::_tao_minor_code (
+ TAO_DEFAULT_MINOR_CODE,
+ ENOMEM),
+ CORBA::COMPLETED_NO));
+ ACE_CHECK;
+
+ PortableInterceptor::ClientRequestInterceptor_var interceptor = i;
+
+ info->add_client_request_interceptor (interceptor.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+}
diff --git a/TAO/orbsvcs/orbsvcs/CSIv2/CSS_ORBInitializer.h b/TAO/orbsvcs/orbsvcs/CSIv2/CSS_ORBInitializer.h
new file mode 100644
index 00000000000..67389e41f37
--- /dev/null
+++ b/TAO/orbsvcs/orbsvcs/CSIv2/CSS_ORBInitializer.h
@@ -0,0 +1,73 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file CSS_ORBInitializer.h
+ *
+ * $Id$
+ *
+ * @author Ossama Othman <ossama@dre.vanderbilt.edu>
+ */
+//=============================================================================
+
+#ifndef TAO_CSS_ORB_INITIALIZER_H
+#define TAO_CSS_ORB_INITIALIZER_H
+
+#include "ace/config-all.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "tao/PortableInterceptorC.h"
+#include "tao/LocalObject.h"
+
+#if defined(_MSC_VER)
+#if (_MSC_VER >= 1200)
+#pragma warning(push)
+#endif /* _MSC_VER >= 1200 */
+#pragma warning(disable:4250)
+#endif /* _MSC_VER */
+
+namespace TAO
+{
+ /**
+ * @class CSS_ORBInitializer
+ *
+ * @brief TAO CSIv2 client side ORBInitializer.
+ *
+ * CSIv2 client security service (CSS) ORBInitializer that registers
+ * a CSS ClientRequestInterceptor with all ORBs.
+ */
+ class CSS_ORBInitializer
+ : public virtual PortableInterceptor::ORBInitializer,
+ public virtual TAO_Local_RefCounted_Object
+ {
+ public:
+
+ /**
+ * @name Methods Required by the ORBInitializer Interface
+ *
+ * These are methods that must be implemented since they are pure
+ * virtual in the abstract base class. They are the canonical
+ * methods required for all ORB initializers.
+ */
+ //@{
+ /// The pre-initialization hook.
+ virtual void pre_init (PortableInterceptor::ORBInitInfo_ptr info
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ /// The post-initialization hook.
+ virtual void post_init (PortableInterceptor::ORBInitInfo_ptr info
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+ //@}
+ };
+} // End TAO namespace
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1200)
+#pragma warning(pop)
+#endif /* _MSC_VER */
+
+#endif /* TAO_CSS_ORB_INITIALIZER_H */
diff --git a/TAO/orbsvcs/orbsvcs/CSIv2/CSS_RequestInterceptor.cpp b/TAO/orbsvcs/orbsvcs/CSIv2/CSS_RequestInterceptor.cpp
new file mode 100644
index 00000000000..f9293a85c25
--- /dev/null
+++ b/TAO/orbsvcs/orbsvcs/CSIv2/CSS_RequestInterceptor.cpp
@@ -0,0 +1,245 @@
+#include "CSS_RequestInterceptor.h"
+#include "CSI_Utils.h"
+
+
+ACE_RCSID (CSIv2,
+ CSS_RequestInterceptor,
+ "$Id$")
+
+
+TAO::CSS_RequestInterceptor::CSS_RequestInterceptor (void)
+{
+}
+
+char *
+TAO::CSS_RequestInterceptor::name (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ return CORBA::string_dup ("TAO::CSS_RequestInterceptor");
+}
+
+void
+TAO::CSS_RequestInterceptor::destroy (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+}
+
+void
+TAO::CSS_RequestInterceptor::send_request (
+ PortableInterceptor::ClientRequestInfo_ptr info
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ PortableInterceptor::ForwardRequest))
+{
+
+ CSI::SASContextBody sas_context;
+
+ const CORBA::Boolean context_created =
+ this->get_sas_context_body (info,
+ sas_context
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+
+ ec.client_context_id = 0; // Stateless CSS
+ ec.authorization_token = /* Retrieve from ATLAS */;
+ ec.identity_token = /* A discriminated union. */;
+ ec.client_authentication_token = /* */;
+
+ sas_context.establish_msg (ec);
+
+ // Create IOP::ServiceContext containing CSI::SASContextBody union.
+ IOP::ServiceContext sc;
+
+ TAO::CSI_Utils::create_sas_service_context (sas_context, sc);
+
+ const CORBA::boolean replace = 0;
+
+ ri->add_request_service_context (service_context,
+ replace
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+}
+
+void
+TAO::CSS_RequestInterceptor::send_poll (
+ PortableInterceptor::ClientRequestInfo_ptr
+ ACE_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+}
+
+void
+TAO::CSS_RequestInterceptor::receive_reply (
+ PortableInterceptor::ClientRequestInfo_ptr info
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ CSI::SASContextBody sas_context;
+
+ // Extract CSI::ContextError structure from CSI::SASContextBody.
+ const CORBA::Boolean found_context_error =
+ this->extract_sas_context (info,
+ sas_context
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+
+ // If SAS message exists, check if a CSI::CompleteEstablishContext
+ // message was sent.
+ if (found_sas_context)
+ {
+ const CSI::MsgType msg_type = sas_context._d ();
+
+ switch (msg_type)
+ {
+ case CSI::MTCompleteEstablishContext: // Stateful CSS only.
+
+ const CSI::CompleteEstablishContext & cec =
+ sas_context.complete_msg ();
+
+ this->complete_context (cec.client_context_id,
+ cec.context_stateful);
+
+ break;
+
+ default:
+ // No other message types should be sent by a target
+ // security service in a normal reply.
+
+ // @@ What do we do in this case?
+ break;
+ }
+ }
+
+}
+
+void
+TAO::CSS_RequestInterceptor::receive_exception (
+ PortableInterceptor::ClientRequestInfo_ptr info
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ PortableInterceptor::ForwardRequest))
+{
+ CORBA::String_var id =
+ info->received_exception_id (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_CHECK;
+
+ // Repository ID of the CORBA::NO_PERMISSION exception
+ static const char no_permission[] =
+ "IDL:omg.org/CORBA/NO_PERMISSION:1.0";
+
+ // If we received a CORBA::NO_PERMISSION no exception, check if
+ // CSI::ContextError ServiceContext was placed in the reply
+ // ServiceContextList, and react accordingly.
+ if (ACE_OS::strcmp (id.in (), no_permission) == 0)
+ {
+ CSI::SASContextBody sas_context;
+
+ // Extract CSI::ContextError structure from CSI::SASContextBody.
+ const CORBA::Boolean found_sas_context =
+ this->extract_sas_context (info,
+ sas_context
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+
+ // If SAS message exists, handle CSI::ContextError messages
+ // accordingly.
+ if (found_sas_context)
+ {
+ const CSI::MsgType msg_type = sas_context._d ();
+
+ switch (msg_type)
+ {
+ case CSI::MTContextError:
+
+ const CSI::ContextError & ce = sas_context.error_msg ();
+
+ if (ce.minor == 1)
+ {
+ if (ce.major == 1) // Invalid evidence
+ {
+ // Re-collect authentication evidence and try
+ // again.
+ }
+ else if (ce.major == 3) // Conflicting evidence
+ {
+ // Stateful CSS only
+ this->invalidate_context (ce.client_context_id);
+
+ // Done. Allow the exception to propagate to
+ // the caller.
+ }
+ else if (ce.major == 4) // No context
+ {
+ // Stateful CSS only
+ this->invalidate_context (ce.client_context_id);
+
+ // @@ Restart invocation with new context.
+ }
+
+ // Don't do anything for the "invalid mechanism"
+ // case (i.e. major == 2). Just allow the exception
+ // to propagate to the caller.
+ }
+
+ break;
+
+ default:
+ // No other message types should be sent by a target
+ // security service. Just allow the exception to
+ // propagate to the caller.
+ break;
+ }
+ }
+ }
+}
+
+void
+TAO::CSS_RequestInterceptor::receive_other (
+ PortableInterceptor::ClientRequestInfo_ptr
+ ACE_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ PortableInterceptor::ForwardRequest))
+{
+ // No need to anything for the oneway and LOCATION_FORWARD case.
+}
+
+CORBA::Boolean
+TAO::TSS_RequestInterceptor::extract_sas_context (
+ PortableInterceptor::ServerRequestInfo_ptr info,
+ CSI::SASContextBody & sas_context
+ ACE_ENV_ARG_DECL)
+{
+ IOP::ServiceContext_var sc;
+
+ ACE_TRY
+ {
+ sc = info->get_reply_service_context (IOP::SecurityAttributeService
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ }
+ ACE_CATCH (CORBA::BAD_PARAM, ex)
+ {
+ if (ex.minor () == (CORBA::OMGVMCID | 26))
+ return 0;
+ else
+ ACE_RE_THROW;
+ }
+ ACE_ENDTRY;
+ ACE_CHECK_RETURN (0);
+
+ if (sc->context_id != IOP::SecurityAttributeService)
+ {
+ // Invalid ServiceId. The server apparently botched the
+ // ServiceContext corresponding to the CSI::SASContextBody.
+ //
+ // @@ Correct exception?
+ ACE_THROW_RETURN (CORBA::BAD_PARAM (), 0);
+ }
+
+ // Extract CSI::SASContextBody from given IOP::ServiceContext.
+ if (!TAO::CSI_Utils::extract_sas_service_context (sc.in (),
+ sas_context))
+ ACE_THROW_RETURN (CORBA::MARSHAL (), 0);
+
+ return 1; // Successfully extracted CSI::SASContextBody.
+}
diff --git a/TAO/orbsvcs/orbsvcs/CSIv2/CSS_RequestInterceptor.h b/TAO/orbsvcs/orbsvcs/CSIv2/CSS_RequestInterceptor.h
new file mode 100644
index 00000000000..21288770eeb
--- /dev/null
+++ b/TAO/orbsvcs/orbsvcs/CSIv2/CSS_RequestInterceptor.h
@@ -0,0 +1,109 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file CSS_RequestInterceptor.h
+ *
+ * $Id$
+ *
+ * Implementation header for the client request interceptor for the
+ * Security Attribute Service (client side).
+ *
+ * @author Ossama Othman <ossama@dre.vanderbilt.edu>
+ */
+//=============================================================================
+
+
+#ifndef TAO_CSS_REQUEST_INTERCEPTOR_H
+#define TAO_CSS_REQUEST_INTERCEPTOR_H
+
+#include "ace/pre.h"
+#include "orbsvcs/Security/security_export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "tao/PortableInterceptorC.h"
+#include "tao/LocalObject.h"
+
+#if defined(_MSC_VER)
+#if (_MSC_VER >= 1200)
+#pragma warning(push)
+#endif /* _MSC_VER >= 1200 */
+#pragma warning(disable:4250)
+#endif /* _MSC_VER */
+
+
+namespace TAO
+{
+ /**
+ * @class CSS_RequestInterceptor
+ *
+ * @brief Client Security Service (CSS) client request interceptor.
+ *
+ * This client request interceptor implements Security Attribute
+ * Service functionality of the Client Security Service.
+ */
+ class TAO_Security_Export CSS_RequestInterceptor
+ : public virtual PortableInterceptor::ClientRequestInterceptor,
+ public virtual TAO_Local_RefCounted_Object
+ {
+ public:
+
+ /// Constructor.
+ CSS_Requestinterceptor (void);
+
+ /**
+ * @name Methods Required by the Client Request Interceptor
+ * Interface
+ *
+ * These are methods that must be implemented since they are pure
+ * virtual in the abstract base class. They are the canonical
+ * methods required for all client request interceptors.
+ */
+ //@{
+ /// Return the name of this ClientRequestinterceptor.
+ virtual char * name (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ virtual void destroy (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ virtual void send_request (PortableInterceptor::ClientRequestInfo_ptr ri
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ PortableInterceptor::ForwardRequest));
+
+ virtual void send_poll (PortableInterceptor::ClientRequestInfo_ptr ri
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ virtual void receive_reply (PortableInterceptor::ClientRequestInfo_ptr ri
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ virtual void receive_exception (
+ PortableInterceptor::ClientRequestInfo_ptr ri
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ PortableInterceptor::ForwardRequest));
+
+ virtual void receive_other (PortableInterceptor::ClientRequestInfo_ptr ri
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ PortableInterceptor::ForwardRequest));
+ //@}
+
+ };
+
+} // End TAO namespace
+
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1200)
+#pragma warning(pop)
+#endif /* _MSC_VER */
+
+#include "ace/post.h"
+
+#endif /* TAO_CSS_REQUEST_INTERCEPTOR_H */
diff --git a/TAO/orbsvcs/orbsvcs/CSIv2/TSS_IORInterceptor.cpp b/TAO/orbsvcs/orbsvcs/CSIv2/TSS_IORInterceptor.cpp
new file mode 100644
index 00000000000..95e6259e2e5
--- /dev/null
+++ b/TAO/orbsvcs/orbsvcs/CSIv2/TSS_IORInterceptor.cpp
@@ -0,0 +1,88 @@
+// $Id$
+
+
+#include "TSS_IORInterceptor.h"
+
+
+ACE_RCSID (CSIv2,
+ TSS_IORInterceptor,
+ "$Id$")
+
+
+TAO::TSS_IORInterceptor::TSS_IORInterceptor (void)
+{
+}
+
+char *
+TAO::TSS_IORInterceptor::name (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ return CORBA::string_dup ("TAO::TSS_IORInterceptor");
+}
+
+void
+TAO::TSS_IORInterceptor::destroy (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+}
+
+void
+TAO::TSS_IORInterceptor::establish_components (
+ PortableInterceptor::IORInfo_ptr info
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ IOP::TaggedComponent tc;
+
+ tc.component_id = IOP::TAG_CSI_SEC_MECH_LIST;
+
+ CSIIOP::CompoundSecMechList component;
+
+ component.stateful = 0; // Only stateless TSS currently supported.
+
+ CSIIOP::CompoundSecMechanisms & mechanisms = component.mechanisms;
+
+ // Only SSLIOP is supported at this point in time.
+ mechanisms.length (1);
+
+ CSIIOP::CompoundSecMech & mech = mechanisms[0];
+
+ mech.target_requires =
+ CSIIOP::Security::Integrity
+ | Security::Confidentiality
+ mech.transport_mech;
+ mech.as_context_mech;
+ mech.sas_context_mech;
+
+ // TAO currently only supports CSIv2 over IIOP.
+ info->add_ior_component_to_profile (component,
+ IOP::TAG_INTERNET_IOP
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+}
+
+void
+TAO::TSS_IORInterceptor::components_established (
+ PortableInterceptor::IORInfo_ptr
+ ACE_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+}
+
+void
+TAO::TSS_IORInterceptor::adapter_manager_state_changed (
+ PortableInterceptor::AdapterManagerId,
+ PortableInterceptor::AdapterState
+ ACE_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+}
+
+void
+TAO::TSS_IORInterceptor::adapter_state_changed (
+ const PortableInterceptor::ObjectReferenceTemplateSeq &,
+ PortableInterceptor::AdapterState
+ ACE_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+}
diff --git a/TAO/orbsvcs/orbsvcs/CSIv2/TSS_IORInterceptor.h b/TAO/orbsvcs/orbsvcs/CSIv2/TSS_IORInterceptor.h
new file mode 100644
index 00000000000..515b6f5ce68
--- /dev/null
+++ b/TAO/orbsvcs/orbsvcs/CSIv2/TSS_IORInterceptor.h
@@ -0,0 +1,101 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file TSS_IORInterceptor.h
+ *
+ * $Id$
+ *
+ * @author Ossama Othman <ossama@dre.vanderbilt.edu>
+ */
+//=============================================================================
+
+#ifndef TAO_TSS_IOR_INTERCEPTOR_H
+#define TAO_TSS_IOR_INTERCEPTOR_H
+
+#include "ace/config-all.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "tao/IORInterceptor/IORInterceptorC.h"
+#include "tao/PortableInterceptorC.h"
+#include "tao/LocalObject.h"
+
+#if defined(_MSC_VER)
+#if (_MSC_VER >= 1200)
+#pragma warning(push)
+#endif /* _MSC_VER >= 1200 */
+#pragma warning(disable:4250)
+#endif /* _MSC_VER */
+
+
+namespace TAO
+{
+ /**
+ * @class TSS_IORInterceptor
+ *
+ * @brief IOR interceptor that adds CSIv2 tagged components to an
+ * object reference.
+ *
+ * This IOR interceptor embeds a CSIv2 tagged component in an object
+ * reference.
+ */
+ class TSS_IORInterceptor
+ : public virtual PortableInterceptor::IORInterceptor,
+ public virtual TAO_Local_RefCounted_Object
+ {
+ public:
+
+ /// Constructor
+ TSS_IORInterceptor (void);
+
+ /**
+ * @name Methods Required by the IOR Interceptor Interface
+ *
+ * These are methods that must be implemented since they are pure
+ * virtual in the abstract base class. They are the canonical
+ * methods required for all IOR interceptors.
+ */
+ //@{
+ /// Return the name of this IORInterceptor.
+ virtual char * name (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ /// Cleanup resources acquired by this IORInterceptor.
+ virtual void destroy (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ /// Add the tagged components to the IOR.
+ virtual void establish_components (PortableInterceptor::IORInfo_ptr info
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ virtual void components_established (PortableInterceptor::IORInfo_ptr info
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ virtual void adapter_manager_state_changed (
+ PortableInterceptor::AdapterManagerId id,
+ PortableInterceptor::AdapterState state
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ virtual void adapter_state_changed (
+ const PortableInterceptor::ObjectReferenceTemplateSeq & templates,
+ PortableInterceptor::AdapterState state
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+ //@}
+
+ };
+
+} // End TAO namespace
+
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1200)
+#pragma warning(pop)
+#endif /* _MSC_VER */
+
+#endif /* TAO_TSS_IOR_INTERCEPTOR_H */
diff --git a/TAO/orbsvcs/orbsvcs/CSIv2/TSS_ORBInitializer.cpp b/TAO/orbsvcs/orbsvcs/CSIv2/TSS_ORBInitializer.cpp
new file mode 100644
index 00000000000..5a77232971f
--- /dev/null
+++ b/TAO/orbsvcs/orbsvcs/CSIv2/TSS_ORBInitializer.cpp
@@ -0,0 +1,41 @@
+// $Id$
+
+#include "TSS_ORBInitializer.h"
+#include "TSS_RequestInterceptor.h"
+
+
+ACE_RCSID (CSIv2,
+ TSS_ORBInitializer,
+ "$Id$")
+
+
+void
+TAO::TSS_ORBInitializer::pre_init (
+ PortableInterceptor::ORBInitInfo_ptr /* info */
+ ACE_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+}
+
+void
+TAO::TSS_ORBInitializer::post_init (
+ PortableInterceptor::ORBInitInfo_ptr info
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ PortableInterceptor::ServerRequestInterceptor_ptr i;
+ ACE_NEW_THROW_EX (i,
+ TAO::TSS_RequestInterceptor,
+ CORBA::NO_MEMORY (
+ CORBA::SystemException::_tao_minor_code (
+ TAO_DEFAULT_MINOR_CODE,
+ ENOMEM),
+ CORBA::COMPLETED_NO));
+ ACE_CHECK;
+
+ PortableInterceptor::ServerRequestInterceptor_var interceptor = i;
+
+ info->add_server_request_interceptor (interceptor.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+}
diff --git a/TAO/orbsvcs/orbsvcs/CSIv2/TSS_ORBInitializer.h b/TAO/orbsvcs/orbsvcs/CSIv2/TSS_ORBInitializer.h
new file mode 100644
index 00000000000..7400749a814
--- /dev/null
+++ b/TAO/orbsvcs/orbsvcs/CSIv2/TSS_ORBInitializer.h
@@ -0,0 +1,73 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file TSS_ORBInitializer.h
+ *
+ * $Id$
+ *
+ * @author Ossama Othman <ossama@dre.vanderbilt.edu>
+ */
+//=============================================================================
+
+#ifndef TAO_TSS_ORB_INITIALIZER_H
+#define TAO_TSS_ORB_INITIALIZER_H
+
+#include "ace/config-all.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "tao/PortableInterceptorC.h"
+#include "tao/LocalObject.h"
+
+#if defined(_MSC_VER)
+#if (_MSC_VER >= 1200)
+#pragma warning(push)
+#endif /* _MSC_VER >= 1200 */
+#pragma warning(disable:4250)
+#endif /* _MSC_VER */
+
+namespace TAO
+{
+ /**
+ * @class TSS_ORBInitializer
+ *
+ * @brief TAO CSIv2 server side ORBInitializer.
+ *
+ * CSIv2 target security service (TSS) ORBInitializer that registers
+ * a TSS ServerRequestInterceptor with all ORBs.
+ */
+ class TSS_ORBInitializer
+ : public virtual PortableInterceptor::ORBInitializer,
+ public virtual TAO_Local_RefCounted_Object
+ {
+ public:
+
+ /**
+ * @name Methods Required by the ORBInitializer Interface
+ *
+ * These are methods that must be implemented since they are pure
+ * virtual in the abstract base class. They are the canonical
+ * methods required for all ORB initializers.
+ */
+ //@{
+ /// The pre-initialization hook.
+ virtual void pre_init (PortableInterceptor::ORBInitInfo_ptr info
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ /// The post-initialization hook.
+ virtual void post_init (PortableInterceptor::ORBInitInfo_ptr info
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+ //@}
+ };
+} // End TAO namespace
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1200)
+#pragma warning(pop)
+#endif /* _MSC_VER */
+
+#endif /* TAO_TSS_ORB_INITIALIZER_H */
diff --git a/TAO/orbsvcs/orbsvcs/CSIv2/TSS_RequestInterceptor.cpp b/TAO/orbsvcs/orbsvcs/CSIv2/TSS_RequestInterceptor.cpp
new file mode 100644
index 00000000000..6379aba12ad
--- /dev/null
+++ b/TAO/orbsvcs/orbsvcs/CSIv2/TSS_RequestInterceptor.cpp
@@ -0,0 +1,381 @@
+#include "TSS_RequestInterceptor.h"
+#include "CSI_Utils.h"
+
+
+ACE_RCSID (CSIv2,
+ TSS_RequestInterceptor,
+ "$Id$")
+
+
+char *
+TAO::TSS_RequestInterceptor::name (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ return CORBA::string_dup ("TAO::TSS_RequestInterceptor");
+}
+
+void
+TAO::TSS_RequestInterceptor::destroy (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+}
+
+void
+TAO::TSS_RequestInterceptor::receive_request_service_contexts (
+ PortableInterceptor::ServerRequestInfo_ptr info
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ PortableInterceptor::ForwardRequest))
+{
+ CSI::SASContextBody sas_context;
+
+ // Extract CSI::SASContextBody union from IOP::ServiceContext.
+ const CORBA::Boolean found_sas_context =
+ this->extract_sas_context (info,
+ sas_context
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+
+ // If SAS message exists, handle it accordingly.
+ if (found_sas_context)
+ {
+ const CORBA::Boolean oneway =
+ info->response_expected (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_CHECK;
+
+ const CSI::MsgType msg_type = sas_context._d ();
+
+ switch (msg_type)
+ {
+ case CSI::MTEstablishContext:
+ CORBA::Boolean stateful;
+
+ if (!this->accept_context (info,
+ oneway,
+ sas_context.establish_msg (),
+ stateful))
+ ACE_THROW (CORBA::NO_PERMISSION ());
+
+ // Success!
+
+ // Only add CSI::CompleteEstablishContext to
+ // ServiceContextList for twoway calls, i.e those that
+ // expect a response. Don't bother for oneway calls. This
+ // is merely an optimization.
+ if (!oneway)
+ {
+ this->add_complete_establish_context (info,
+ ec.client_context_id,
+ stateful,
+ final_context_token
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+ }
+
+ break;
+
+ case CSI::MTMessageInContext:
+ const CSI::MessageInContext & mic = sas_context.in_context_msg ();
+
+ // @@ We should be revalidating/reauthenticating the
+ // identity of the client, right?
+ context = this->reference_context (mic.client_context_id);
+
+ // Only add CSI::ContextError to ServiceContextList for
+ // twoway calls, i.e those that expect a response. Don't
+ // bother for oneway calls. This is merely an
+ // optimization.
+ if (context is empty
+ && !oneway)
+ {
+ // Major and minor codes for "no context" ContextError.
+ const CORBA::Long major = 4;
+ const CORBA::Long minor = 1;
+
+ this->add_context_error (mic.client_context_id,
+ major,
+ minor,
+ error_token
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+
+ ACE_THROW (CORBA::NO_PERMISSION ());
+ }
+
+ // @@ Should this be done in the send_reply() interception
+ // point?
+ // @@ I don't think that's necessary.
+ if (mic.discard_context)
+ this->discard_context (mic.client_context_id);
+
+ break;
+
+ default:
+ // ContextError?
+ // No other message types should be sent by a client security
+ // service.
+ ACE_THROW (CORBA::NO_PERMISSION ());
+ break;
+ }
+ }
+
+ // No SAS message. Verify that the transport layer security
+ // context satisfies the target object security requirements.
+ else if (!this->accept_transport_context ())
+ ACE_THROW (CORBA::NO_PERMISSION ());
+
+ // Success!
+}
+
+void
+TAO::TSS_RequestInterceptor::receive_request (
+ PortableInterceptor::ServerRequestInfo_ptr info
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ PortableInterceptor::ForwardRequest))
+{
+}
+
+void
+TAO::TSS_RequestInterceptor::send_reply (
+ PortableInterceptor::ServerRequestInfo_ptr
+ ACE_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+}
+
+void
+TAO::TSS_RequestInterceptor::send_exception (
+ PortableInterceptor::ServerRequestInfo_ptr
+ ACE_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ PortableInterceptor::ForwardRequest))
+{
+}
+
+void
+TAO::TSS_RequestInterceptor::send_other (
+ PortableInterceptor::ServerRequestInfo_ptr
+ ACE_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ PortableInterceptor::ForwardRequest))
+{
+}
+
+CORBA::Boolean
+TAO::TSS_RequestInterceptor::accept_transport_context (void)
+{
+ /**
+ * @todo Query the transport layer.
+ */
+
+ return 1; // Context accepted.
+}
+
+CORBA::Boolean
+TAO::TSS_RequestInterceptor::accept_context (
+ PortableInterceptor::ServerRequestInfo_ptr info,
+ CORBA::Boolean oneway,
+ const CSI::EstablishContext & ec,
+ CORBA::Boolean & stateful
+ ACE_ENV_ARG_PARAMETER)
+{
+ ErrorCode error_code = /**/;
+
+ // Only add CSI::ContextError to ServiceContextList for twoway
+ // calls, i.e those that expect a response. Don't bother for oneway
+ // calls. This is merely an optimization.
+ if (!oneway && error_code != NONE)
+ {
+ // The CSI::ContextError major and minor status codes are
+ // defined in Section 24.3.5 in Secure Interoperability chapter
+ // of the core CORBA specification.
+ CORBA::Long major = 0;
+ CORBA::Long minor = 1;
+
+ // The "no context" error code should never occur when a context
+ // is being established. It should only occur after a context
+ // has been established in a stateful Target Security
+ // Service case.
+ ACE_ASSERT (error_code != NO_CONTEXT);
+
+ if (error_code == INVALID_EVIDENCE)
+ {
+ major = 1;
+ }
+ else if (error_code == CONFLICTING_EVIDENCE)
+ {
+ major = 2;
+ }
+ else if (error_code == INVALID_MECHANISM)
+ {
+ major = 3;
+ }
+ else if (error_code == POLICY_CHANGE)
+ {
+ ACE_THROW_RETURN (PortableInterceptor::ForwardRequest (),
+ 0);
+ }
+
+ this->add_context_error (ec.client_context_id,
+ major,
+ minor,
+ error_token
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (0);
+
+ return 0;
+ }
+
+ if (ec.client_context_id == 0)
+ stateful = 0; // Do not establish stateful context for clients
+ // that request a stateless one.
+ else
+ stateful = 0; // TAO TSS isn't stateful yet.
+
+ return 1; // Context accepted.
+}
+
+void
+TAO::TSS_RequestInterceptor::reference_context (CSI::ContextId context_id)
+{
+
+}
+
+void
+TAO::TSS_RequestInterceptor::discard_context (CSI::ContextId context_id)
+{
+}
+
+CORBA::Boolean
+TAO::TSS_RequestInterceptor::extract_sas_context (
+ PortableInterceptor::ServerRequestInfo_ptr info,
+ CSI::SASContextBody & sas_context
+ ACE_ENV_ARG_DECL)
+{
+ IOP::ServiceContext_var sc;
+
+ ACE_TRY
+ {
+ sc = info->get_request_service_context (IOP::SecurityAttributeService
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ }
+ ACE_CATCH (CORBA::BAD_PARAM, ex)
+ {
+ if (ex.minor () == (CORBA::OMGVMCID | 26))
+ return 0;
+ else
+ ACE_RE_THROW;
+ }
+ ACE_ENDTRY;
+ ACE_CHECK_RETURN (0);
+
+ if (sc->context_id != IOP::SecurityAttributeService)
+ {
+ // Invalid ServiceId. The client apparently botched the
+ // ServiceContext corresponding to the CSI::SASContextBody.
+ //
+ // @@ Correct exception? If so, should ContextError be added to
+ // the exception reply ServiceContextList.
+ ACE_THROW_RETURN (CORBA::NO_PERMISSION (), 0);
+ }
+
+ // Extract CSI::SASContextBody from given IOP::ServiceContext.
+ if (!TAO::CSI_Utils::extract_sas_service_context (sc.in (),
+ sas_context))
+ ACE_THROW_RETURN (CORBA::MARSHAL (), 0);
+
+ return 1; // Successfully extracted CSI::SASContextBody.
+}
+
+void
+TAO::TSS_RequestInterceptor::add_complete_establish_context (
+ PortableInterceptor::ServerRequestInfo_ptr info,
+ CSI::ContextId client_context_id,
+ CORBA::Boolean context_stateful,
+ CSI::GSSToken & final_context_token
+ ACE_ENV_ARG_DECL)
+{
+ CSI::CompleteEstablishContext cec;
+
+ cec.client_context_id = client_context_id;
+ cec.context_stateful = context_stateful;
+
+ const CORBA::Boolean release = 0; // Do not claim ownership of
+ // final context token sequence
+ // buffer.
+
+ // To improve performance, shallow copy the final context token
+ // octet sequence. This is fine since the sequence will not be
+ // modified. It will merely be copied into the reply
+ // ServiceContextList.
+ cec.final_context_token.replace (final_context_token.maximum (),
+ final_context_token.length (),
+ final_context_token.get_buffer (),
+ release);
+
+ CSI::SASContextBody sas_context;
+ sas_context.complete_msg (cec);
+
+ this->add_sas_context (info,
+ sas_context
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+}
+
+void
+TAO::TSS_RequestInterceptor::add_context_error (
+ PortableInterceptor::ServerRequestInfo_ptr info,
+ CSI::ContextId context_id,
+ CORBA::Long major,
+ CORBA::Long minor,
+ CSI::GSSToken & error_token
+ ACE_ENV_ARG_DECL)
+{
+ CSI::ContextError context_error;
+
+ context_error.client_context_id = context_id;
+ context_error.major_status = major;
+ context_error.minor_status = minor;
+
+ const CORBA::Boolean release = 0; // Do not claim ownership of
+ // error token sequence buffer.
+
+ // To improve performance, shallow copy the error token octet
+ // sequence. This is fine since the sequence will not be modified.
+ // It will merely be copied into the reply ServiceContextList.
+ context_error.error_token.replace (error_token.maximum (),
+ error_token.length (),
+ error_token.get_buffer (),
+ release);
+
+ CSI::SASContextBody sas_context;
+ sas_context.error_msg (context_error);
+
+ this->add_sas_context (info,
+ sas_context
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+}
+
+void
+TAO::TSS_RequestInterceptor::add_sas_context (
+ PortableInterceptor::ServerRequestInfo_ptr info,
+ const CSI::SASContextBody & sas_context
+ ACE_ENV_ARG_DECL)
+{
+ // Create IOP::ServiceContext containing CSI::SASContextBody union.
+ IOP::ServiceContext sc;
+
+ TAO::CSI_Util::create_sas_service_context (sas, sc);
+
+ // Another IOP::SecurityAttributeService ServiceContext should not
+ // exist in the reply's ServiceContextList.
+ const CORBA::Boolean replace = 0;
+
+ info->add_reply_service_context (sc,
+ replace
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+}
diff --git a/TAO/orbsvcs/orbsvcs/CSIv2/TSS_RequestInterceptor.h b/TAO/orbsvcs/orbsvcs/CSIv2/TSS_RequestInterceptor.h
new file mode 100644
index 00000000000..42cb7ea4acb
--- /dev/null
+++ b/TAO/orbsvcs/orbsvcs/CSIv2/TSS_RequestInterceptor.h
@@ -0,0 +1,126 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file TSS_RequestInterceptor.h
+ *
+ * $Id$
+ *
+ * Implementation header for the server request interceptor for the
+ * Security Attribute Service (server side).
+ *
+ * @author Ossama Othman <ossama@dre.vanderbilt.edu>
+ */
+//=============================================================================
+
+#ifndef TAO_TSS_REQUEST_INTERCEPTOR_H
+#define TAO_TSS_REQUEST_INTERCEPTOR_H
+
+#include "ace/pre.h"
+#include "orbsvcs/Security/security_export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "tao/LocalObject.h"
+
+#if defined(_MSC_VER)
+#if (_MSC_VER >= 1200)
+#pragma warning(push)
+#endif /* _MSC_VER >= 1200 */
+#pragma warning(disable:4250)
+#endif /* _MSC_VER */
+
+namespace TAO
+{
+ /**
+ * @class TSS_RequestInterceptor
+ *
+ * @brief Target Security Service (TSS) server request interceptor.
+ *
+ * This server request interceptor implements Security Attribute
+ * Service functionality of the Target Security Service.
+ */
+ class TAO_Security_Export TSS_RequestInterceptor
+ : public virtual PortableInterceptor::ServerRequestInterceptor,
+ public virtual TAO_Local_RefCounted_Object
+ {
+ public:
+
+ /**
+ * Error codes used within a ContextError service context.
+ */
+ typedef enum
+ {
+ NONE,
+ INVALID_EVIDENCE, // Major = 1, Minor = 1, NO_PERMISSION
+ INVALID_MECHANISM, // Major = 2, Minor = 1, NO_PERMISSION
+ CONFLICTING_EVIDENCE, // Major = 3, Minor = 1, NO_PERMISSION
+ NO_CONTEXT, // Major = 4, Minor = 1, NO_PERMISSION
+ POLICY_CHANGE
+ } ErrorCode;
+
+ /**
+ * @name Methods Required by the Server Request Interceptor
+ * Interface
+ *
+ * These are methods that must be implemented since they are pure
+ * virtual in the abstract base class. They are the canonical
+ * methods required for all server request interceptors.
+ */
+ //@{
+ /// Return the name of this ServerRequestinterceptor.
+ virtual char * name (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ virtual void destroy (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ virtual void receive_request_service_contexts (
+ PortableInterceptor::ServerRequestInfo_ptr ri
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ PortableInterceptor::ForwardRequest));
+
+ virtual void receive_request (PortableInterceptor::ServerRequestInfo_ptr ri
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ PortableInterceptor::ForwardRequest));
+
+ virtual void send_reply (PortableInterceptor::ServerRequestInfo_ptr ri
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ virtual void send_exception (PortableInterceptor::ServerRequestInfo_ptr ri
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ PortableInterceptor::ForwardRequest));
+
+ virtual void send_other (PortableInterceptor::ServerRequestInfo_ptr ri
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ PortableInterceptor::ForwardRequest));
+ //@}
+
+ private:
+
+ CORBA::Boolean accept_context ();
+ CORBA::Boolean accept_transport_context ();
+ void reference_context ();
+ void discard_context ();
+
+ CORBA::Boolean extract_sas_context ();
+ void add_complete_establish_context ();
+ void add_context_error ();
+
+ };
+} // End TAO namespace
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1200)
+#pragma warning(pop)
+#endif /* _MSC_VER */
+
+#include "ace/post.h"
+
+#endif /* TAO_TSS_REQUEST_INTERCEPTOR_H */
diff --git a/TAO/orbsvcs/orbsvcs/GSSUP.idl b/TAO/orbsvcs/orbsvcs/GSSUP.idl
new file mode 100644
index 00000000000..4bb8ed232bc
--- /dev/null
+++ b/TAO/orbsvcs/orbsvcs/GSSUP.idl
@@ -0,0 +1,63 @@
+// -*- IDL -*-
+
+//=============================================================================
+/**
+ * @file GSSUP.idl
+ *
+ * $Id$
+ *
+ * @author Object Management Group
+ */
+//=============================================================================
+
+#ifndef _GSSUP_IDL_
+#define _GSSUP_IDL_
+
+#include <CSI.idl>
+//import ::CSI;
+
+module GSSUP {
+ typeprefix GSSUP "omg.org";
+ // The GSS Object Identifier allocated for the
+ // username/password mechanism is defined below.
+ //
+ // { iso-itu-t (2) international-organization (23) omg (130)
+ // security (1) authentication (1) gssup-mechanism (1) }
+ const CSI::StringOID GSSUPMechOID = "oid:2.23.130.1.1.1";
+
+ // The following structure defines the inner contents of the
+ // username password initial context token. This structure is
+ // CDR encapsulated and appended at the end of the
+ // username/password GSS (initial context) Token.
+ struct InitialContextToken {
+ CSI::UTF8String username;
+ CSI::UTF8String password;
+ CSI::GSS_NT_ExportedName target_name;
+ };
+
+ typedef unsigned long ErrorCode;
+
+ // GSSUP Mechanism-Specific Error Token
+ struct ErrorToken {
+ ErrorCode error_code;
+ };
+
+ // The context validator has chosen not to reveal the GSSUP
+ // specific cause of the failure.
+ const ErrorCode GSS_UP_S_G_UNSPECIFIED = 1;
+
+ // The user identified in the username field of the
+ // GSSUP::InitialContextToken is unknown to the target.
+ const ErrorCode GSS_UP_S_G_NOUSER = 2;
+
+ // The password supplied in the GSSUP::InitialContextToken was
+ // incorrect.
+ const ErrorCode GSS_UP_S_G_BAD_PASSWORD = 3;
+
+ // The target_name supplied in the GSSUP::InitialContextToken does
+ // not match a target_name in a mechanism definition of the target.
+ const ErrorCode GSS_UP_S_G_BAD_TARGET = 4;
+
+}; // GSSUP
+
+#endif