Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

Token.cpp

Go to the documentation of this file.
00001 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
00002  * vim:expandtab:autoindent:tabstop=4:shiftwidth=4:filetype=c:cindent:textwidth=0:
00003  *
00004  * Copyright (C) 2005 Dell Inc.
00005  *  by Michael Brown <Michael_E_Brown@dell.com>
00006  * Licensed under the Open Software License version 2.1
00007  *
00008  * Alternatively, you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published
00010  * by the Free Software Foundation; either version 2 of the License,
00011  * or (at your option) any later version.
00012 
00013  * This program is distributed in the hope that it will be useful, but
00014  * WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00016  * See the GNU General Public License for more details.
00017  */
00018 
00019 // compat header should always be first header if including system headers
00020 #define LIBSMBIOS_SOURCE
00021 #include "smbios/compat.h"
00022 
00023 #include <iomanip>
00024 
00025 #include "TokenImpl.h"
00026 
00027 using namespace std;
00028 
00029 namespace smbios
00030 {
00031     IToken::IToken()
00032     {}
00033 
00034     IProtectedToken::IProtectedToken()
00035     {}
00036 
00037     ICmosToken::ICmosToken()
00038     {}
00039 
00040     ISmiToken::ISmiToken()
00041     {}
00042 
00043     // no dynamically allocated memory, yay!
00044     IToken::~IToken()
00045     {}
00046 
00047     std::ostream & operator << (std::ostream & cout, const IToken & item)
00048     {
00049         return item.streamify(cout);
00050     }
00051 
00052     void activateToken(int tokenNum, string password)
00053     {
00054         smbios::TokenTableFactory *ttFactory = smbios::TokenTableFactory::getFactory() ;
00055         smbios::ITokenTable *tokenTable = ttFactory->getSingleton();
00056         try
00057         {
00058             smbios::IToken *token = &(*((*tokenTable)[ tokenNum ]));
00059             dynamic_cast< smbios::IProtectedToken * >(token)->tryPassword(password);
00060         } catch (...) { /* not an error if password fails */ }
00061 
00062         (*tokenTable)[ tokenNum ]->activate();
00063     }   
00064     
00065     bool isTokenActive(int token)
00066     {   
00067         smbios::TokenTableFactory *ttFactory = smbios::TokenTableFactory::getFactory() ;
00068         smbios::ITokenTable *tokenTable = ttFactory->getSingleton();
00069         return (*tokenTable)[ token ]->isActive();
00070     } 
00071 }

Generated on Wed Apr 11 16:25:10 2007 for SMBIOS Library by doxygen 1.3.5