xmpp-compliance-tester

XMPP Compliance Tester, forked from github.com/iNPUTmice/ComplianceTester
git clone https://git.in0rdr.ch/xmpp-compliance-tester.git
Log | Files | Refs | Pull requests |Archive | README | LICENSE

commit a4caa69ccdda9578cf633a32a542d635ce8096ce
parent 93958748329decfd5785fd96ad0a971a1bdb7257
Author: Daniel Gultsch <daniel@gultsch.de>
Date:   Mon,  6 Jun 2016 12:51:24 +0200

save account passwords in accounts.xml for later use

Diffstat:
Asrc/main/java/eu/siacs/AccountStore.java | 45+++++++++++++++++++++++++++++++++++++++++++++
Msrc/main/java/eu/siacs/ComplianceTester.java | 19+++++++++++++++----
2 files changed, 60 insertions(+), 4 deletions(-)

diff --git a/src/main/java/eu/siacs/AccountStore.java b/src/main/java/eu/siacs/AccountStore.java @@ -0,0 +1,45 @@ +package eu.siacs; + +import rocks.xmpp.addr.Jid; + +import java.io.*; +import java.util.Properties; + +public class AccountStore { + + private static final File FILE = new File("accounts.xml"); + + public static String getPassword(Jid jid) { + Properties properties = new Properties(); + try { + properties.loadFromXML(new FileInputStream(FILE)); + return properties.getProperty(jid.asBareJid().toString()); + } catch (IOException e) { + return null; + } + } + + public static boolean storePassword(Jid jid, String password) { + Properties properties = new Properties(); + try { + properties.loadFromXML(new FileInputStream(FILE)); + } catch (FileNotFoundException e) { + try { + FILE.createNewFile(); + } catch (IOException e1) { + // + } + } catch (IOException e) { + //ignored + } + properties.put(jid.asBareJid().toString(),password); + try { + properties.storeToXML(new FileOutputStream(FILE),null); + return true; + } catch (IOException e) { + e.printStackTrace(); + return false; + } + } + +} diff --git a/src/main/java/eu/siacs/ComplianceTester.java b/src/main/java/eu/siacs/ComplianceTester.java @@ -13,12 +13,23 @@ public class ComplianceTester { public static void main(String[] args) { - if (args.length != 2) { - System.err.println("java -jar ComplianceTester.jar username@domain.tld password"); + Jid jid = Jid.of(args[0]); + String password; + if (args.length < 1 || args.length > 2) { + System.err.println("java -jar ComplianceTester.jar username@domain.tld [password]"); System.exit(1); + return; + } else if (args.length == 2) { + password = args[1]; + AccountStore.storePassword(jid, password); + } else { + password = AccountStore.getPassword(jid); + if (password == null) { + System.err.println("password for "+jid+ " was not stored"); + System.exit(1); + return; + } } - Jid jid = Jid.of(args[0]); - String password = args[1]; List<Class <? extends AbstractTestSuite>> testSuites = Arrays.asList( AdvancedServerCore.class, AdvancedServerIM.class,