Normalize newlines to '\n'
Change all \r\n into unix style newlines. Add missing newlines at the end of a file and activate the newline checkstyle module, that enforces '\n' as newline and a newline at the end of every file.filetransferTypos
parent
1e57f1c659
commit
d069e1be64
@ -1,49 +1,49 @@
|
||||
/**
|
||||
*
|
||||
* Copyright 2009 the original author or authors
|
||||
*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* The AbstractConnectionListener class provides an empty implementation for all
|
||||
* methods defined by the {@link ConnectionListener} interface. This is a
|
||||
* convenience class which should be used in case you do not need to implement
|
||||
* all methods.
|
||||
*
|
||||
* @author Henning Staib
|
||||
*/
|
||||
public class AbstractConnectionListener implements ConnectionListener {
|
||||
|
||||
public void connectionClosed() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
public void connectionClosedOnError(Exception e) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
public void reconnectingIn(int seconds) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
public void reconnectionFailed(Exception e) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
public void reconnectionSuccessful() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
*
|
||||
* Copyright 2009 the original author or authors
|
||||
*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* The AbstractConnectionListener class provides an empty implementation for all
|
||||
* methods defined by the {@link ConnectionListener} interface. This is a
|
||||
* convenience class which should be used in case you do not need to implement
|
||||
* all methods.
|
||||
*
|
||||
* @author Henning Staib
|
||||
*/
|
||||
public class AbstractConnectionListener implements ConnectionListener {
|
||||
|
||||
public void connectionClosed() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
public void connectionClosedOnError(Exception e) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
public void reconnectingIn(int seconds) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
public void reconnectionFailed(Exception e) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
public void reconnectionSuccessful() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,140 +1,140 @@
|
||||
/**
|
||||
*
|
||||
* Copyright 2003-2007 Jive Software.
|
||||
*
|
||||
* 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;
|
||||
|
||||
import org.jivesoftware.smack.filter.PacketIDFilter;
|
||||
import org.jivesoftware.smack.packet.Authentication;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
|
||||
import javax.security.auth.callback.CallbackHandler;
|
||||
import javax.security.auth.callback.PasswordCallback;
|
||||
import javax.security.auth.callback.Callback;
|
||||
|
||||
/**
|
||||
* Implementation of JEP-0078: Non-SASL Authentication. Follow the following
|
||||
* <a href=http://www.jabber.org/jeps/jep-0078.html>link</a> to obtain more
|
||||
* information about the JEP.
|
||||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
class NonSASLAuthentication implements UserAuthentication {
|
||||
|
||||
private Connection connection;
|
||||
|
||||
public NonSASLAuthentication(Connection connection) {
|
||||
super();
|
||||
this.connection = connection;
|
||||
}
|
||||
|
||||
public String authenticate(String username, String resource, CallbackHandler cbh) throws XMPPException {
|
||||
//Use the callback handler to determine the password, and continue on.
|
||||
PasswordCallback pcb = new PasswordCallback("Password: ",false);
|
||||
try {
|
||||
cbh.handle(new Callback[]{pcb});
|
||||
return authenticate(username, String.valueOf(pcb.getPassword()),resource);
|
||||
} catch (Exception e) {
|
||||
throw new XMPPException("Unable to determine password.",e);
|
||||
}
|
||||
}
|
||||
|
||||
public String authenticate(String username, String password, String resource) throws
|
||||
XMPPException {
|
||||
// If we send an authentication packet in "get" mode with just the username,
|
||||
// the server will return the list of authentication protocols it supports.
|
||||
Authentication discoveryAuth = new Authentication();
|
||||
discoveryAuth.setType(IQ.Type.GET);
|
||||
discoveryAuth.setUsername(username);
|
||||
|
||||
PacketCollector collector =
|
||||
connection.createPacketCollector(new PacketIDFilter(discoveryAuth.getPacketID()));
|
||||
// Send the packet
|
||||
connection.sendPacket(discoveryAuth);
|
||||
// Wait up to a certain number of seconds for a response from the server.
|
||||
IQ response = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
|
||||
if (response == null) {
|
||||
throw new XMPPException("No response from the server.");
|
||||
}
|
||||
// If the server replied with an error, throw an exception.
|
||||
else if (response.getType() == IQ.Type.ERROR) {
|
||||
throw new XMPPException(response.getError());
|
||||
}
|
||||
// Otherwise, no error so continue processing.
|
||||
Authentication authTypes = (Authentication) response;
|
||||
collector.cancel();
|
||||
|
||||
// Now, create the authentication packet we'll send to the server.
|
||||
Authentication auth = new Authentication();
|
||||
auth.setUsername(username);
|
||||
|
||||
// Figure out if we should use digest or plain text authentication.
|
||||
if (authTypes.getDigest() != null) {
|
||||
auth.setDigest(connection.getConnectionID(), password);
|
||||
}
|
||||
else if (authTypes.getPassword() != null) {
|
||||
auth.setPassword(password);
|
||||
}
|
||||
else {
|
||||
throw new XMPPException("Server does not support compatible authentication mechanism.");
|
||||
}
|
||||
|
||||
auth.setResource(resource);
|
||||
|
||||
collector = connection.createPacketCollector(new PacketIDFilter(auth.getPacketID()));
|
||||
// Send the packet.
|
||||
connection.sendPacket(auth);
|
||||
// Wait up to a certain number of seconds for a response from the server.
|
||||
response = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
|
||||
if (response == null) {
|
||||
throw new XMPPException("Authentication failed.");
|
||||
}
|
||||
else if (response.getType() == IQ.Type.ERROR) {
|
||||
throw new XMPPException(response.getError());
|
||||
}
|
||||
// We're done with the collector, so explicitly cancel it.
|
||||
collector.cancel();
|
||||
|
||||
return response.getTo();
|
||||
}
|
||||
|
||||
public String authenticateAnonymously() throws XMPPException {
|
||||
// Create the authentication packet we'll send to the server.
|
||||
Authentication auth = new Authentication();
|
||||
|
||||
PacketCollector collector =
|
||||
connection.createPacketCollector(new PacketIDFilter(auth.getPacketID()));
|
||||
// Send the packet.
|
||||
connection.sendPacket(auth);
|
||||
// Wait up to a certain number of seconds for a response from the server.
|
||||
IQ response = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
|
||||
if (response == null) {
|
||||
throw new XMPPException("Anonymous login failed.");
|
||||
}
|
||||
else if (response.getType() == IQ.Type.ERROR) {
|
||||
throw new XMPPException(response.getError());
|
||||
}
|
||||
// We're done with the collector, so explicitly cancel it.
|
||||
collector.cancel();
|
||||
|
||||
if (response.getTo() != null) {
|
||||
return response.getTo();
|
||||
}
|
||||
else {
|
||||
return connection.getServiceName() + "/" + ((Authentication) response).getResource();
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
*
|
||||
* Copyright 2003-2007 Jive Software.
|
||||
*
|
||||
* 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;
|
||||
|
||||
import org.jivesoftware.smack.filter.PacketIDFilter;
|
||||
import org.jivesoftware.smack.packet.Authentication;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
|
||||
import javax.security.auth.callback.CallbackHandler;
|
||||
import javax.security.auth.callback.PasswordCallback;
|
||||
import javax.security.auth.callback.Callback;
|
||||
|
||||
/**
|
||||
* Implementation of JEP-0078: Non-SASL Authentication. Follow the following
|
||||
* <a href=http://www.jabber.org/jeps/jep-0078.html>link</a> to obtain more
|
||||
* information about the JEP.
|
||||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
class NonSASLAuthentication implements UserAuthentication {
|
||||
|
||||
private Connection connection;
|
||||
|
||||
public NonSASLAuthentication(Connection connection) {
|
||||
super();
|
||||
this.connection = connection;
|
||||
}
|
||||
|
||||
public String authenticate(String username, String resource, CallbackHandler cbh) throws XMPPException {
|
||||
//Use the callback handler to determine the password, and continue on.
|
||||
PasswordCallback pcb = new PasswordCallback("Password: ",false);
|
||||
try {
|
||||
cbh.handle(new Callback[]{pcb});
|
||||
return authenticate(username, String.valueOf(pcb.getPassword()),resource);
|
||||
} catch (Exception e) {
|
||||
throw new XMPPException("Unable to determine password.",e);
|
||||
}
|
||||
}
|
||||
|
||||
public String authenticate(String username, String password, String resource) throws
|
||||
XMPPException {
|
||||
// If we send an authentication packet in "get" mode with just the username,
|
||||
// the server will return the list of authentication protocols it supports.
|
||||
Authentication discoveryAuth = new Authentication();
|
||||
discoveryAuth.setType(IQ.Type.GET);
|
||||
discoveryAuth.setUsername(username);
|
||||
|
||||
PacketCollector collector =
|
||||
connection.createPacketCollector(new PacketIDFilter(discoveryAuth.getPacketID()));
|
||||
// Send the packet
|
||||
connection.sendPacket(discoveryAuth);
|
||||
// Wait up to a certain number of seconds for a response from the server.
|
||||
IQ response = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
|
||||
if (response == null) {
|
||||
throw new XMPPException("No response from the server.");
|
||||
}
|
||||
// If the server replied with an error, throw an exception.
|
||||
else if (response.getType() == IQ.Type.ERROR) {
|
||||
throw new XMPPException(response.getError());
|
||||
}
|
||||
// Otherwise, no error so continue processing.
|
||||
Authentication authTypes = (Authentication) response;
|
||||
collector.cancel();
|
||||
|
||||
// Now, create the authentication packet we'll send to the server.
|
||||
Authentication auth = new Authentication();
|
||||
auth.setUsername(username);
|
||||
|
||||
// Figure out if we should use digest or plain text authentication.
|
||||
if (authTypes.getDigest() != null) {
|
||||
auth.setDigest(connection.getConnectionID(), password);
|
||||
}
|
||||
else if (authTypes.getPassword() != null) {
|
||||
auth.setPassword(password);
|
||||
}
|
||||
else {
|
||||
throw new XMPPException("Server does not support compatible authentication mechanism.");
|
||||
}
|
||||
|
||||
auth.setResource(resource);
|
||||
|
||||
collector = connection.createPacketCollector(new PacketIDFilter(auth.getPacketID()));
|
||||
// Send the packet.
|
||||
connection.sendPacket(auth);
|
||||
// Wait up to a certain number of seconds for a response from the server.
|
||||
response = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
|
||||
if (response == null) {
|
||||
throw new XMPPException("Authentication failed.");
|
||||
}
|
||||
else if (response.getType() == IQ.Type.ERROR) {
|
||||
throw new XMPPException(response.getError());
|
||||
}
|
||||
// We're done with the collector, so explicitly cancel it.
|
||||
collector.cancel();
|
||||
|
||||
return response.getTo();
|
||||
}
|
||||
|
||||
public String authenticateAnonymously() throws XMPPException {
|
||||
// Create the authentication packet we'll send to the server.
|
||||
Authentication auth = new Authentication();
|
||||
|
||||
PacketCollector collector =
|
||||
connection.createPacketCollector(new PacketIDFilter(auth.getPacketID()));
|
||||
// Send the packet.
|
||||
connection.sendPacket(auth);
|
||||
// Wait up to a certain number of seconds for a response from the server.
|
||||
IQ response = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
|
||||
if (response == null) {
|
||||
throw new XMPPException("Anonymous login failed.");
|
||||
}
|
||||
else if (response.getType() == IQ.Type.ERROR) {
|
||||
throw new XMPPException(response.getError());
|
||||
}
|
||||
// We're done with the collector, so explicitly cancel it.
|
||||
collector.cancel();
|
||||
|
||||
if (response.getTo() != null) {
|
||||
return response.getTo();
|
||||
}
|
||||
else {
|
||||
return connection.getServiceName() + "/" + ((Authentication) response).getResource();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,46 +1,46 @@
|
||||
/**
|
||||
*
|
||||
* Copyright 2003-2007 Jive Software.
|
||||
*
|
||||
* 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;
|
||||
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.cert.X509Certificate;
|
||||
|
||||
/**
|
||||
* Dummy trust manager that trust all certificates presented by the server. This class
|
||||
* is used during old SSL connections.
|
||||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
class OpenTrustManager implements X509TrustManager {
|
||||
|
||||
public OpenTrustManager() {
|
||||
}
|
||||
|
||||
public X509Certificate[] getAcceptedIssuers() {
|
||||
return new X509Certificate[0];
|
||||
}
|
||||
|
||||
public void checkClientTrusted(X509Certificate[] arg0, String arg1)
|
||||
throws CertificateException {
|
||||
}
|
||||
|
||||
public void checkServerTrusted(X509Certificate[] arg0, String arg1)
|
||||
throws CertificateException {
|
||||
}
|
||||
}
|
||||
/**
|
||||
*
|
||||
* Copyright 2003-2007 Jive Software.
|
||||
*
|
||||
* 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;
|
||||
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.cert.X509Certificate;
|
||||
|
||||
/**
|
||||
* Dummy trust manager that trust all certificates presented by the server. This class
|
||||
* is used during old SSL connections.
|
||||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
class OpenTrustManager implements X509TrustManager {
|
||||
|
||||
public OpenTrustManager() {
|
||||
}
|
||||
|
||||
public X509Certificate[] getAcceptedIssuers() {
|
||||
return new X509Certificate[0];
|
||||
}
|
||||
|
||||
public void checkClientTrusted(X509Certificate[] arg0, String arg1)
|
||||
throws CertificateException {
|
||||
}
|
||||
|
||||
public void checkServerTrusted(X509Certificate[] arg0, String arg1)
|
||||
throws CertificateException {
|
||||
}
|
||||
}
|
||||
|
@ -1,47 +1,47 @@
|
||||
/**
|
||||
*
|
||||
* Copyright 2003-2005 Jive Software.
|
||||
*
|
||||
* 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;
|
||||
|
||||
import org.jivesoftware.smack.packet.Packet;
|
||||
|
||||
/**
|
||||
* Provides a mechanism to intercept and modify packets that are going to be
|
||||
* sent to the server. PacketInterceptors are added to the {@link Connection}
|
||||
* together with a {@link org.jivesoftware.smack.filter.PacketFilter} so that only
|
||||
* certain packets are intercepted and processed by the interceptor.<p>
|
||||
*
|
||||
* This allows event-style programming -- every time a new packet is found,
|
||||
* the {@link #interceptPacket(Packet)} method will be called.
|
||||
*
|
||||
* @see Connection#addPacketInterceptor(PacketInterceptor, org.jivesoftware.smack.filter.PacketFilter)
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public interface PacketInterceptor {
|
||||
|
||||
/**
|
||||
* Process the packet that is about to be sent to the server. The intercepted
|
||||
* packet can be modified by the interceptor.<p>
|
||||
*
|
||||
* Interceptors are invoked using the same thread that requested the packet
|
||||
* to be sent, so it's very important that implementations of this method
|
||||
* not block for any extended period of time.
|
||||
*
|
||||
* @param packet the packet to is going to be sent to the server.
|
||||
*/
|
||||
public void interceptPacket(Packet packet);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* Copyright 2003-2005 Jive Software.
|
||||
*
|
||||
* 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;
|
||||
|
||||
import org.jivesoftware.smack.packet.Packet;
|
||||
|
||||
/**
|
||||
* Provides a mechanism to intercept and modify packets that are going to be
|
||||
* sent to the server. PacketInterceptors are added to the {@link Connection}
|
||||
* together with a {@link org.jivesoftware.smack.filter.PacketFilter} so that only
|
||||
* certain packets are intercepted and processed by the interceptor.<p>
|
||||
*
|
||||
* This allows event-style programming -- every time a new packet is found,
|
||||
* the {@link #interceptPacket(Packet)} method will be called.
|
||||
*
|
||||
* @see Connection#addPacketInterceptor(PacketInterceptor, org.jivesoftware.smack.filter.PacketFilter)
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public interface PacketInterceptor {
|
||||
|
||||
/**
|
||||
* Process the packet that is about to be sent to the server. The intercepted
|
||||
* packet can be modified by the interceptor.<p>
|
||||
*
|
||||
* Interceptors are invoked using the same thread that requested the packet
|
||||
* to be sent, so it's very important that implementations of this method
|
||||
* not block for any extended period of time.
|
||||
*
|
||||
* @param packet the packet to is going to be sent to the server.
|
||||
*/
|
||||
public void interceptPacket(Packet packet);
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,40 +1,40 @@
|
||||
/**
|
||||
*
|
||||
* Copyright the original author or authors
|
||||
*
|
||||
* 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;
|
||||
|
||||
public enum SmackError {
|
||||
NO_RESPONSE_FROM_SERVER("No response from server.");
|
||||
|
||||
private String message;
|
||||
|
||||
private SmackError(String errMessage) {
|
||||
message = errMessage;
|
||||
}
|
||||
|
||||
public String getErrorMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public static SmackError getErrorCode(String message) {
|
||||
for (SmackError code : values()) {
|
||||
if (code.message.equals(message)) {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
/**
|
||||
*
|
||||
* Copyright the original author or authors
|
||||
*
|
||||
* 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;
|
||||
|
||||
public enum SmackError {
|
||||
NO_RESPONSE_FROM_SERVER("No response from server.");
|
||||
|
||||
private String message;
|
||||
|
||||
private SmackError(String errMessage) {
|
||||
message = errMessage;
|
||||
}
|
||||
|
||||
public String getErrorMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public static SmackError getErrorCode(String message) {
|
||||
for (SmackError code : values()) {
|
||||
if (code.message.equals(message)) {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -1,76 +1,76 @@
|
||||
/**
|
||||
*
|
||||
* Copyright 2003-2007 Jive Software.
|
||||
*
|
||||
* 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;
|
||||
|
||||
import javax.security.auth.callback.CallbackHandler;
|
||||
|
||||
/**
|
||||
* There are two ways to authenticate a user with a server. Using SASL or Non-SASL
|
||||
* authentication. This interface makes {@link SASLAuthentication} and
|
||||
* {@link NonSASLAuthentication} polyphormic.
|
||||
*
|
||||
* @author Gaston Dombiak
|
||||
* @author Jay Kline
|
||||
*/
|
||||
interface UserAuthentication {
|
||||
|
||||
/**
|
||||
* Authenticates the user with the server. This method will return the full JID provided by
|
||||
* the server. The server may assign a full JID with a username and resource different than
|
||||
* requested by this method.
|
||||
*
|
||||
* Note that using callbacks is the prefered method of authenticating users since it allows
|
||||
* more flexability in the mechanisms used.
|
||||
*
|
||||
* @param username the requested username (authorization ID) for authenticating to the server
|
||||
* @param resource the requested resource.
|
||||
* @param cbh the CallbackHandler used to obtain authentication ID, password, or other
|
||||
* information
|
||||
* @return the full JID provided by the server while binding a resource for the connection.
|
||||
* @throws XMPPException if an error occurs while authenticating.
|
||||
*/
|
||||
String authenticate(String username, String resource, CallbackHandler cbh) throws
|
||||
XMPPException;
|
||||
|
||||
/**
|
||||
* Authenticates the user with the server. This method will return the full JID provided by
|
||||
* the server. The server may assign a full JID with a username and resource different than
|
||||
* the requested by this method.
|
||||
*
|
||||
* It is recommended that @{link #authenticate(String, String, CallbackHandler)} be used instead
|
||||
* since it provides greater flexability in authenticaiton and authorization.
|
||||
*
|
||||
* @param username the username that is authenticating with the server.
|
||||
* @param password the password to send to the server.
|
||||
* @param resource the desired resource.
|
||||
* @return the full JID provided by the server while binding a resource for the connection.
|
||||
* @throws XMPPException if an error occures while authenticating.
|
||||
*/
|
||||
String authenticate(String username, String password, String resource) throws
|
||||
XMPPException;
|
||||
|
||||
/**
|
||||
* Performs an anonymous authentication with the server. The server will created a new full JID
|
||||
* for this connection. An exception will be thrown if the server does not support anonymous
|
||||
* authentication.
|
||||
*
|
||||
* @return the full JID provided by the server while binding a resource for the connection.
|
||||
* @throws XMPPException if an error occures while authenticating.
|
||||
*/
|
||||
String authenticateAnonymously() throws XMPPException;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* Copyright 2003-2007 Jive Software.
|
||||
*
|
||||
* 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;
|
||||
|
||||
import javax.security.auth.callback.CallbackHandler;
|
||||
|
||||
/**
|
||||
* There are two ways to authenticate a user with a server. Using SASL or Non-SASL
|
||||
* authentication. This interface makes {@link SASLAuthentication} and
|
||||
* {@link NonSASLAuthentication} polyphormic.
|
||||
*
|
||||
* @author Gaston Dombiak
|
||||
* @author Jay Kline
|
||||
*/
|
||||
interface UserAuthentication {
|
||||
|
||||
/**
|
||||
* Authenticates the user with the server. This method will return the full JID provided by
|
||||
* the server. The server may assign a full JID with a username and resource different than
|
||||
* requested by this method.
|
||||
*
|
||||
* Note that using callbacks is the prefered method of authenticating users since it allows
|
||||
* more flexability in the mechanisms used.
|
||||
*
|
||||
* @param username the requested username (authorization ID) for authenticating to the server
|
||||
* @param resource the requested resource.
|
||||
* @param cbh the CallbackHandler used to obtain authentication ID, password, or other
|
||||
* information
|
||||
* @return the full JID provided by the server while binding a resource for the connection.
|
||||
* @throws XMPPException if an error occurs while authenticating.
|
||||
*/
|
||||
String authenticate(String username, String resource, CallbackHandler cbh) throws
|
||||
XMPPException;
|
||||
|
||||
/**
|
||||
* Authenticates the user with the server. This method will return the full JID provided by
|
||||
* the server. The server may assign a full JID with a username and resource different than
|
||||
* the requested by this method.
|
||||
*
|
||||
* It is recommended that @{link #authenticate(String, String, CallbackHandler)} be used instead
|
||||
* since it provides greater flexability in authenticaiton and authorization.
|
||||
*
|
||||
* @param username the username that is authenticating with the server.
|
||||
* @param password the password to send to the server.
|
||||
* @param resource the desired resource.
|
||||
* @return the full JID provided by the server while binding a resource for the connection.
|
||||
* @throws XMPPException if an error occures while authenticating.
|
||||
*/
|
||||
String authenticate(String username, String password, String resource) throws
|
||||
XMPPException;
|
||||
|
||||
/**
|
||||
* Performs an anonymous authentication with the server. The server will created a new full JID
|
||||
* for this connection. An exception will be thrown if the server does not support anonymous
|
||||
* authentication.
|
||||
*
|
||||
* @return the full JID provided by the server while binding a resource for the connection.
|
||||
* @throws XMPPException if an error occures while authenticating.
|
||||
*/
|
||||
String authenticateAnonymously() throws XMPPException;
|
||||
}
|
||||
|
@ -1,45 +1,45 @@
|
||||
/**
|
||||
*
|
||||
* Copyright 2003-2006 Jive Software.
|
||||
*
|
||||
* 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.filter;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.Packet;
|
||||
|
||||
/**
|
||||
* A filter for IQ packet types. Returns true only if the packet is an IQ packet
|
||||
* and it matches the type provided in the constructor.
|
||||
*
|
||||
* @author Alexander Wenckus
|
||||
*
|
||||
*/
|
||||
public class IQTypeFilter implements PacketFilter {
|
||||
|
||||
private IQ.Type type;
|
||||
|
||||
public IQTypeFilter(IQ.Type type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.jivesoftware.smack.filter.PacketFilter#accept(org.jivesoftware.smack.packet.Packet)
|
||||
*/
|
||||
public boolean accept(Packet packet) {
|
||||
return (packet instanceof IQ && ((IQ) packet).getType().equals(type));
|
||||
}
|
||||
}
|
||||
/**
|
||||
*
|
||||
* Copyright 2003-2006 Jive Software.
|
||||
*
|
||||
* 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.filter;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.Packet;
|
||||
|
||||
/**
|
||||
* A filter for IQ packet types. Returns true only if the packet is an IQ packet
|
||||
* and it matches the type provided in the constructor.
|
||||
*
|
||||
* @author Alexander Wenckus
|
||||
*
|
||||
*/
|
||||
public class IQTypeFilter implements PacketFilter {
|
||||
|
||||
private IQ.Type type;
|
||||
|
||||
public IQTypeFilter(IQ.Type type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.jivesoftware.smack.filter.PacketFilter#accept(org.jivesoftware.smack.packet.Packet)
|
||||
*/
|
||||
public boolean accept(Packet packet) {
|
||||
return (packet instanceof IQ && ((IQ) packet).getType().equals(type));
|
||||
}
|
||||
}
|
||||
|
@ -1,55 +1,55 @@
|
||||
/**
|
||||
*
|
||||
* Copyright the original author or authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||