Files
surfer/openssl-act-engine/SecOpGuard.cpp
carsten.pluntke 9a8b208c62 References #2
2010-09-02 15:56:01 +00:00

49 lines
845 B
C++

#include "SecOpGuard.h"
#include <actDebug.h>
#include <actIToken.h>
#include <actITokenAuth.h>
SecOpGuard::SecOpGuard(act::IToken* token)
: m_token(token)
, act::SCardLock(token->GetOS())
{
ACT_ASSERT(token != NULL);
m_token_auth = token->GetAuth();
}
SecOpGuard::~SecOpGuard()
{
if(!m_token_auth->IsAuthenticated())
return;
try
{
m_token_auth->Logout();
}
catch(act::Exception& ACT_DEBUG_PARAM(e))
{
ACT_TRACE(e, "SecOpGuard::~SecOpGuard");
}
}
bool SecOpGuard::Authenticate(act::ITokenPIN* token_pin, const act::Blob& auth_data)
{
// Auth constraints, chained authorization, anyone?
if(m_token_auth->IsAuthenticated())
return true;
try
{
return (m_token_auth->Login(token_pin, auth_data));
}
catch(act::Exception& ACT_DEBUG_PARAM(e))
{
ACT_TRACE(e, "SecOpGuard::Authenticate");
}
return false;
}