diff options
Diffstat (limited to 'src/com/isode/stroke/parser/AuthRequestParser.java')
-rw-r--r-- | src/com/isode/stroke/parser/AuthRequestParser.java | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/com/isode/stroke/parser/AuthRequestParser.java b/src/com/isode/stroke/parser/AuthRequestParser.java new file mode 100644 index 0000000..7f40c9c --- /dev/null +++ b/src/com/isode/stroke/parser/AuthRequestParser.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2010, Isode Limited, London, England. + * All rights reserved. + */ +/* + * Copyright (c) 2010, Remko Tron¨on. + * All rights reserved. + */ +package com.isode.stroke.parser; + +import com.isode.stroke.elements.AuthRequest; +import com.isode.stroke.stringcodecs.Base64; + +class AuthRequestParser extends GenericElementParser<AuthRequest> { + + public AuthRequestParser() { + super(AuthRequest.class); + } + + @Override + public void handleStartElement(String a, String b, AttributeMap attribute) { + if (depth_ == 0) { + getElementGeneric().setMechanism(attribute.getAttribute("mechanism")); + } + ++depth_; + } + + @Override + public void handleEndElement(String a, String b) { + --depth_; + if (depth_ == 0) { + getElementGeneric().setMessage(Base64.decode(text_)); + } + } + + @Override + public void handleCharacterData(String a) { + text_ += a; + } + String text_ = ""; + int depth_ = 0; +} |