1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-06-30 23:36:47 +02:00

Fixed loading of vcard of other users when using an anonymous connection.

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@6452 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Gaston Dombiak 2006-12-20 22:05:38 +00:00 committed by gato
parent 694c7863bd
commit dd6f76fcac

View file

@ -471,7 +471,7 @@ public class VCard extends IQ {
* @throws XMPPException thrown if there was an issue setting the VCard in the server. * @throws XMPPException thrown if there was an issue setting the VCard in the server.
*/ */
public void save(XMPPConnection connection) throws XMPPException { public void save(XMPPConnection connection) throws XMPPException {
checkAuthenticated(connection); checkAuthenticated(connection, true);
setType(IQ.Type.SET); setType(IQ.Type.SET);
setFrom(connection.getUser()); setFrom(connection.getUser());
@ -495,7 +495,7 @@ public class VCard extends IQ {
* and not anonymous. * and not anonymous.
*/ */
public void load(XMPPConnection connection) throws XMPPException { public void load(XMPPConnection connection) throws XMPPException {
checkAuthenticated(connection); checkAuthenticated(connection, true);
setFrom(connection.getUser()); setFrom(connection.getUser());
doLoad(connection, connection.getUser()); doLoad(connection, connection.getUser());
@ -505,7 +505,7 @@ public class VCard extends IQ {
* Load VCard information for a given user. Connection should be authenticated and not anonymous. * Load VCard information for a given user. Connection should be authenticated and not anonymous.
*/ */
public void load(XMPPConnection connection, String user) throws XMPPException { public void load(XMPPConnection connection, String user) throws XMPPException {
checkAuthenticated(connection); checkAuthenticated(connection, false);
setTo(user); setTo(user);
doLoad(connection, user); doLoad(connection, user);
@ -561,14 +561,14 @@ public class VCard extends IQ {
} }
} }
private void checkAuthenticated(XMPPConnection connection) { private void checkAuthenticated(XMPPConnection connection, boolean checkForAnonymous) {
if (connection == null) { if (connection == null) {
throw new IllegalArgumentException("No connection was provided"); throw new IllegalArgumentException("No connection was provided");
} }
if (!connection.isAuthenticated()) { if (!connection.isAuthenticated()) {
throw new IllegalArgumentException("Connection is not authenticated"); throw new IllegalArgumentException("Connection is not authenticated");
} }
if (connection.isAnonymous()) { if (checkForAnonymous && connection.isAnonymous()) {
throw new IllegalArgumentException("Connection cannot be anonymous"); throw new IllegalArgumentException("Connection cannot be anonymous");
} }
} }