SMBIOS Library
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
libraries
token
Token.cpp
Go to the documentation of this file.
1
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2
* vim:expandtab:autoindent:tabstop=4:shiftwidth=4:filetype=c:cindent:textwidth=0:
3
*
4
* Copyright (C) 2005 Dell Inc.
5
* by Michael Brown <Michael_E_Brown@dell.com>
6
* Licensed under the Open Software License version 2.1
7
*
8
* Alternatively, you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published
10
* by the Free Software Foundation; either version 2 of the License,
11
* or (at your option) any later version.
12
13
* This program is distributed in the hope that it will be useful, but
14
* WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
* See the GNU General Public License for more details.
17
*/
18
19
// compat header should always be first header if including system headers
20
#define LIBSMBIOS_SOURCE
21
#include "
smbios/compat.h
"
22
23
#include <iomanip>
24
25
#include "
TokenImpl.h
"
26
27
using namespace
std;
28
29
namespace
smbios
30
{
31
IToken::IToken()
32
{}
33
34
IProtectedToken::IProtectedToken()
35
{}
36
37
ICmosToken::ICmosToken()
38
{}
39
40
ISmiToken::ISmiToken()
41
{}
42
43
// no dynamically allocated memory, yay!
44
IToken::~IToken()
45
{}
46
47
std::ostream &
operator <<
(std::ostream & cout,
const
IToken
& item)
48
{
49
return
item.
streamify
(cout);
50
}
51
52
void
activateToken
(
int
tokenNum,
string
password)
53
{
54
smbios::TokenTableFactory
*ttFactory =
smbios::TokenTableFactory::getFactory
() ;
55
smbios::ITokenTable
*tokenTable = ttFactory->
getSingleton
();
56
try
57
{
58
smbios::IToken
*token = &(*((*tokenTable)[ tokenNum ]));
59
dynamic_cast<
smbios::IProtectedToken
*
>
(token)->tryPassword(password);
60
}
catch
(...) {
/* not an error if password fails */
}
61
62
(*tokenTable)[ tokenNum ]->activate();
63
}
64
65
bool
isTokenActive
(
int
token)
66
{
67
smbios::TokenTableFactory
*ttFactory =
smbios::TokenTableFactory::getFactory
() ;
68
smbios::ITokenTable
*tokenTable = ttFactory->
getSingleton
();
69
return
(*tokenTable)[ token ]->isActive();
70
}
71
}
Generated on Thu Mar 27 2014 09:27:18 for SMBIOS Library by
1.8.1.2