mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-09-09 00:59:39 +02:00
Introduce SmackSaslException
This commit is contained in:
parent
bb759a136e
commit
b51a6c54e8
12 changed files with 161 additions and 100 deletions
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright © 2014 Florian Schmaus
|
||||
* Copyright © 2014-2019 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -31,7 +31,7 @@ import javax.security.sasl.Sasl;
|
|||
import javax.security.sasl.SaslClient;
|
||||
import javax.security.sasl.SaslException;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.SmackException.SmackSaslException;
|
||||
import org.jivesoftware.smack.sasl.SASLMechanism;
|
||||
|
||||
public abstract class SASLJavaXMechanism extends SASLMechanism {
|
||||
|
@ -42,15 +42,15 @@ public abstract class SASLJavaXMechanism extends SASLMechanism {
|
|||
public abstract String getName();
|
||||
|
||||
@Override
|
||||
public final void checkIfSuccessfulOrThrow() throws SmackException {
|
||||
public final void checkIfSuccessfulOrThrow() throws SmackSaslException {
|
||||
if (!sc.isComplete()) {
|
||||
throw new SmackException(getName() + " was not completed");
|
||||
throw new SmackSaslException(getName() + " was not completed");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void authenticateInternal()
|
||||
throws SmackException {
|
||||
throws SmackJavaxSaslException {
|
||||
String[] mechanisms = { getName() };
|
||||
Map<String, String> props = getSaslProps();
|
||||
String authzid = null;
|
||||
|
@ -100,38 +100,38 @@ public abstract class SASLJavaXMechanism extends SASLMechanism {
|
|||
});
|
||||
}
|
||||
catch (SaslException e) {
|
||||
throw new SmackException(e);
|
||||
throw new SmackJavaxSaslException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void authenticateInternal(CallbackHandler cbh)
|
||||
throws SmackException {
|
||||
throws SmackJavaxSaslException {
|
||||
String[] mechanisms = { getName() };
|
||||
Map<String, String> props = getSaslProps();
|
||||
try {
|
||||
sc = Sasl.createSaslClient(mechanisms, null, "xmpp", host, props, cbh);
|
||||
}
|
||||
catch (SaslException e) {
|
||||
throw new SmackException(e);
|
||||
throw new SmackJavaxSaslException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected byte[] getAuthenticationText() throws SmackException {
|
||||
protected byte[] getAuthenticationText() throws SmackJavaxSaslException {
|
||||
if (sc.hasInitialResponse()) {
|
||||
try {
|
||||
return sc.evaluateChallenge(new byte[0]);
|
||||
}
|
||||
catch (SaslException e) {
|
||||
throw new SmackException(e);
|
||||
throw new SmackJavaxSaslException(e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected byte[] evaluateChallenge(byte[] challenge) throws SmackException {
|
||||
protected byte[] evaluateChallenge(byte[] challenge) throws SmackJavaxSaslException {
|
||||
try {
|
||||
if (challenge != null) {
|
||||
return sc.evaluateChallenge(challenge);
|
||||
|
@ -141,7 +141,7 @@ public abstract class SASLJavaXMechanism extends SASLMechanism {
|
|||
}
|
||||
}
|
||||
catch (SaslException e) {
|
||||
throw new SmackException(e);
|
||||
throw new SmackJavaxSaslException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2019 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jivesoftware.smack.sasl.javax;
|
||||
|
||||
import javax.security.sasl.SaslException;
|
||||
|
||||
import org.jivesoftware.smack.SmackException.SmackSaslException;
|
||||
|
||||
public class SmackJavaxSaslException extends SmackSaslException {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final SaslException saslException;
|
||||
|
||||
public SmackJavaxSaslException(SaslException saslException) {
|
||||
super(saslException);
|
||||
this.saslException = saslException;
|
||||
}
|
||||
|
||||
public SaslException getSaslException() {
|
||||
return saslException;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue