Commit 45cc834a authored by akrherz's avatar akrherz Committed by Guus der Kinderen

enable whitelist/blacklist functionality on admin console

OF-1209, previously setting "Allowed to Connect" option was a NOOP
parent 57e24df5
......@@ -21,19 +21,22 @@
final ConnectionType connectionType = ConnectionType.SOCKET_S2S;
final ConnectionManagerImpl manager = (ConnectionManagerImpl) XMPPServer.getInstance().getConnectionManager();
pageContext.setAttribute("permissionPolicy", RemoteServerManager.getPermissionPolicy().toString());
final ConnectionConfiguration plaintextConfiguration = manager.getListener( connectionType, false ).generateConnectionConfiguration();
boolean update = request.getParameter( "update" ) != null;
boolean closeSettings = request.getParameter( "closeSettings" ) != null;
boolean serverAllowed = request.getParameter( "serverAllowed" ) != null;
boolean serverBlocked = request.getParameter( "serverBlocked" ) != null;
boolean permissionUpdate = request.getParameter( "permissionUpdate" ) != null;
String configToDelete = ParamUtils.getParameter( request, "deleteConf" );
final Map<String, String> errors = new HashMap<>();
Cookie csrfCookie = CookieUtils.getCookie(request, "csrf");
String csrfParam = ParamUtils.getParameter(request, "csrf");
if (update || closeSettings || serverAllowed || serverBlocked || configToDelete != null) {
if (update || closeSettings || serverAllowed || serverBlocked || permissionUpdate || configToDelete != null) {
if (csrfCookie == null || csrfParam == null || !csrfCookie.getValue().equals(csrfParam)) {
update = false;
closeSettings = false;
......@@ -63,6 +66,13 @@
webManager.logEvent( "Updated connection settings for " + connectionType, "plain: enabled=" + plaintextEnabled + ", port=" + plaintextTcpPort);
response.sendRedirect( "connection-settings-socket-s2s.jsp?success=update" );
}
else if ( permissionUpdate && errors.isEmpty() )
{
final String permissionFilter = ParamUtils.getParameter( request, "permissionFilter" );
RemoteServerManager.setPermissionPolicy(permissionFilter);
webManager.logEvent( "Updated s2s permission policy to: " + permissionFilter, null);
response.sendRedirect( "connection-settings-socket-s2s.jsp?success=update" );
}
else if ( closeSettings && errors.isEmpty() )
{
// TODO below is the 'idle connection' handing. This should go into the connection configuration, like all other configuration.
......@@ -352,7 +362,7 @@
<table cellpadding="3" cellspacing="0" border="0">
<tr valign="top">
<td width="1%" nowrap>
<input type="radio" name="permissionFilter" value="blacklist" id="rb05" ${'blacklist' eq param.permissionFilter ? 'checked' : ''}>
<input type="radio" name="permissionFilter" value="blacklist" id="rb05" ${permissionPolicy eq 'blacklist'? 'checked' : '' }>
</td>
<td width="99%">
<label for="rb05">
......@@ -362,7 +372,7 @@
</tr>
<tr valign="top">
<td width="1%" nowrap>
<input type="radio" name="permissionFilter" value="whitelist" id="rb06" ${'whitelist' eq param.permissionFilter ? 'checked' : ''}>
<input type="radio" name="permissionFilter" value="whitelist" id="rb06" ${permissionPolicy eq 'whitelist'? 'checked' : ''}>
</td>
<td width="99%">
<label for="rb06">
......@@ -486,4 +496,4 @@
<!-- END 'Not Allowed to Connect' -->
</body>
</html>
\ No newline at end of file
</html>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment