Skip to content

Commit

Permalink
Add a constrained namespace implementation around Authenticator class…
Browse files Browse the repository at this point in the history
… to prevent conflict with libvlc live555.
  • Loading branch information
SteveGilvarry committed Dec 17, 2015
1 parent 8f27213 commit af76d19
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/zm_remote_camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void RemoteCamera::Initialise()
}

mNeedAuth = false;
mAuthenticator = new Authenticator(username,password);
mAuthenticator = new zm::Authenticator(username,password);

struct addrinfo hints;
memset(&hints, 0, sizeof(hints));
Expand Down
2 changes: 1 addition & 1 deletion src/zm_remote_camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class RemoteCamera : public Camera
// fill required fields and set needAuth
// subsequent requests can set the required authentication header.
bool mNeedAuth;
Authenticator* mAuthenticator;
zm::Authenticator* mAuthenticator;
protected:
struct addrinfo *hp;

Expand Down
4 changes: 2 additions & 2 deletions src/zm_remote_camera_http.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ int RemoteCameraHttp::GetResponse()
std::string Header = header;

mAuthenticator->checkAuthResponse(Header);
if ( mAuthenticator->auth_method() == AUTH_DIGEST ) {
if ( mAuthenticator->auth_method() == zm::AUTH_DIGEST ) {
Debug( 2, "Need Digest Authentication" );
request = stringtf( "GET %s HTTP/%s\r\n", path.c_str(), config.http_version );
request += stringtf( "User-Agent: %s/%s\r\n", config.http_ua, ZM_VERSION );
Expand Down Expand Up @@ -750,7 +750,7 @@ Debug(3, "Need more data buffer %d < content length %d", buffer.size(), content_
Debug(2, "Checking for digest auth in %s", authenticate_header );

mAuthenticator->checkAuthResponse(Header);
if ( mAuthenticator->auth_method() == AUTH_DIGEST ) {
if ( mAuthenticator->auth_method() == zm::AUTH_DIGEST ) {
Debug( 2, "Need Digest Authentication" );
request = stringtf( "GET %s HTTP/%s\r\n", path.c_str(), config.http_version );
request += stringtf( "User-Agent: %s/%s\r\n", config.http_ua, ZM_VERSION );
Expand Down
4 changes: 2 additions & 2 deletions src/zm_rtsp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,9 @@ RtspThread::RtspThread( int id, RtspMethod method, const std::string &protocol,
mNeedAuth = false;
StringVector parts = split(auth,":");
if (parts.size() > 1)
mAuthenticator = new Authenticator(parts[0], parts[1]);
mAuthenticator = new zm::Authenticator(parts[0], parts[1]);
else
mAuthenticator = new Authenticator(parts[0], "");
mAuthenticator = new zm::Authenticator(parts[0], "");
}

RtspThread::~RtspThread()
Expand Down
2 changes: 1 addition & 1 deletion src/zm_rtsp.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class RtspThread : public Thread
// subsequent requests can set the required authentication header.
bool mNeedAuth;
int respCode;
Authenticator* mAuthenticator;
zm::Authenticator* mAuthenticator;


std::string mHttpSession; ///< Only for RTSP over HTTP sessions
Expand Down
4 changes: 4 additions & 0 deletions src/zm_rtsp_auth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#include <stdlib.h>
#include <string.h>

namespace zm {

Authenticator::Authenticator(std::string &username, std::string password) {
#ifdef HAVE_GCRYPT_H
// Special initialisation for libgcrypt
Expand Down Expand Up @@ -227,3 +229,5 @@ void Authenticator::checkAuthResponse(std::string &response) {
Debug( 2, "Didn't find auth line in %s", authLine.c_str());
}
}

} // namespace zm
4 changes: 4 additions & 0 deletions src/zm_rtsp_auth.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
#include <openssl/md5.h>
#endif // HAVE_GCRYPT_H || HAVE_LIBCRYPTO

namespace zm {

enum AuthMethod { AUTH_UNDEFINED = 0, AUTH_BASIC = 1, AUTH_DIGEST = 2 };
class Authenticator {
public:
Expand Down Expand Up @@ -62,4 +64,6 @@ class Authenticator {
int nc;
};

} // namespace zm

#endif // ZM_RTSP_AUTH_H

0 comments on commit af76d19

Please sign in to comment.