Commit 3093757e authored by Guus der Kinderen's avatar Guus der Kinderen

OF-1369: Skip IBR when readonly user provider

There's no point in offering in-band registration when the user provider disallows any modifications.
parent f5eb85c3
......@@ -1395,6 +1395,8 @@ reg.settings.inband_account_info=Inband account registration allows users to cre
this web administration interface. Administrators may want to disable this option so users are \
required to register by other means (e.g. sending requests to the server administrator or through \
your own custom web interface).
reg.settings.inband_account_readonly=This instance of Openfire is set up to integrate with an external user provider, \
that is considered to be 'read-only'. Inband account registration is therefor not possible.
reg.settings.enable=Enabled
reg.settings.auto_create_user=Users can automatically create new accounts.
reg.settings.disable=Disabled
......@@ -1403,6 +1405,8 @@ reg.settings.change_password=Change Password
reg.settings.change_password_info=You can choose whether users are allowed to change their password. \
Password changing is independent from inband account registration. However, you may only \
want to disable this feature when disabling inband account registration.
reg.settings.change_password_readonly=This instance of Openfire is set up to integrate with an external user provider, \
that is considered to be 'read-only'. Users cannot change their passwords.
reg.settings.can_change=Users can change their password.
reg.settings.cannot_change=Users are not allowed to change their password.
reg.settings.anonymous_login=Anonymous Login
......
......@@ -442,20 +442,32 @@ public class IQRegisterHandler extends IQHandler implements ServerFeaturesProvid
return null;
}
public boolean isInbandRegEnabled() {
return registrationEnabled;
public boolean isInbandRegEnabled()
{
return registrationEnabled && !UserManager.getUserProvider().isReadOnly();
}
public void setInbandRegEnabled(boolean allowed) {
public void setInbandRegEnabled(boolean allowed)
{
if ( allowed && UserManager.getUserProvider().isReadOnly() )
{
Log.warn( "Enabling in-band registration has no effect, as the user provider for this system is read-only." );
}
registrationEnabled = allowed;
JiveGlobals.setProperty("register.inband", registrationEnabled ? "true" : "false");
}
public boolean canChangePassword() {
return canChangePassword;
public boolean canChangePassword()
{
return canChangePassword && !UserManager.getUserProvider().isReadOnly();
}
public void setCanChangePassword(boolean allowed) {
public void setCanChangePassword(boolean allowed)
{
if ( allowed && UserManager.getUserProvider().isReadOnly() )
{
Log.warn( "Allowing password changes has no effect, as the user provider for this system is read-only." );
}
canChangePassword = allowed;
JiveGlobals.setProperty("register.password", canChangePassword ? "true" : "false");
}
......
......@@ -46,6 +46,7 @@ import org.jivesoftware.openfire.session.LocalClientSession;
import org.jivesoftware.openfire.spi.ConnectionConfiguration;
import org.jivesoftware.openfire.spi.ConnectionManagerImpl;
import org.jivesoftware.openfire.spi.ConnectionType;
import org.jivesoftware.openfire.user.UserManager;
import org.jivesoftware.util.JiveConstants;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.TaskEngine;
......
......@@ -27,6 +27,7 @@
<%@ page import="java.util.*" %>
<%@ page import="org.jivesoftware.util.JiveGlobals" %>
<%@ page import="org.jivesoftware.openfire.net.SASLAuthentication" %>
<%@ page import="org.jivesoftware.openfire.user.UserManager" %>
<%@ taglib uri="admin" prefix="admin" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
......@@ -158,6 +159,7 @@
}
blockedIPs = buf2.toString();
pageContext.setAttribute( "readOnly", UserManager.getUserProvider().isReadOnly() );
pageContext.setAttribute( "inbandEnabled", inbandEnabled );
pageContext.setAttribute( "canChangePassword", canChangePassword );
pageContext.setAttribute( "anonLogin", anonLogin );
......@@ -183,16 +185,9 @@
<% if (save) { %>
<div class="jive-success">
<table cellpadding="0" cellspacing="0" border="0">
<tbody>
<tr><td class="jive-icon"><img src="images/success-16x16.gif" width="16" height="16" border="0" alt=""></td>
<td class="jive-icon-label">
<admin:infoBox type="success">
<fmt:message key="reg.settings.update" />
</td></tr>
</tbody>
</table>
</div><br>
</admin:infoBox>
<% } %>
......@@ -201,13 +196,16 @@
<fmt:message key="reg.settings.inband_account" var="inband_account_boxtitle"/>
<admin:contentBox title="${inband_account_boxtitle}">
<p><fmt:message key="reg.settings.inband_account_info" /></p>
<c:if test="${readOnly}">
<admin:infoBox type="info"><fmt:message key="reg.settings.inband_account_readonly" /></admin:infoBox>
</c:if>
<table cellpadding="3" cellspacing="0" border="0">
<tr>
<td width="1%"><input type="radio" name="inbandEnabled" value="true" id="rb01" ${inbandEnabled ? 'checked' : ''}></td>
<td width="1%"><input type="radio" name="inbandEnabled" value="true" id="rb01" ${inbandEnabled ? 'checked' : ''} ${readOnly ? 'disabled' : ''}></td>
<td width="99%"><label for="rb01"><b><fmt:message key="reg.settings.enable" /></b> -<fmt:message key="reg.settings.auto_create_user" /></label></td>
</tr>
<tr>
<td width="1%"><input type="radio" name="inbandEnabled" value="false" id="rb02" ${inbandEnabled ? '' : 'checked'}></td>
<td width="1%"><input type="radio" name="inbandEnabled" value="false" id="rb02" ${inbandEnabled ? '' : 'checked'} ${readOnly ? 'disabled' : ''}></td>
<td width="99%"><label for="rb02"><b><fmt:message key="reg.settings.disable" /></b> - <fmt:message key="reg.settings.not_auto_create" /></label></td>
</tr>
</table>
......@@ -216,13 +214,16 @@
<fmt:message key="reg.settings.change_password" var="change_password_boxtitle"/>
<admin:contentBox title="${change_password_boxtitle}">
<p><fmt:message key="reg.settings.change_password_info" /></p>
<c:if test="${readOnly}">
<admin:infoBox type="info"><fmt:message key="reg.settings.change_password_readonly" /></admin:infoBox>
</c:if>
<table cellpadding="3" cellspacing="0" border="0">
<tr>
<td width="1%"><input type="radio" name="canChangePassword" value="true" id="rb03" ${canChangePassword ? 'checked' : ''}></td>
<td width="1%"><input type="radio" name="canChangePassword" value="true" id="rb03" ${canChangePassword ? 'checked' : ''} ${readOnly ? 'disabled' : ''}></td>
<td width="99%"><label for="rb03"><b><fmt:message key="reg.settings.enable" /></b> - <fmt:message key="reg.settings.can_change" /></label></td>
</tr>
<tr>
<td width="1%"><input type="radio" name="canChangePassword" value="false" id="rb04" ${canChangePassword ? '' : 'checked'}></td>
<td width="1%"><input type="radio" name="canChangePassword" value="false" id="rb04" ${canChangePassword ? '' : 'checked'} ${readOnly ? 'disabled' : ''}></td>
<td width="99%"><label for="rb04"><b><fmt:message key="reg.settings.disable" /></b> - <fmt:message key="reg.settings.cannot_change" /></label></td>
</tr>
</table>
......
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