• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KIO

ksslsession.cpp

Go to the documentation of this file.
00001 /* This file is part of the KDE project
00002  *
00003  * Copyright (C) 2003 George Staikos <staikos@kde.org>
00004  *
00005  * This library is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU Library General Public
00007  * License as published by the Free Software Foundation; either
00008  * version 2 of the License, or (at your option) any later version.
00009  *
00010  * This library is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Library General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU Library General Public License
00016  * along with this library; see the file COPYING.LIB.  If not, write to
00017  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, USA.
00019  */
00020 
00021 #include "ksslsession.h"
00022 
00023 #include <config.h>
00024 #include <ksslconfig.h>
00025 
00026 #include <kopenssl.h>
00027 #include <kcodecs.h>
00028 
00029 KSSLSession::KSSLSession() : _session(0L) {
00030 }
00031 
00032 
00033 KSSLSession::~KSSLSession() {
00034 #ifdef KSSL_HAVE_SSL
00035     if (_session) {
00036         KOpenSSLProxy::self()->SSL_SESSION_free(static_cast<SSL_SESSION*>(_session));
00037         _session = 0L;
00038     }
00039 #endif
00040 }
00041 
00042 
00043 QString KSSLSession::toString() const {
00044     QString rc;
00045 #ifdef KSSL_HAVE_SSL
00046     SSL_SESSION *session = static_cast<SSL_SESSION*>(_session);
00047     int slen = KOpenSSLProxy::self()->i2d_SSL_SESSION(session, 0L);
00048 
00049     if (slen >= 0) {
00050     // These should technically be unsigned char * but it doesn't matter
00051     // for our purposes
00052     char *csess = new char[slen];
00053     unsigned char *p = (unsigned char*)csess;
00054 
00055     if (!KOpenSSLProxy::self()->i2d_SSL_SESSION(session, &p)) {
00056         delete[] csess;
00057         return QString();
00058     }
00059 
00060     // encode it into a QString
00061     rc = QByteArray(csess,slen).toBase64();
00062     delete[] csess;
00063      }
00064 #endif
00065     return rc;
00066 }
00067 
00068 
00069 KSSLSession *KSSLSession::fromString(const QString& s) {
00070 KSSLSession *session = 0L;
00071 #ifdef KSSL_HAVE_SSL
00072 QByteArray qba, qbb = s.toLocal8Bit();
00073         qba = QByteArray::fromBase64(qbb);
00074     unsigned char *qbap = reinterpret_cast<unsigned char *>(qba.data());
00075     SSL_SESSION *ss = KOSSL::self()->d2i_SSL_SESSION(0L, &qbap, qba.size());
00076         if (ss) {
00077         session = new KSSLSession;
00078         session->_session = ss;
00079         }
00080 #endif
00081 return session;
00082 }
00083 
00084 

KIO

Skip menu "KIO"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • KIO
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal