DeserializationAgentVMClassCheck.java 2.31 KB
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  org.apache.felix.scr.annotations.Component
 *  org.apache.felix.scr.annotations.Properties
 *  org.apache.felix.scr.annotations.Property
 *  org.apache.felix.scr.annotations.Reference
 *  org.apache.felix.scr.annotations.Service
 *  org.apache.sling.hc.api.HealthCheck
 *  org.apache.sling.hc.api.Result
 *  org.apache.sling.hc.api.ResultLog
 *  org.apache.sling.hc.util.FormattingResultLog
 */
package com.adobe.cq.deserfw.impl.healthcheck;

import com.adobe.cq.deserfw.impl.intapi.DeserializationFirewallStatus;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Properties;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.hc.api.HealthCheck;
import org.apache.sling.hc.api.Result;
import org.apache.sling.hc.api.ResultLog;
import org.apache.sling.hc.util.FormattingResultLog;

@Service(value={HealthCheck.class})
@Component
@Properties(value={@Property(name="hc.name", value={"Deserialization Firewall Attach API Readiness"}), @Property(name="hc.tags", value={"deserialization", "security"}), @Property(name="hc.mbean.name", value={"Deserialization Firewall Attach API Readiness"})})
public class DeserializationAgentVMClassCheck
implements HealthCheck {
    @Reference
    private DeserializationFirewallStatus firewall;

    public Result execute() {
        FormattingResultLog log = new FormattingResultLog();
        if (this.firewall.isVMClassReady(log)) {
            log.info("Deserialization firewall Attach API Readiness is in an acceptable state", new Object[0]);
        } else {
            log.healthCheckError("Deserialization firewall was not able to detect the VirtualMachine class of the Attach API. Please see error log for nested exception details.", new Object[0]);
        }
        return new Result((ResultLog)log);
    }

    protected void bindFirewall(DeserializationFirewallStatus deserializationFirewallStatus) {
        this.firewall = deserializationFirewallStatus;
    }

    protected void unbindFirewall(DeserializationFirewallStatus deserializationFirewallStatus) {
        if (this.firewall == deserializationFirewallStatus) {
            this.firewall = null;
        }
    }
}