use of net.sf.kraken.registration.RegistrationHandler in project Openfire by igniterealtime.
the class TransportSession method sessionDisconnectedNoReconnect.
/**
* Should be called when a session has been disconnected but no reconnect attempt should be made.
*
* It is also called internally by sessionDisconnected to handle total failed attempt.
*
* @param errorMessage Error message to send, or null if no message.
*/
public void sessionDisconnectedNoReconnect(String errorMessage) {
Log.debug("Disconnecting session " + getJID() + " from " + getTransport().getJID());
try {
cleanUp();
} catch (Exception e) {
Log.info("sessionDisconnectedNoReconnect: Error=" + e);
}
setLoginStatus(TransportLoginStatus.LOGGED_OUT);
if (getRegistrationPacket() != null) {
new RegistrationHandler(getTransport()).completeRegistration(this);
} else {
Presence p = new Presence(Presence.Type.unavailable);
p.setTo(getJID());
p.setFrom(getTransport().getJID());
getTransport().sendPacket(p);
if (errorMessage != null) {
getTransport().sendMessage(getJIDWithHighestPriority(), getTransport().getJID(), errorMessage, Message.Type.error);
}
getBuddyManager().sendOfflineForAllAvailablePresences(getJID());
}
buddyManager.resetBuddies();
getTransport().getSessionManager().removeSession(getJID());
}
use of net.sf.kraken.registration.RegistrationHandler in project Openfire by igniterealtime.
the class ConfigManager method deleteRegistration.
/**
* Deletes a registration via the web interface.
*
* @param registrationID ID number associated with registration to delete.
* @return Error message or null on success.
*/
public String deleteRegistration(Integer registrationID) {
PluginManager pluginManager = XMPPServer.getInstance().getPluginManager();
KrakenPlugin plugin = (KrakenPlugin) pluginManager.getPlugin("kraken");
try {
Registration reg = new Registration(registrationID);
if (!plugin.getTransportInstance(reg.getTransportType().toString()).isEnabled()) {
return LocaleUtils.getLocalizedString("gateway.web.registrations.notenabled", "kraken");
}
final BaseTransport transport = plugin.getTransportInstance(reg.getTransportType().toString()).getTransport();
new RegistrationHandler(transport).deleteRegistration(reg.getJID());
return null;
} catch (NotFoundException e) {
// Ok, nevermind.
Log.error("Not found while deleting id " + registrationID, e);
return LocaleUtils.getLocalizedString("gateway.web.registrations.xmppnotfound", "kraken");
} catch (UserNotFoundException e) {
// Ok, nevermind.
Log.error("Not found while deleting id " + registrationID, e);
return LocaleUtils.getLocalizedString("gateway.web.registrations.regnotfound", "kraken");
}
}
use of net.sf.kraken.registration.RegistrationHandler in project Openfire by igniterealtime.
the class BaseTransport method processPacket.
/**
* Handles all incoming iq stanzas.
*
* @param packet The iq packet to be processed.
* @return list of packets that will be sent back to the IQ requester.
*/
private List<Packet> processPacket(IQ packet) {
Log.debug("Received iq packet: " + packet.toXML());
List<Packet> reply = new ArrayList<Packet>();
if (packet.getType() == IQ.Type.error) {
// Lets not start a loop. Ignore.
return reply;
}
String xmlns = null;
Element child = (packet).getChildElement();
if (child != null) {
xmlns = child.getNamespaceURI();
}
if (xmlns == null) {
// No namespace defined.
Log.debug("No XMLNS:" + packet.toString());
IQ error = IQ.createResultIQ(packet);
error.setError(Condition.bad_request);
reply.add(error);
return reply;
}
if (xmlns.equals(NameSpace.DISCO_INFO)) {
reply.addAll(handleDiscoInfo(packet));
} else if (xmlns.equals(NameSpace.DISCO_ITEMS)) {
reply.addAll(handleDiscoItems(packet));
} else if (xmlns.equals(NameSpace.IQ_GATEWAY)) {
reply.addAll(handleIQGateway(packet));
} else if (xmlns.equals(NameSpace.IQ_REGISTER)) {
// could/should be made more generic.
try {
// note that this handler does not make use of the reply-queue.
// Instead, it sends packets directly.
new RegistrationHandler(this).process(packet);
} catch (UnauthorizedException ex) {
final IQ result = IQ.createResultIQ(packet);
result.setError(Condition.forbidden);
reply.add(result);
final Message em = new Message();
em.setType(Message.Type.error);
em.setTo(packet.getFrom());
em.setFrom(packet.getTo());
em.setBody(ex.getMessage());
reply.add(em);
}
} else if (xmlns.equals(NameSpace.IQ_VERSION)) {
reply.addAll(handleIQVersion(packet));
} else if (xmlns.equals(NameSpace.VCARD_TEMP) && child.getName().equals("vCard")) {
reply.addAll(handleVCardTemp(packet));
} else if (xmlns.equals(NameSpace.IQ_ROSTER)) {
// No reason to 'argue' about this one. Return success.
reply.add(IQ.createResultIQ(packet));
} else if (xmlns.equals(NameSpace.IQ_LAST)) {
reply.addAll(handleIQLast(packet));
} else {
Log.debug("Unable to handle iq request: " + xmlns);
IQ error = IQ.createResultIQ(packet);
error.setError(Condition.service_unavailable);
reply.add(error);
}
return reply;
}
use of net.sf.kraken.registration.RegistrationHandler in project Openfire by igniterealtime.
the class ConfigManager method addRegistration.
/**
* Adds a new registration via the web interface.
*
* @param user Username or full JID of user who is getting an account registered.
* @param transportType Type of transport to add user to.
* @param legacyUsername User's username on the legacy service.
* @param legacyPassword User's password on the legacy service.
* @param legacyNickname User's nickname on the legacy service.
* @return Error message or null on success.
*/
public String addRegistration(String user, String transportType, String legacyUsername, String legacyPassword, String legacyNickname) {
PluginManager pluginManager = XMPPServer.getInstance().getPluginManager();
KrakenPlugin plugin = (KrakenPlugin) pluginManager.getPlugin("kraken");
JID jid;
if (user.contains("@")) {
jid = new JID(user);
} else {
jid = new JID(user, XMPPServer.getInstance().getServerInfo().getXMPPDomain(), null);
}
if (!plugin.getTransportInstance(transportType).isEnabled()) {
return LocaleUtils.getLocalizedString("gateway.web.registrations.notenabled", "kraken");
}
try {
final BaseTransport transport = plugin.getTransportInstance(transportType).getTransport();
new RegistrationHandler(transport).addNewRegistration(jid, legacyUsername, legacyPassword, legacyNickname, false);
return null;
} catch (UserNotFoundException e) {
Log.error("Not found while adding account for " + jid.toString());
return LocaleUtils.getLocalizedString("gateway.web.registrations.xmppnotfound", "kraken");
} catch (IllegalAccessException e) {
Log.error("Domain of JID specified for registration is not on this server: " + jid.toString());
return LocaleUtils.getLocalizedString("gateway.web.registrations.illegaldomain", "kraken");
} catch (IllegalArgumentException e) {
Log.error("Username specified for registration is not valid.");
return LocaleUtils.getLocalizedString("gateway.web.registrations.invaliduser", "kraken");
}
}
use of net.sf.kraken.registration.RegistrationHandler in project Openfire by igniterealtime.
the class TransportSession method setLoginStatus.
/**
* Updates the login status.
*
* If there is a pending presence set, it will automatically commit the pending presence.
*
* @param status New login status.
*/
public void setLoginStatus(TransportLoginStatus status) {
loginStatus = status;
if (status.equals(TransportLoginStatus.LOGGED_IN)) {
reconnectionAttempts = 0;
setFailureStatus(ConnectionFailureReason.NO_ISSUE);
getRegistration().setLastLogin(new Date());
if (pendingPresence != null && pendingVerboseStatus != null) {
setPresenceAndStatus(pendingPresence, pendingVerboseStatus);
pendingPresence = null;
pendingVerboseStatus = null;
}
if (getRegistrationPacket() != null) {
new RegistrationHandler(getTransport()).completeRegistration(this);
}
}
}
Aggregations