class TPMBaselineGenerator {

    public final TpmWhiteListBaseline generateWhiteListBaselineOnKernelUpdate(
            final String baselineName, final IntegrityReport report, final int kernelPcrMask)
            throws NullPointerException {
        if (baselineName == null) {
            LOGGER.error("null argument: baselineName");
            throw new NullPointerException("baselineName");
        }

        LOGGER.debug("generating TPM baseline on kernel update from report");

        // Generate a temporary reference baseline from the given report.  The name can be blank.
        final TpmWhiteListBaseline referenceBaseline =
                generateBaselineFromIntegrityReport("", report);
        final Set<TPMMeasurementRecord> records = referenceBaseline.getPcrRecords();

        final TpmWhiteListBaseline newBaseline = new TpmWhiteListBaseline(baselineName);

        // Copy each of the kernel PCR values from the reference baseline to the new one
        for (final TPMMeasurementRecord record : records) {
            final int shifted = 1 << record.getPcrId();
            if ((shifted & kernelPcrMask) == shifted) {
                newBaseline.addToBaseline(record);
            }
        }

        LOGGER.debug("retrieving Device Info data from referenced baseline");

        // Copy the criteria from the device info report corroborated the kernel update.
        final OSInfo referenceOSInfo = referenceBaseline.getOSInfo();
        final HashMap<TPMBaselineFields, String> map = new HashMap<>();
        map.put(TPMBaselineFields.OS_NAME, referenceOSInfo.getOSName());
        map.put(TPMBaselineFields.OS_VERSION, referenceOSInfo.getOSVersion());
        final OSInfo osInfo = TPMBaselineFields.toOSInfo(map, new OSInfo());
        newBaseline.setOSInfo(osInfo);

        return newBaseline;
    }

}