• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdeio/kssl
 

tdeio/kssl

  • tdeio
  • kssl
ksslsession.cpp
1 /* This file is part of the KDE project
2  *
3  * Copyright (C) 2003 George Staikos <staikos@kde.org>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public License
16  * along with this library; see the file COPYING.LIB. If not, write to
17  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  */
20 
21 #include "ksslsession.h"
22 
23 #ifdef HAVE_CONFIG_H
24 #include <config.h>
25 #endif
26 
27 #include <kopenssl.h>
28 #include <kmdcodec.h>
29 
30 KSSLSession::KSSLSession() : _session(0L) {
31 }
32 
33 
34 KSSLSession::~KSSLSession() {
35 #ifdef KSSL_HAVE_SSL
36  if (_session) {
37  KOpenSSLProxy::self()->SSL_SESSION_free(static_cast<SSL_SESSION*>(_session));
38  _session = 0L;
39  }
40 #endif
41 }
42 
43 
44 TQString KSSLSession::toString() const {
45 TQString rc;
46 #ifdef KSSL_HAVE_SSL
47 TQByteArray qba;
48 SSL_SESSION *session = static_cast<SSL_SESSION*>(_session);
49 unsigned int slen = KOpenSSLProxy::self()->i2d_SSL_SESSION(session, 0L);
50 unsigned char *csess = new unsigned char[slen];
51 unsigned char *p = csess;
52 
53  if (!KOpenSSLProxy::self()->i2d_SSL_SESSION(session, &p)) {
54  delete[] csess;
55  return TQString::null;
56  }
57 
58  // encode it into a QString
59  qba.duplicate((const char*)csess, slen);
60  delete[] csess;
61  rc = KCodecs::base64Encode(qba);
62 #endif
63 return rc;
64 }
65 
66 
67 KSSLSession *KSSLSession::fromString(const TQString& s) {
68 KSSLSession *session = 0L;
69 #ifdef KSSL_HAVE_SSL
70 TQByteArray qba, qbb = s.local8Bit().copy();
71  KCodecs::base64Decode(qbb, qba);
72  unsigned char *qbap = reinterpret_cast<unsigned char *>(qba.data());
73  SSL_SESSION *ss = KOSSL::self()->d2i_SSL_SESSION(0L, &qbap, qba.size());
74  if (ss) {
75  session = new KSSLSession;
76  session->_session = ss;
77  }
78 #endif
79 return session;
80 }
81 
82 
KSSL::session
const KSSLSession * session() const
Obtain a pointer to the session information.
Definition: kssl.cpp:688
KSSLSession::~KSSLSession
~KSSLSession()
Destroy this instance.
Definition: ksslsession.cpp:34
KSSLSession::fromString
static KSSLSession * fromString(const TQString &s)
Create as session ID object from a base64 encoded string.
Definition: ksslsession.cpp:67
KSSLSession
KDE SSL Session Information.
Definition: ksslsession.h:42
KSSLSession::toString
TQString toString() const
Convert to a base64 encoded string (so it can be copied safely)
Definition: ksslsession.cpp:44
KOpenSSLProxy::self
static KOpenSSLProxy * self()
Return an instance of class KOpenSSLProxy * You cannot delete this object.
Definition: kopenssl.cpp:729

tdeio/kssl

Skip menu "tdeio/kssl"
  • Main Page
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

tdeio/kssl

Skip menu "tdeio/kssl"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  •     tdecore
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  • tdeioslave
  •   http
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeio/kssl by doxygen 1.8.8
This website is maintained by Timothy Pearson.