Import Mozilla Firefox passwords in KDE wallet

The KDE wallet manager password integration add-on for Firefox didn't work for me for quite some time. The new release 0.9 in combination with Mozilla Firefox 5.0 works again. So it was time to import all passwords saved in Firefox into my KDE wallet. I found instructions here, but they were out of date. Here's how I proceeded.

First, install the Firefox add-on Password Exporter, restart Firefox, open "Edit > Preferences" and go to the Security tab where you click Import/Export Passwords and then Export Passwords.

Transform the saved XML file with the following XSL stylesheet:

<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!--
Copyright (C) 2011 Thomas Zumbrunn http://thomas.zumbrunn.name/
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program.  If not, see http://www.gnu.org/licenses/.
-->
<!-- XSL stylesheet to transform XML file exported with Firefox 5.0
Password Exporter 1.2.1 for KDE Wallet Manager 1.7 -->
  <xsl:template match="entries">
    <wallet name="Firefox">
      <folder name="Firefox">
        <xsl:apply-templates />
      </folder>
    </wallet>
  </xsl:template>
  <xsl:template match="entry">
    <map>
      <xsl:attribute name="name">
        <xsl:value-of select="@user"/>
        <xsl:text>,</xsl:text>
        <xsl:value-of select="@host"/>
        <xsl:text>,</xsl:text>
        <xsl:value-of select="@httpRealm"/>
        <xsl:text>,</xsl:text>
        <xsl:value-of select="@formSubmitURL"/>
      </xsl:attribute>
      <xsl:if test="@formSubmitURL != ''">
        <mapentry name="formSubmitURL">
          <xsl:value-of select="@formSubmitURL"/>
        </mapentry>
      </xsl:if>
      <xsl:if test="@httpRealm != ''">
        <mapentry name="httpRealm">
          <xsl:value-of select="@httpRealm"/>
        </mapentry>
      </xsl:if>
      <xsl:if test="@host != ''">
        <mapentry name="hostname">
          <xsl:value-of select="@host"/>
        </mapentry>
      </xsl:if>
      <xsl:if test="@password != ''">
        <mapentry name="password">
          <xsl:value-of select="@password"/>
        </mapentry>
      </xsl:if>
      <xsl:if test="@passFieldName != ''">
        <mapentry name="passwordField">
          <xsl:value-of select="@passFieldName"/>
        </mapentry>
      </xsl:if>
      <xsl:if test="@user != ''">
        <mapentry name="username">
          <xsl:value-of select="@user"/>
        </mapentry>
      </xsl:if>
      <xsl:if test="@userFieldName != ''">
        <mapentry name="usernameField">
          <xsl:value-of select="@userFieldName"/>
        </mapentry>
      </xsl:if>
    </map>
  </xsl:template>
</xsl:stylesheet>

Finally, open a wallet in KDE wallet (I use version 1.7 as of this writing) and import the XML file resulting from the XSL transformation with File > Import XML.... Done.

This entry was posted in XML. Bookmark the permalink.

3 Responses to "Import Mozilla Firefox passwords in KDE wallet"

Leave a reply