Search in sources :

Example 1 with SerialNumber

use of lucee.runtime.security.SerialNumber in project Lucee by lucee.

the class XMLConfigAdmin method updateSerial.

public void updateSerial(String serial) throws PageException {
    checkWriteAccess();
    if (!(config instanceof ConfigServer)) {
        throw new SecurityException("can't change serial number from this context, access is denied");
    }
    Element root = doc.getDocumentElement();
    if (!StringUtil.isEmpty(serial)) {
        serial = serial.trim();
        if (!new SerialNumber(serial).isValid(serial))
            throw new SecurityException("serial number is invalid");
        root.setAttribute("serial-number", serial);
    } else {
        try {
            root.removeAttribute("serial-number");
        } catch (Throwable t) {
            ExceptionUtil.rethrowIfNecessary(t);
        }
    }
    try {
        root.removeAttribute("serial");
    } catch (Throwable t) {
        ExceptionUtil.rethrowIfNecessary(t);
    }
}
Also used : SerialNumber(lucee.runtime.security.SerialNumber) Element(org.w3c.dom.Element) SecurityException(lucee.runtime.exp.SecurityException)

Aggregations

SecurityException (lucee.runtime.exp.SecurityException)1 SerialNumber (lucee.runtime.security.SerialNumber)1 Element (org.w3c.dom.Element)1