Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

SupportedClientResponse.h

00001 /*
00002  * Copyright 2003 Michael A. Marsh, Cornell University. All rights reserved.
00003  * This software is released under the modified BSD license.
00004  * See the file LICENSE in the top-level directory for details.
00005  */
00006 //
00007 // $Id: SupportedClientResponse.h,v 1.4 2005/01/21 19:44:17 mmarsh Exp $
00008 //
00009 // $Log: SupportedClientResponse.h,v $
00010 // Revision 1.4  2005/01/21 19:44:17  mmarsh
00011 // Updated for compatibility with Doxygen 1.4.1
00012 //
00013 // Revision 1.3  2004/05/19 15:56:53  mmarsh
00014 // *** empty log message ***
00015 //
00016 // Revision 1.2  2003/11/04 22:31:49  mmarsh
00017 // *** empty log message ***
00018 //
00019 //
00020 
00021 #ifndef __CODEX_KEYSERVICE_SUPPORTEDCLIENTRESPONSE_H__
00022 #define __CODEX_KEYSERVICE_SUPPORTEDCLIENTRESPONSE_H__
00023 
00024 #include "CODEX_ASN1/Base.h"
00025 #include "CODEX_ASN1/Array.h"
00026 #include "CODEX_Server/ServerSignature.h"
00027 #include "CODEX_Server/ServerState.h"
00028 
00029 namespace CODEX_KeyService
00030 {
00035    template< class RespT , class ReqT >
00036    class SupportedClientResponse : public CODEX_ASN1::Base
00037    {
00038       public :
00040          typedef CODEX_ASN1::Array< CODEX_Server::ServerSignature >  ArrayType;
00041 
00043          typedef CODEX_Server::ServerState::LSType::LabelType        LabelType;
00044 
00046          SupportedClientResponse() :
00047             CODEX_ASN1::Base( false )
00048          {}
00049 
00051          SupportedClientResponse( const RespT& response,
00052                                   const ReqT& request,
00053                                   const ArrayType& evidence,
00054                                   const LabelType& label ) :
00055             CODEX_ASN1::Base( true ),
00056             m_response( response ),
00057             m_request( request ),
00058             m_evidence( evidence ),
00059             m_label( label )
00060          {}
00061 
00063          SupportedClientResponse(
00064             const SupportedClientResponse< RespT , ReqT >& aOther ) :
00065             CODEX_ASN1::Base( aOther.m_initialized ),
00066             m_response( aOther.m_response ),
00067             m_request( aOther.m_request ),
00068             m_evidence( aOther.m_evidence ),
00069             m_label( aOther.m_label )
00070          {}
00071 
00073          virtual ~SupportedClientResponse() {}
00074 
00076          void operator=(
00077             const SupportedClientResponse< RespT , ReqT >& aOther )
00078          {
00079             m_initialized = aOther.m_initialized;
00080             m_response = aOther.m_response;
00081             m_request = aOther.m_request;
00082             m_evidence = aOther.m_evidence;
00083             m_label = aOther.m_label;
00084          }
00085 
00087          const RespT& response() const { return m_response; }
00088 
00090          const ReqT& request() const { return m_request; }
00091 
00093          const ArrayType& evidence() const { return m_evidence; }
00094 
00096          const LabelType& label() const { return m_label; }
00097 
00099          int marshal( unsigned char ** pp ) const
00100          {
00101             int r=0;
00102             int ret=0;
00103             unsigned char * p;
00104 
00105             ret += m_response.marshal(0);
00106             ret += m_request.marshal(0);
00107             ret += m_evidence.marshal(0);
00108             ret += m_label.marshal(0);
00109             M_ASN1_I2D_seq_total();
00110             m_response.marshal(&p);
00111             m_request.marshal(&p);
00112             m_evidence.marshal(&p);
00113             m_label.marshal(&p);
00114             M_ASN1_I2D_finish();
00115          }
00116 
00118          void* unmarshal( void* bogus, unsigned char ** pp, long length )
00119          {
00120             if ( m_initialized )
00121             {
00122                return NULL;
00123             }
00124             if ( (NULL == pp) || (NULL == *pp) )
00125             {
00126                return NULL;
00127             }
00128             ASN1_CTX c;
00129             c.pp = pp;
00130             c.q = *pp;
00131             c.error = ERR_R_NESTED_ASN1_ERROR;
00132             int i;
00133 
00134             M_ASN1_D2I_Init();
00135             M_ASN1_D2I_start_sequence();
00136             M_ASN1_D2I_get(i, m_response.unmarshal);
00137             M_ASN1_D2I_get(i, m_request.unmarshal);
00138             M_ASN1_D2I_get(i, m_evidence.unmarshal);
00139             M_ASN1_D2I_get(i, m_label.unmarshal);
00140             if ( !asn1_Finish(&c) )
00141             {
00142                return NULL;
00143             }
00144             *pp=c.p;
00145             m_initialized = true;
00146             return this;
00147            err: // needed by ASN.1 macros
00148             return NULL;
00149          }
00150 
00151       private :
00152          RespT      m_response;
00153          ReqT       m_request;
00154          ArrayType  m_evidence;
00155          LabelType  m_label;
00156    };
00157 
00158 }
00159 
00160 #endif /* __CODEX_KEYSERVICE_SUPPORTEDCLIENTRESPONSE_H__ */

Generated on Fri May 6 17:41:27 2005 for COrnell Data EXchange (CODEX) by  doxygen 1.4.1