class PossibleActionsRuleEngine {

    public EnumSet<PossibleActionEnum> getPossibleCertificateActions(TokenInfo tokenInfo,
            KeyInfo keyInfo,
            CertificateInfo certificateInfo) {
        EnumSet<PossibleActionEnum> actions = EnumSet.noneOf(PossibleActionEnum.class);
        boolean canUnregister = keyInfo.getUsage() == KeyUsageInfo.AUTHENTICATION
                && (CertificateInfo.STATUS_REGINPROG.equals(certificateInfo.getStatus())
                || CertificateInfo.STATUS_REGISTERED.equals(certificateInfo.getStatus()));
        if (canUnregister) {
            actions.add(PossibleActionEnum.UNREGISTER);
        }
        boolean savedToConfiguration = certificateInfo.isSavedToConfiguration();
        if (canDeleteCertOrCsr(tokenInfo, savedToConfiguration, canUnregister)) {
            actions.add(PossibleActionEnum.DELETE);
        }
        if (keyInfo.getUsage() == KeyUsageInfo.AUTHENTICATION
                && CertificateInfo.STATUS_SAVED.equals(certificateInfo.getStatus())
                && (!canUnregister)) {
            actions.add(PossibleActionEnum.REGISTER);
        }
        if (keyInfo.getUsage() != null && certificateInfo.isSavedToConfiguration()) {
            if (certificateInfo.isActive()) {
                actions.add(PossibleActionEnum.DISABLE);
            } else {
                actions.add(PossibleActionEnum.ACTIVATE);
            }
        }
        if (!certificateInfo.isSavedToConfiguration()) {
            // auth cert cannot be imported
            if (!isAuthCert(certificateInfo)) {
                actions.add(PossibleActionEnum.IMPORT_FROM_TOKEN);
            }
        }

        return actions;
    }

}