class SecurityServiceImpl extends RemoteServiceServlet implements SecurityService {

	@Override
	public boolean saveSettings(GUISecuritySettings settings) throws ServerException {
		Session session = ServiceUtil.checkMenu(getThreadLocalRequest(), Menu.SECURITY);

		boolean restartRequired = false;

		try {
			ContextProperties conf = Context.get().getProperties();

			if (session.getTenantId() == Tenant.DEFAULT_ID) {
				conf.setProperty("password.ttl", Integer.toString(settings.getPwdExpiration()));
				conf.setProperty("login.ignorecase", Boolean.toString(settings.isIgnoreLoginCase()));
				conf.setProperty("ssl.required", Boolean.toString(settings.isForceSsl()));
				conf.setProperty("security.acceptsid", Boolean.toString(settings.isAllowSidInRequest()));

				// Update the web.xml
				try {
					ServletContext context = getServletContext();
					String policy = "true".equals(conf.getProperty("ssl.required")) ? "CONFIDENTIAL" : "NONE";
					WebConfigurator configurator = new WebConfigurator(context.getRealPath("/WEB-INF/web.xml"));
					restartRequired = configurator.setTransportGuarantee(policy);
				} catch (Throwable t) {
					log.error(t.getMessage());
				}
			}

			conf.setProperty(session.getTenantName() + ".password.size", Integer.toString(settings.getPwdSize()));
			conf.setProperty(session.getTenantName() + ".gui.savelogin", Boolean.toString(settings.isSaveLogin()));
			conf.setProperty(session.getTenantName() + ".anonymous.enabled",
					Boolean.toString(settings.isEnableAnonymousLogin()));
			conf.setProperty(session.getTenantName() + ".anonymous.key", settings.getAnonymousKey().trim());

			if (settings.getAnonymousUser() != null)
				conf.setProperty(session.getTenantName() + ".anonymous.user",
						settings.getAnonymousUser().getUsername());

			conf.write();

			log.info("Security settings data written successfully.");

			return restartRequired;
		} catch (Throwable e) {
			return (Boolean) ServiceUtil.throwServerException(session, log, e);
		}
	}

}