summaryrefslogtreecommitdiffstats
blob: b56ff892d220902833f2daca65f2b8f0fa3d5131 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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;
}