X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=src%2Fde%2Fj32%2Favmfritz%2FLoginXML.java;h=c5ec76bf1462b7dd76e71194b0898e2a749010c1;hb=e4126a1787b7045a53f6074e9ef15681c9f5fde4;hp=82766c3dc2fc349bdd8edf8f9fc81b39b0b82e55;hpb=276d9a69fa796728169c2992921a1e4bd875f549;p=jpim.git diff --git a/src/de/j32/avmfritz/LoginXML.java b/src/de/j32/avmfritz/LoginXML.java index 82766c3..c5ec76b 100644 --- a/src/de/j32/avmfritz/LoginXML.java +++ b/src/de/j32/avmfritz/LoginXML.java @@ -16,59 +16,60 @@ import de.j32.util.XmlUtil; public class LoginXML { - Document xml_; - - public LoginXML(InputStream is) - throws SAXException, IOException - { - xml_ = XmlUtil.parse(is); - } - - public boolean iswriteaccess() - throws SAXException - { - try { - return xml_.getElementsByTagName("iswriteaccess").item(0).getTextContent().equals("1"); - } - catch (NullPointerException e) { - throw new SAXException(); - } - } - - public String sid() - throws SAXException - { - try { - return Util.nonnull(xml_.getElementsByTagName("SID").item(0).getTextContent()); - } - catch (NullPointerException e) { - throw new SAXException(); - } - } - - public String challenge() - throws SAXException - { - try { - return Util.nonnull(xml_.getElementsByTagName("Challenge").item(0).getTextContent()); - } - catch (NullPointerException e) { - throw new SAXException(); - } - } - - public String response(String password) - throws SAXException - { - try { - String c = challenge(); - MessageDigest md = MessageDigest.getInstance("MD5"); - md.update((c + "-" + password).getBytes("UTF-16LE")); - return c + "-" + new HexBinaryAdapter().marshal(md.digest()).toLowerCase(); - } catch (NoSuchAlgorithmException e) { - throw new AssertionError("missing MD5 implementation"); - } catch (UnsupportedEncodingException e) { - throw new AssertionError("missing UTF-16LE encoding"); - } - } + Document xml_; + + public LoginXML(InputStream is) throws SAXException, IOException + { + xml_ = XmlUtil.parse(is); + } + + public boolean iswriteaccess() throws SAXException + { + try { + return xml_.getElementsByTagName("iswriteaccess").item(0) + .getTextContent().equals("1"); + } + catch (NullPointerException e) { + throw new SAXException(); + } + } + + public String sid() throws SAXException + { + try { + return Util.nonnull(xml_.getElementsByTagName("SID").item(0) + .getTextContent()); + } + catch (NullPointerException e) { + throw new SAXException(); + } + } + + public String challenge() throws SAXException + { + try { + return Util.nonnull(xml_.getElementsByTagName("Challenge").item(0) + .getTextContent()); + } + catch (NullPointerException e) { + throw new SAXException(); + } + } + + public String response(String password) throws SAXException + { + try { + String c = challenge(); + MessageDigest md = MessageDigest.getInstance("MD5"); + md.update((c + "-" + password).getBytes("UTF-16LE")); + return c + "-" + + new HexBinaryAdapter().marshal(md.digest()).toLowerCase(); + } + catch (NoSuchAlgorithmException e) { + throw new AssertionError("missing MD5 implementation"); + } + catch (UnsupportedEncodingException e) { + throw new AssertionError("missing UTF-16LE encoding"); + } + } }