use of org.jivesoftware.util.ModificationNotAllowedException in project Openfire by igniterealtime.
the class ExternalComponentManager method setServicePort.
/**
* @param port The port to use
* @deprecated Obtain and use the corresponding {@link org.jivesoftware.openfire.spi.ConnectionListener} instead.
* @throws ModificationNotAllowedException if the server cannot be modified
*/
@Deprecated
public static void setServicePort(int port) throws ModificationNotAllowedException {
// Alert listeners about this event
for (ExternalComponentManagerListener listener : listeners) {
try {
listener.portChanged(port);
} catch (Exception e) {
Log.warn("An exception occurred while dispatching a 'portChanged' event!", e);
}
}
ConnectionManager connectionManager = XMPPServer.getInstance().getConnectionManager();
connectionManager.setComponentListenerPort(port);
}
use of org.jivesoftware.util.ModificationNotAllowedException in project Openfire by igniterealtime.
the class ExternalComponentManager method setServiceEnabled.
/**
* @param enabled enables or disables the service
* @deprecated Obtain and use the corresponding {@link org.jivesoftware.openfire.spi.ConnectionListener} instead.
* @throws ModificationNotAllowedException if the status of the service cannot be changed
*/
@Deprecated
public static void setServiceEnabled(boolean enabled) throws ModificationNotAllowedException {
// Alert listeners about this event
for (ExternalComponentManagerListener listener : listeners) {
try {
listener.serviceEnabled(enabled);
} catch (Exception e) {
Log.warn("An exception occurred while dispatching a 'serviceEnabled' event!", e);
}
}
ConnectionManager connectionManager = XMPPServer.getInstance().getConnectionManager();
connectionManager.enableComponentListener(enabled);
}
use of org.jivesoftware.util.ModificationNotAllowedException in project Openfire by igniterealtime.
the class ExternalComponentManager method blockAccess.
/**
* Blocks an external component from connecting to the local server. If the component was
* connected when the permission was revoked then the connection of the entity will be closed.
*
* @param subdomain the subdomain of the external component that is not allowed to connect.
* @throws ModificationNotAllowedException if the operation was denied.
*/
public static void blockAccess(String subdomain) throws ModificationNotAllowedException {
// Alert listeners about this event
for (ExternalComponentManagerListener listener : listeners) {
try {
listener.componentBlocked(subdomain);
} catch (Exception e) {
Log.warn("An exception occurred while dispatching a 'componentBlocked' event!", e);
}
}
// Remove any previous configuration for this external component
deleteConfigurationFromDB(getConfiguration(subdomain, false));
// Update the database with the new revoked permission
ExternalComponentConfiguration config = new ExternalComponentConfiguration(subdomain, false, Permission.blocked, null);
addConfiguration(config);
// Check if the component was connected and proceed to close the connection
String domain = subdomain + "." + XMPPServer.getInstance().getServerInfo().getXMPPDomain();
Session session = SessionManager.getInstance().getComponentSession(domain);
if (session != null) {
Log.debug("Closing session for external component '{}' as the domain is being blocked. Affected session: {}", domain, session);
session.close();
}
}
use of org.jivesoftware.util.ModificationNotAllowedException in project Openfire by igniterealtime.
the class ExternalComponentManager method setPermissionPolicy.
/**
* Sets the permission policy being used for new XMPP entities that are trying to
* connect to the server. There are two types of policies: 1) blacklist: where any entity
* is allowed to connect to the server except for those listed in the black list and
* 2) whitelist: where only the entities listed in the white list are allowed to connect to
* the server.
*
* @param policy the new PermissionPolicy to use.
* @throws ModificationNotAllowedException if the operation was denied.
*/
public static void setPermissionPolicy(PermissionPolicy policy) throws ModificationNotAllowedException {
// Alert listeners about this event
for (ExternalComponentManagerListener listener : listeners) {
try {
listener.permissionPolicyChanged(policy);
} catch (Exception e) {
Log.warn("An exception occurred while dispatching a 'permissionPolicyChanged' event!", e);
}
}
JiveGlobals.setProperty("xmpp.component.permission", policy.toString());
// Check if connected components can remain connected to the server
for (ComponentSession session : SessionManager.getInstance().getComponentSessions()) {
for (String domain : session.getExternalComponent().getSubdomains()) {
if (!canAccess(domain)) {
Log.debug("Closing session for external component '{}' as a changed permission policy is taken into effect. Affected session: {}", domain, session);
session.close();
break;
}
}
}
}
Aggregations