001/**
002 *
003 * Copyright 2014 Florian Schmaus
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 *     http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.jivesoftware.smack.sasl;
018
019import java.util.HashMap;
020import java.util.Map;
021
022import org.jivesoftware.smack.XMPPException;
023import org.jivesoftware.smack.sasl.packet.SaslNonza.SASLFailure;
024
025public class SASLErrorException extends XMPPException {
026
027    /**
028     *
029     */
030    private static final long serialVersionUID = 6247573875760717257L;
031
032    private final SASLFailure saslFailure;
033    private final String mechanism;
034    private final Map<String, String> texts;
035
036    public SASLErrorException(String mechanism, SASLFailure saslFailure) {
037        this(mechanism, saslFailure, new HashMap<String, String>());
038    }
039
040    public SASLErrorException(String mechanism, SASLFailure saslFailure, Map<String, String> texts) {
041        super("SASLError using " + mechanism + ": " + saslFailure.getSASLErrorString());
042        this.mechanism = mechanism;
043        this.saslFailure = saslFailure;
044        this.texts = texts;
045    }
046
047    public SASLFailure getSASLFailure() {
048        return saslFailure;
049    }
050
051    public String getMechanism() {
052        return mechanism;
053    }
054
055    public Map<String, String> getTexts() {
056        return texts;
057    }
058}