Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound 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.3 2004/05/19 15:56:53 mmarsh Exp $
00008 //
00009 // $Log: SupportedClientResponse.h,v $
00010 // Revision 1.3  2004/05/19 15:56:53  mmarsh
00011 // *** empty log message ***
00012 //
00013 // Revision 1.2  2003/11/04 22:31:49  mmarsh
00014 // *** empty log message ***
00015 //
00016 //
00017 
00018 #ifndef __CODEX_KEYSERVICE_SUPPORTEDCLIENTRESPONSE_H__
00019 #define __CODEX_KEYSERVICE_SUPPORTEDCLIENTRESPONSE_H__
00020 
00021 #include "CODEX_ASN1/Base.h"
00022 #include "CODEX_ASN1/Array.h"
00023 #include "CODEX_Server/ServerSignature.h"
00024 #include "CODEX_Server/ServerState.h"
00025 
00026 namespace CODEX_KeyService
00027 {
00032    template< class RespT , class ReqT >
00033    class SupportedClientResponse : public CODEX_ASN1::Base
00034    {
00035       public :
00037          typedef CODEX_ASN1::Array< CODEX_Server::ServerSignature >  ArrayType;
00038 
00040          typedef CODEX_Server::ServerState::LSType::LabelType        LabelType;
00041 
00043          SupportedClientResponse() :
00044             CODEX_ASN1::Base( false )
00045          {}
00046 
00048          SupportedClientResponse( const RespT& response,
00049                                   const ReqT& request,
00050                                   const ArrayType& evidence,
00051                                   const LabelType& label ) :
00052             CODEX_ASN1::Base( true ),
00053             m_response( response ),
00054             m_request( request ),
00055             m_evidence( evidence ),
00056             m_label( label )
00057          {}
00058 
00060          SupportedClientResponse(
00061             const SupportedClientResponse< RespT , ReqT >& aOther ) :
00062             CODEX_ASN1::Base( aOther.m_initialized ),
00063             m_response( aOther.m_response ),
00064             m_request( aOther.m_request ),
00065             m_evidence( aOther.m_evidence ),
00066             m_label( aOther.m_label )
00067          {}
00068 
00070          virtual ~SupportedClientResponse() {}
00071 
00073          void operator=(
00074             const SupportedClientResponse< RespT , ReqT >& aOther )
00075          {
00076             m_initialized = aOther.m_initialized;
00077             m_response = aOther.m_response;
00078             m_request = aOther.m_request;
00079             m_evidence = aOther.m_evidence;
00080             m_label = aOther.m_label;
00081          }
00082 
00084          const RespT& response() const { return m_response; }
00085 
00087          const ReqT& request() const { return m_request; }
00088 
00090          const ArrayType& evidence() const { return m_evidence; }
00091 
00093          const LabelType& label() const { return m_label; }
00094 
00096          int marshal( unsigned char ** pp ) const
00097          {
00098             int r=0;
00099             int ret=0;
00100             unsigned char * p;
00101 
00102             ret += m_response.marshal(0);
00103             ret += m_request.marshal(0);
00104             ret += m_evidence.marshal(0);
00105             ret += m_label.marshal(0);
00106             M_ASN1_I2D_seq_total();
00107             m_response.marshal(&p);
00108             m_request.marshal(&p);
00109             m_evidence.marshal(&p);
00110             m_label.marshal(&p);
00111             M_ASN1_I2D_finish();
00112          }
00113 
00115          void* unmarshal( void* bogus, unsigned char ** pp, long length )
00116          {
00117             if ( m_initialized )
00118             {
00119                return NULL;
00120             }
00121             if ( (NULL == pp) || (NULL == *pp) )
00122             {
00123                return NULL;
00124             }
00125             ASN1_CTX c;
00126             c.pp = pp;
00127             c.q = *pp;
00128             c.error = ERR_R_NESTED_ASN1_ERROR;
00129             int i;
00130 
00131             M_ASN1_D2I_Init();
00132             M_ASN1_D2I_start_sequence();
00133             M_ASN1_D2I_get(i, m_response.unmarshal);
00134             M_ASN1_D2I_get(i, m_request.unmarshal);
00135             M_ASN1_D2I_get(i, m_evidence.unmarshal);
00136             M_ASN1_D2I_get(i, m_label.unmarshal);
00137             if ( !asn1_Finish(&c) )
00138             {
00139                return NULL;
00140             }
00141             *pp=c.p;
00142             m_initialized = true;
00143             return this;
00144            err: // needed by ASN.1 macros
00145             return NULL;
00146          }
00147 
00148       private :
00149          RespT      m_response;
00150          ReqT       m_request;
00151          ArrayType  m_evidence;
00152          LabelType  m_label;
00153    };
00154 
00155 }
00156 
00157 #endif /* __CODEX_KEYSERVICE_SUPPORTEDCLIENTRESPONSE_H__ */

Generated on Wed Jun 2 16:32:56 2004 for COrnell Data EXchange (CODEX) by doxygen1.2.18