use of lucee.runtime.net.ntp.NtpClient in project Lucee by lucee.
the class XMLConfigAdmin method updateTimeServer.
/**
* update the timeServer
* @param timeServer
* @param useTimeServer
* @throws PageException
*/
public void updateTimeServer(String timeServer, Boolean useTimeServer) throws PageException {
checkWriteAccess();
if (useTimeServer != null && useTimeServer.booleanValue() && !StringUtil.isEmpty(timeServer, true)) {
try {
new NtpClient(timeServer).getOffset();
} catch (IOException e) {
try {
new NtpClient(timeServer).getOffset();
} catch (IOException ee) {
throw Caster.toPageException(ee);
}
}
}
boolean hasAccess = ConfigWebUtil.hasAccess(config, SecurityManager.TYPE_SETTING);
if (!hasAccess)
throw new SecurityException("no access to update regional setting");
Element scope = _getRootElement("regional");
scope.setAttribute("timeserver", timeServer.trim());
if (useTimeServer != null)
scope.setAttribute("use-timeserver", Caster.toString(useTimeServer));
else
scope.removeAttribute("use-timeserver");
}
use of lucee.runtime.net.ntp.NtpClient in project Lucee by lucee.
the class ConfigImpl method reloadTimeServerOffset.
@Override
public void reloadTimeServerOffset() {
timeOffset = 0;
if (useTimeServer && !StringUtil.isEmpty(timeServer, true)) {
NtpClient ntp = new NtpClient(timeServer);
timeOffset = ntp.getOffset(0);
}
}
Aggregations