VideoTools
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
gssl_none.cpp
Go to the documentation of this file.
1 //
2 // Copyright (C) 2017 Graeme Walker
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 // ===
17 //
18 // gssl_none.cpp
19 //
20 
21 #include "gdef.h"
22 #include "gssl.h"
23 #include "gexception.h"
24 #include <utility>
25 
26 GSsl::Library * GSsl::Library::m_this = nullptr ;
27 
28 GSsl::Library::Library( const bool , const std::string & )
29 {
30  if( m_this == nullptr )
31  m_this = this ;
32 }
33 
34 GSsl::Library::Library( bool , const std::string & , const std::string & , const std::string & )
35 {
36  if( m_this == nullptr )
37  m_this = this ;
38 }
39 
41 {
42  if( this == m_this )
43  m_this = nullptr ;
44 }
45 
47 {
48  return m_this ;
49 }
50 
51 void GSsl::Library::add( const std::string & , const std::string & , const std::string & , const std::string & )
52 {
53 }
54 
55 bool GSsl::Library::has( const std::string & ) const
56 {
57  return false ;
58 }
59 
60 const GSsl::Profile & GSsl::Library::profile( const std::string & ) const
61 {
62  throw G::Exception( "internal error" ) ;
63 }
64 
66 {
67  return false ;
68 }
69 
70 std::string GSsl::Library::id()
71 {
72  return "none" ;
73 }
74 
75 std::string GSsl::Library::credit( const std::string & , const std::string & , const std::string & )
76 {
77  return std::string() ;
78 }
79 
80 //
81 
82 GSsl::Protocol::Protocol( const Profile & , LogFn )
83 {
84 }
85 
87 {
88 }
89 
90 GSsl::Protocol::Result GSsl::Protocol::connect( G::ReadWrite & )
91 {
92  return Result_error ;
93 }
94 
95 GSsl::Protocol::Result GSsl::Protocol::accept( G::ReadWrite & )
96 {
97  return Result_error ;
98 }
99 
100 GSsl::Protocol::Result GSsl::Protocol::stop()
101 {
102  return Result_error ;
103 }
104 
105 GSsl::Protocol::Result GSsl::Protocol::read( char * , size_type , ssize_type & )
106 {
107  return Result_error ;
108 }
109 
110 GSsl::Protocol::Result GSsl::Protocol::write( const char * , size_type , ssize_type & )
111 {
112  return Result_error ;
113 }
114 
115 std::string GSsl::Protocol::str( Protocol::Result )
116 {
117  return std::string() ;
118 }
119 
120 std::pair<std::string,bool> GSsl::Protocol::peerCertificate( int format )
121 {
122  return std::make_pair( std::string() , false ) ;
123 }
124 
125 /// \file gssl_none.cpp
static Library * instance()
Returns a pointer to a library object, if any.
Definition: gssl_none.cpp:46
An interface to an underlying TLS library.
Protocol(const Profile &, LogFn log_fn)
Constructor.
Definition: gssl_none.cpp:82
An abstract interface for reading and writing from a non-blocking i/o channel.
Definition: greadwrite.h:49
bool has(const std::string &profile_name) const
Returns true if the named profile has been add()ed.
Definition: gssl_none.cpp:55
void add(const std::string &profile_name, const std::string &key_and_cert_file=std::string(), const std::string &ca_file=std::string(), const std::string &profile_extra_config=std::string())
Creates a named Profile object that can be retrieved by profile().
Definition: gssl_none.cpp:51
static std::string str(Result result)
Converts a result enumeration into a printable string.
Definition: gssl_none.cpp:115
~Library()
Destructor. Cleans up the underlying TLS library.
Definition: gssl_none.cpp:40
std::pair< std::string, bool > peerCertificate(int format=0)
Returns the peer certificate and a verified flag.
Definition: gssl_none.cpp:120
Library(bool active=true, const std::string &extra_config=std::string())
Constructor.
Definition: gssl_none.cpp:28
Result stop()
Initiates the protocol shutdown.
Definition: gssl_none.cpp:100
Result accept(G::ReadWrite &io)
Starts the protocol passively (as a server).
Definition: gssl_none.cpp:95
Result connect(G::ReadWrite &io)
Starts the protocol actively (as a client).
Definition: gssl_none.cpp:90
static std::string credit(const std::string &prefix, const std::string &eol, const std::string &eot)
Returns a library credit string.
Definition: gssl_none.cpp:75
const Profile & profile(const std::string &profile_name) const
Returns an opaque reference to the named profile.
Definition: gssl_none.cpp:60
A general-purpose exception class derived from std::exception and containing a std::string.
Definition: gexception.h:43
Result read(char *buffer, size_type buffer_size_in, ssize_type &data_size_out)
Reads user data into the supplied buffer.
Definition: gssl_none.cpp:105
A singleton class for initialising the underlying TLS library.
Definition: gssl.h:157
static std::string id()
Returns a library identifier (typically name and version).
Definition: gssl_none.cpp:70
~Protocol()
Destructor.
Definition: gssl_none.cpp:86
bool enabled() const
Returns true if this is a real TLS library and the constructor's active parameter was set...
Definition: gssl_none.cpp:65
Result write(const char *buffer, size_type data_size_in, ssize_type &data_size_out)
Writes user data.
Definition: gssl_none.cpp:110