Commit f06ab4b3 authored by Dave Cridland's avatar Dave Cridland Committed by GitHub

Merge pull request #855 from guusdk/OF-1369_No-IBR-with-readonly-userprovider

OF-1369: Skip IBR when readonly user provider
parents 732b7676 3093757e
...@@ -1395,6 +1395,8 @@ reg.settings.inband_account_info=Inband account registration allows users to cre ...@@ -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 \ 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 \ required to register by other means (e.g. sending requests to the server administrator or through \
your own custom web interface). 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.enable=Enabled
reg.settings.auto_create_user=Users can automatically create new accounts. reg.settings.auto_create_user=Users can automatically create new accounts.
reg.settings.disable=Disabled reg.settings.disable=Disabled
...@@ -1403,6 +1405,8 @@ reg.settings.change_password=Change Password ...@@ -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. \ 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 \ Password changing is independent from inband account registration. However, you may only \
want to disable this feature when disabling inband account registration. 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.can_change=Users can change their password.
reg.settings.cannot_change=Users are not allowed to change their password. reg.settings.cannot_change=Users are not allowed to change their password.
reg.settings.anonymous_login=Anonymous Login reg.settings.anonymous_login=Anonymous Login
......
...@@ -442,20 +442,32 @@ public class IQRegisterHandler extends IQHandler implements ServerFeaturesProvid ...@@ -442,20 +442,32 @@ public class IQRegisterHandler extends IQHandler implements ServerFeaturesProvid
return null; return null;
} }
public boolean isInbandRegEnabled() { public boolean isInbandRegEnabled()
return registrationEnabled; {
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; registrationEnabled = allowed;
JiveGlobals.setProperty("register.inband", registrationEnabled ? "true" : "false"); JiveGlobals.setProperty("register.inband", registrationEnabled ? "true" : "false");
} }
public boolean canChangePassword() { public boolean canChangePassword()
return 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; canChangePassword = allowed;
JiveGlobals.setProperty("register.password", canChangePassword ? "true" : "false"); JiveGlobals.setProperty("register.password", canChangePassword ? "true" : "false");
} }
......
...@@ -46,6 +46,7 @@ import org.jivesoftware.openfire.session.LocalClientSession; ...@@ -46,6 +46,7 @@ import org.jivesoftware.openfire.session.LocalClientSession;
import org.jivesoftware.openfire.spi.ConnectionConfiguration; import org.jivesoftware.openfire.spi.ConnectionConfiguration;
import org.jivesoftware.openfire.spi.ConnectionManagerImpl; import org.jivesoftware.openfire.spi.ConnectionManagerImpl;
import org.jivesoftware.openfire.spi.ConnectionType; import org.jivesoftware.openfire.spi.ConnectionType;
import org.jivesoftware.openfire.user.UserManager;
import org.jivesoftware.util.JiveConstants; import org.jivesoftware.util.JiveConstants;
import org.jivesoftware.util.JiveGlobals; import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.TaskEngine; import org.jivesoftware.util.TaskEngine;
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
<%@ page import="java.util.*" %> <%@ page import="java.util.*" %>
<%@ page import="org.jivesoftware.util.JiveGlobals" %> <%@ page import="org.jivesoftware.util.JiveGlobals" %>
<%@ page import="org.jivesoftware.openfire.net.SASLAuthentication" %> <%@ page import="org.jivesoftware.openfire.net.SASLAuthentication" %>
<%@ page import="org.jivesoftware.openfire.user.UserManager" %>
<%@ taglib uri="admin" prefix="admin" %> <%@ taglib uri="admin" prefix="admin" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
...@@ -158,6 +159,7 @@ ...@@ -158,6 +159,7 @@
} }
blockedIPs = buf2.toString(); blockedIPs = buf2.toString();
pageContext.setAttribute( "readOnly", UserManager.getUserProvider().isReadOnly() );
pageContext.setAttribute( "inbandEnabled", inbandEnabled ); pageContext.setAttribute( "inbandEnabled", inbandEnabled );
pageContext.setAttribute( "canChangePassword", canChangePassword ); pageContext.setAttribute( "canChangePassword", canChangePassword );
pageContext.setAttribute( "anonLogin", anonLogin ); pageContext.setAttribute( "anonLogin", anonLogin );
...@@ -183,16 +185,9 @@ ...@@ -183,16 +185,9 @@
<% if (save) { %> <% if (save) { %>
<div class="jive-success"> <admin:infoBox type="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">
<fmt:message key="reg.settings.update" /> <fmt:message key="reg.settings.update" />
</td></tr> </admin:infoBox>
</tbody>
</table>
</div><br>
<% } %> <% } %>
...@@ -201,13 +196,16 @@ ...@@ -201,13 +196,16 @@
<fmt:message key="reg.settings.inband_account" var="inband_account_boxtitle"/> <fmt:message key="reg.settings.inband_account" var="inband_account_boxtitle"/>
<admin:contentBox title="${inband_account_boxtitle}"> <admin:contentBox title="${inband_account_boxtitle}">
<p><fmt:message key="reg.settings.inband_account_info" /></p> <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"> <table cellpadding="3" cellspacing="0" border="0">
<tr> <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> <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>
<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> <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> </tr>
</table> </table>
...@@ -216,13 +214,16 @@ ...@@ -216,13 +214,16 @@
<fmt:message key="reg.settings.change_password" var="change_password_boxtitle"/> <fmt:message key="reg.settings.change_password" var="change_password_boxtitle"/>
<admin:contentBox title="${change_password_boxtitle}"> <admin:contentBox title="${change_password_boxtitle}">
<p><fmt:message key="reg.settings.change_password_info" /></p> <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"> <table cellpadding="3" cellspacing="0" border="0">
<tr> <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> <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>
<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> <td width="99%"><label for="rb04"><b><fmt:message key="reg.settings.disable" /></b> - <fmt:message key="reg.settings.cannot_change" /></label></td>
</tr> </tr>
</table> </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