int CSetSoapSecurityDigest2Impl::soap_wsse_add_UsernameTokenText(struct soap *soap, 
												  const char *username, const char *password)  
{   
    _wsse__Security *security = soap->header->wsse__Security;  
    /* allocate a UsernameToken if we don't have one already */  
    if (!security->UsernameToken)  
        security->UsernameToken = (_wsse__UsernameToken*)soap_malloc(soap, sizeof(_wsse__UsernameToken));  
    soap_default__wsse__UsernameToken(soap, security->UsernameToken);  
    /* populate the UsernameToken */  
/*    security->UsernameToken->wsu__Id = soap_strdup(soap, id);  */
    security->UsernameToken->Username = soap_strdup(soap, username);  
    /* allocate and populate the Password */  
    if (password)  
    {   
        security->UsernameToken->Password = (_wsse__Password*)soap_malloc(soap, sizeof(_wsse__Password));  
        soap_default__wsse__Password(soap, security->UsernameToken->Password);  
        security->UsernameToken->Password->__item = soap_strdup(soap, password);  
    }  
    return SOAP_OK;  
}  
Ejemplo n.º 2
0
/**
@fn int soap_wsse_add_UsernameTokenText(struct soap *soap, const char *id, const char *username, const char *password)
@brief Adds UsernameToken element with optional clear-text password.
@param soap context
@param[in] id string for signature referencing or NULL
@param[in] username string
@param[in] password string or NULL to omit the password
@return SOAP_OK

Passwords are sent in the clear, so transport-level encryption is required.

@note
This release supports the use of at most one UsernameToken in the header.
*/
int
soap_wsse_add_UsernameTokenText(struct soap *soap, const char *id, const char *username, const char *password)
{ _wsse__Security *security = soap_wsse_add_Security(soap);
  DBGFUN2("soap_wsse_add_UsernameTokenText", "id=%s", id?id:"", "username=%s", username?username:"");
  /* allocate a UsernameToken if we don't have one already */
  if (!security->UsernameToken)
  { if (!(security->UsernameToken = (_wsse__UsernameToken*)soap_malloc(soap, sizeof(_wsse__UsernameToken))))
      return soap->error = SOAP_EOM;
  }
  soap_default__wsse__UsernameToken(soap, security->UsernameToken);
  /* populate the UsernameToken */
  security->UsernameToken->wsu__Id = soap_strdup(soap, id);
  security->UsernameToken->Username = soap_strdup(soap, username);
  /* allocate and populate the Password */
  if (password)
  { if (!(security->UsernameToken->Password = (_wsse__Password*)soap_malloc(soap, sizeof(_wsse__Password))))
      return soap->error = SOAP_EOM;
    soap_default__wsse__Password(soap, security->UsernameToken->Password);
    security->UsernameToken->Password->Type = (char*)wsse_PasswordTextURI;
    security->UsernameToken->Password->__item = soap_strdup(soap, password);
  }
  return SOAP_OK;
}