00001
00002
00003
00004
00005
00006 #include "eirods_client_server_negotiation.h"
00007
00008
00009
00010 #include "rodsDef.h"
00011 #include "index.h"
00012 #include "reFuncDefs.h"
00013
00014
00015 namespace eirods {
00016
00017
00018 error client_server_negotiation_for_server(
00019 eirods::network_object_ptr _ptr,
00020 std::string& _result ) {
00021
00022
00023 ruleExecInfo_t rei;
00024 memset ((char*)&rei, 0, sizeof (ruleExecInfo_t));
00025
00026
00027
00028 msParamArray_t params;
00029 memset( ¶ms, 0, sizeof( params ) );
00030 int status = applyRuleUpdateParams(
00031 "acPreConnect(*OUT)",
00032 ¶ms,
00033 &rei,
00034 NO_SAVE_REI );
00035 if( 0 != status ) {
00036 return ERROR( status, "failed in call to applyRuleUpdateParams" );
00037 }
00038
00039
00040
00041 char* rule_result_ptr = 0;
00042 msParam_t* out_ms_param = getMsParamByLabel( ¶ms, "*OUT" );
00043 if( out_ms_param ) {
00044 rule_result_ptr = reinterpret_cast< char* >( out_ms_param->inOutStruct );
00045
00046 } else {
00047 return ERROR( SYS_INVALID_INPUT_PARAM, "null out parameter" );
00048
00049 }
00050
00051 if( !rule_result_ptr ) {
00052 return ERROR( SYS_INVALID_INPUT_PARAM, "rule_result is null" );
00053
00054 }
00055
00056 std::string rule_result( rule_result_ptr );
00057
00058
00059
00060 if( !do_client_server_negotiation_for_server() ) {
00061
00062
00063 if( CS_NEG_REQUIRE == rule_result ) {
00064 std::stringstream msg;
00065 msg << "SSL is required by the server but not requested by the client";
00066 return ERROR( SYS_INVALID_INPUT_PARAM, msg.str() );
00067
00068 } else {
00069
00070
00071 return SUCCESS();
00072 }
00073
00074 }
00075
00076
00077
00078 eirods::cs_neg_t cs_neg;
00079 cs_neg.status_ = CS_NEG_STATUS_SUCCESS;
00080 strncpy( cs_neg.result_, rule_result.c_str(), MAX_NAME_LEN );
00081 error err = send_client_server_negotiation_message( _ptr, cs_neg );
00082 if( !err.ok() ) {
00083 std::stringstream msg;
00084 msg << "failed with PEP value of [" << rule_result << "]";
00085 return PASSMSG( msg.str(), err );
00086 }
00087
00088
00089
00090 boost::shared_ptr< cs_neg_t > read_cs_neg;
00091 err = read_client_server_negotiation_message( _ptr, read_cs_neg );
00092 if( !err.ok() ) {
00093 return PASS( err );
00094 }
00095
00096
00097
00098 if( strlen( read_cs_neg->result_ ) != 0 ) {
00099 _result = read_cs_neg->result_;
00100 }
00101
00102
00103
00104 if( CS_NEG_STATUS_SUCCESS == read_cs_neg->status_ ) {
00105 return SUCCESS();
00106 }
00107
00108
00109
00110 return ERROR( -1, "failure detected from client" );
00111
00112 }
00113
00114 };
00115
00116
00117