1#if !defined(RESIP_HELPER_HXX)
2#define RESIP_HELPER_HXX
23class SecurityAttributes;
72 static void integer2hex(
char* _d,
unsigned int _s,
bool _l =
true);
99 static int jitterValue(
int input,
int lowerPercentage,
int upperPercentage,
int minimum=0);
373 const int* allowedMethods = 0,
419 const Data& password);
428 const Data& password,
429 int expiresDelta = 0);
433 const Data& resipPasswordHashA1,
434 int expiresDelta = 0);
438 const Data& passwordOrResipPasswordHashA1,
440 bool isPasswordHashResipA1);
446 const Data& resipPasswordHashA1,
447 int expiresDelta = 0,
448 bool proxyAuthorization =
true);
455 const std::vector<DigestType>& digestTypes = std::vector<DigestType>());
462 const std::vector<DigestType>& digestTypes = std::vector<DigestType>());
471 const std::vector<DigestType>& digestTypes = std::vector<DigestType>());
492 const Data& username,
493 const Data& password,
495 unsigned int& nonceCount);
498 const Data& username,
499 const Data& password,
500 const Auth& challenge,
502 unsigned int& nonceCount,
503 Data& nonceCountString);
506 const Data& username,
507 const Data& password,
508 const Auth& challenge,
511 const Data& nonceCountString,
515 const Data& username,
516 const Data& resipPasswordHashA1,
517 const Auth& challenge,
519 unsigned int& nonceCount,
520 Data& nonceCountString);
523 const Data& username,
524 const Data& resipPasswordHashA1,
525 const Auth& challenge,
528 const Data& nonceCountString,
533 const Data& method,
const Data& digestUri,
const Data& nonce,
541 const Data& method,
const Data& digestUri,
const Data& nonce,
548 const Data& method,
const Data& digestUri,
const Data& nonce,
552 return makeResponseDigest(username, password, realm, method, digestUri, nonce, qop, cnonce, cnonceCount, entityBody,
MD5);
556 const Data& method,
const Data& digestUri,
const Data& nonce,
599 std::unique_ptr<SecurityAttributes> attributes);
618 const std::set<int>* additionalTransactionTerminatingResponses = NULL);
654 NonceHelperPtr() : mNonceHelper(0) {}
655 ~NonceHelperPtr() {
delete mNonceHelper; }
656 NonceHelper *mNonceHelper;
658 static NonceHelperPtr mNonceHelperPtr;
Represents the "credentials" and "challenge" elements in the SIP grammar.
Base class for all SIP body types.
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
static const Data Empty
Constant that represents a zero-length data.
An aggregation of useful static functions.
static Auth makeChallengeResponseAuthWithA1(const SipMessage &request, const Data &username, const Data &resipPasswordHashA1, const Auth &challenge, const Data &cnonce, unsigned int &nonceCount, Data &nonceCountString)
static SipMessage * makeChallenge(const SipMessage &request, const Data &realm, bool useAuth=true, bool stale=false, bool proxy=false, const std::vector< DigestType > &digestTypes=std::vector< DigestType >())
static Uri makeUri(const Data &aor, const Data &scheme=Symbols::DefaultSipScheme)
///////////////////////////////////////////////////////////////////////////////////////////
static SdpContents * getSdpRecurse(Contents *tree)
static AuthResult authenticateRequestWithA1(const SipMessage &request, const Data &realm, const Data &resipPasswordHashA1, int expiresDelta=0)
static Uri fromAor(const Data &aor, const Data &scheme=Symbols::DefaultSipScheme)
static Data makeResponseDigestWithA1(const Data &a1, const Data &method, const Data &digestUri, const Data &nonce, const Data &qop=Data::Empty, const Data &cnonce=Data::Empty, const Data &cnonceCount=Data::Empty, const Contents *entityBody=0, DigestType digestType=MD5)
static void updateNonceCount(unsigned int &nonceCount, Data &nonceCountString)
static Data extractA1FromResipA1HashString(const Data &resipA1HashString, DigestType digestType)
static const int tagSize
bytes in to-tag& from-tag, should prob. live somewhere else
static SipMessage * makePublish(const NameAddr &target, const NameAddr &from)
Create a Publish request with an empty Contact. See makeRequest.
static SipMessage * makeRegister(const NameAddr &to, const NameAddr &from)
Create a Register request with an empty Contact. See makeRequest.
static Data gruuUserPart(const Data &instanceId, const Data &aor, const Data &key)
static bool validateMessage(const SipMessage &message, resip::Data *reason=0)
static bool isClientBehindNAT(const SipMessage &request, bool privateToPublicOnly=true)
Looks at SIP headers and message source for a mismatch to make an assumption that the sender is behin...
static bool algorithmAndQopSupported(const Auth &challenge)
static void getResponseCodeReason(int responseCode, Data &reason)
Returns the default reason string for a particular response code.
static NonceHelper * getNonceHelper()
static SipMessage * makeInvite(const NameAddr &target, const NameAddr &from)
Make an invite request - Empty Contact and Via is added and will be populated by the stack when sent.
static T aBitSmallerThan(T secs)
Used by Registration, Publication and Subscription refreshes, to calculate the time at which a refres...
static Data makeResponseMD5(const Data &username, const Data &password, const Data &realm, const Data &method, const Data &digestUri, const Data &nonce, const Data &qop=Data::Empty, const Data &cnonce=Data::Empty, const Data &cnonceCount=Data::Empty, const Contents *entityBody=0)
static void processStrictRoute(SipMessage &request)
static std::pair< Data, Data > fromGruuUserPart(const Data &gruuUserPart, const Data &key)
static SipMessage & addAuthorization(SipMessage &request, const SipMessage &challenge, const Data &username, const Data &password, const Data &cnonce, unsigned int &nonceCount)
static Data createResipA1HashString(const Data &username, const Data &realm, const Data &password)
static void setNonceHelper(NonceHelper *nonceHelper)
///////////////////////////////////////////////////////////////////////////////////////////
static void massageRoute(const SipMessage &request, NameAddr &route)
static SipMessage * makeProxyChallenge(const SipMessage &request, const Data &realm, bool useAuth=true, bool stale=false, const std::vector< DigestType > &digestTypes=std::vector< DigestType >())
static SipMessage * makeMessage(const NameAddr &target, const NameAddr &from)
Create a Message request with an empty Contact. See makeRequest.
static unsigned int hex2integer(const char *_s)
Converts a character string containing a hexidecimal value into an unsigned int.
static Data computeTag(int numBytes)
static std::unique_ptr< SdpContents > getSdp(Contents *tree)
static Data qopOption(const Auth &challenge)
static SipMessage * makeCancel(const SipMessage &request)
Make a new Cancel request for the specified request.
static void addChallenge(SipMessage &response, const SipMessage &request, const Data &realm, bool useAuth=true, bool stale=false, bool proxy=false, DigestType digestType=MD5)
static int getPortForReply(SipMessage &request)
static bool isDigestTypeSupportedInResipA1HashString(const Data &resipA1HashString, DigestType digestType)
static SipMessage * make405(const SipMessage &request, const int *allowedMethods=0, int nMethods=-1)
Make a 405 response to a provided request.
static ContentsSecAttrs extractFromPkcs7(const SipMessage &message, Security &security)
static void makeResponse(SipMessage &response, const SipMessage &request, int responseCode, const Data &reason=Data::Empty, const Data &hostname=Data::Empty, const Data &warning=Data::Empty)
Make a response to a provided request.
static Tuple getClientPublicAddress(const SipMessage &request)
Look at Via headers, and find the first public IP address closest to the sending client.
static int jitterValue(int input, int lowerPercentage, int upperPercentage, int minimum=0)
Used to jitter the expires in a SUBSCRIBE or REGISTER expires header.
static void makeRawResponse(Data &rawBuffer, const SipMessage &request, int responseCode, const Data &additionalHeaders=Data::Empty, const Data &body=Data::Empty)
static void integer2hex(char *_d, unsigned int _s, bool _l=true)
Converts an interger in a character string containing the hexidecimal representation of the integer.
static SipMessage * makeWWWChallenge(const SipMessage &request, const Data &realm, bool useAuth=true, bool stale=false, const std::vector< DigestType > &digestTypes=std::vector< DigestType >())
static SipMessage * makeRequest(const NameAddr &target, const NameAddr &from, const NameAddr &contact, MethodTypes method)
///////////////////////////////////////////////////////////////////////////////////////////
static AuthResult authenticateRequest(const SipMessage &request, const Data &realm, const Data &password, int expiresDelta=0)
static std::pair< AuthResult, Data > advancedAuthenticateRequest(const SipMessage &request, const Data &realm, const Data &resipPasswordHashA1, int expiresDelta=0, bool proxyAuthorization=true)
static Data makeResponseDigest(const Data &username, const Data &password, const Data &realm, const Data &method, const Data &digestUri, const Data &nonce, const Data &qop=Data::Empty, const Data &cnonce=Data::Empty, const Data &cnonceCount=Data::Empty, const Contents *entityBody=0, DigestType digestType=MD5)
static FailureMessageEffect determineFailureMessageEffect(const SipMessage &response, const std::set< int > *additionalTransactionTerminatingResponses=NULL)
static bool isDigestAlgorithmSupported(const Auth &auth, DigestType &digestType)
static Data computeUniqueBranch()
Creates and returns a unique branch parameter.
static SipMessage * makeFailureAck(const SipMessage &request, const SipMessage &response)
This interface should be used by the stack (TransactionState) to create an AckMsg to a failure respon...
static Auth makeChallengeResponseAuth(const SipMessage &request, const Data &username, const Data &password, const Auth &challenge, const Data &cnonce, unsigned int &nonceCount, Data &nonceCountString)
static Data makeNonce(const SipMessage &request, const Data ×tamp)
static SipMessage * makeSubscribe(const NameAddr &target, const NameAddr &from)
Create a Subscribe request with an empty Contact. See makeRequest.
static Data makeResponseMD5WithA1(const Data &a1, const Data &method, const Data &digestUri, const Data &nonce, const Data &qop=Data::Empty, const Data &cnonce=Data::Empty, const Data &cnonceCount=Data::Empty, const Contents *entityBody=0)
static Data computeCallId()
Represents the "name-addr" and the "addr-spec" elements in the RFC 3261 grammar.
Provides an interface to process and generate SDP bodies (MIME content-type application/sdp).
Represents a SIP message.
static const char * DefaultSipScheme
Represents a network address.
Represents the "SIP-URI" and "SIPS-URI" elements in the RFC 3261 grammar.
dcm! – add UnusedChecking(_enum) below;
const _Tp & resipMin(const _Tp &__a, const _Tp &__b)
const _Tp & resipMax(const _Tp &__a, const _Tp &__b)
std::unique_ptr< Contents > mContents
ContentsSecAttrs & operator=(ContentsSecAttrs &&)=default
~ContentsSecAttrs()=default
ContentsSecAttrs(const ContentsSecAttrs &)=delete
ContentsSecAttrs & operator=(const ContentsSecAttrs &)=delete
ContentsSecAttrs()=default
std::unique_ptr< SecurityAttributes > mAttributes
ContentsSecAttrs(ContentsSecAttrs &&)=default