Example usage for org.apache.commons.collections SetUtils EMPTY_SET

List of usage examples for org.apache.commons.collections SetUtils EMPTY_SET

Introduction

In this page you can find the example usage for org.apache.commons.collections SetUtils EMPTY_SET.

Prototype

Set EMPTY_SET

To view the source code for org.apache.commons.collections SetUtils EMPTY_SET.

Click Source Link

Document

An empty unmodifiable set.

Usage

From source file:com.capitalone.dashboard.evaluator.LibraryPolicyEvaluator.java

/**
 * Reusable method for constructing the LibraryPolicyAuditResponse object
 *
 * @param collectorItem Collector item/*  www.  j ava 2  s. co m*/
 * @param beginDate     Begin Date
 * @param endDate       End Date
 * @return SecurityReviewAuditResponse
 */
private LibraryPolicyAuditResponse getLibraryPolicyAuditResponse(CollectorItem collectorItem, long beginDate,
        long endDate) {
    List<LibraryPolicyResult> libraryPolicyResults = libraryPolicyResultsRepository
            .findByCollectorItemIdAndEvaluationTimestampIsBetweenOrderByTimestampDesc(collectorItem.getId(),
                    beginDate - 1, endDate + 1);

    LibraryPolicyAuditResponse libraryPolicyAuditResponse = new LibraryPolicyAuditResponse();

    if (CollectionUtils.isEmpty(libraryPolicyResults)) {
        libraryPolicyAuditResponse.addAuditStatus(LibraryPolicyAuditStatus.LIBRARY_POLICY_AUDIT_MISSING);
        return libraryPolicyAuditResponse;
    }

    LibraryPolicyResult returnPolicyResult = libraryPolicyResults.get(0);
    libraryPolicyAuditResponse.setLibraryPolicyResult(returnPolicyResult);
    libraryPolicyAuditResponse.setLastExecutionTime(returnPolicyResult.getEvaluationTimestamp());

    //threats by type
    Set<LibraryPolicyResult.Threat> securityThreats = !MapUtils.isEmpty(returnPolicyResult.getThreats())
            ? returnPolicyResult.getThreats().get(LibraryPolicyType.Security)
            : SetUtils.EMPTY_SET;
    Set<LibraryPolicyResult.Threat> licenseThreats = !MapUtils.isEmpty(returnPolicyResult.getThreats())
            ? returnPolicyResult.getThreats().get(LibraryPolicyType.License)
            : SetUtils.EMPTY_SET;

    boolean isOk = true;
    //License Threats
    if (licenseThreats.stream()
            .anyMatch(threat -> Objects.equals(threat.getLevel(), LibraryPolicyThreatLevel.Critical)
                    && hasViolations(threat))) {
        libraryPolicyAuditResponse
                .addAuditStatus(LibraryPolicyAuditStatus.LIBRARY_POLICY_FOUND_CRITICAL_LICENSE);
        isOk = false;
    }

    if (licenseThreats.stream()
            .anyMatch(threat -> Objects.equals(threat.getLevel(), LibraryPolicyThreatLevel.High)
                    && hasViolations(threat))) {
        libraryPolicyAuditResponse.addAuditStatus(LibraryPolicyAuditStatus.LIBRARY_POLICY_FOUND_HIGH_LICENSE);
        isOk = false;
    }

    //Security Threats
    if (securityThreats.stream()
            .anyMatch(threat -> Objects.equals(threat.getLevel(), LibraryPolicyThreatLevel.Critical)
                    && hasViolations(threat))) {
        libraryPolicyAuditResponse
                .addAuditStatus(LibraryPolicyAuditStatus.LIBRARY_POLICY_FOUND_CRITICAL_SECURITY);
        isOk = false;
    }

    if (securityThreats.stream()
            .anyMatch(threat -> Objects.equals(threat.getLevel(), LibraryPolicyThreatLevel.High)
                    && hasViolations(threat))) {
        libraryPolicyAuditResponse.addAuditStatus(LibraryPolicyAuditStatus.LIBRARY_POLICY_FOUND_HIGH_SECURITY);
        isOk = false;
    }

    if (isOk) {
        libraryPolicyAuditResponse.addAuditStatus(LibraryPolicyAuditStatus.LIBRARY_POLICY_AUDIT_OK);
    }

    return libraryPolicyAuditResponse;
}

From source file:org.efaps.ui.wicket.components.table.filter.PickerPanel.java

/**
 * @param _wicketId         wicket id for this component
 * @param _model            model/*from   w  w w  .  j ava  2s  .c  o  m*/
 * @throws EFapsException on error
 */
public PickerPanel(final String _wicketId, final IModel<UITableHeader> _model) throws EFapsException {
    super(_wicketId, _model);
    final UITableHeader tableHeader = (UITableHeader) super.getDefaultModelObject();
    this.add(new Label("checkAll", DBProperties.getProperty("FilterPage.All")));
    if (tableHeader.getUiHeaderObject() instanceof UITable) {
        final UITable table = (UITable) tableHeader.getUiHeaderObject();
        this.pickList = table.getFilterPickList(tableHeader);
        final TableFilter filter = table.getFilter(tableHeader);
        if (filter != null && filter.getFilterList() != null) {
            this.selected = filter.getFilterList();
        } else {
            this.selected = SetUtils.EMPTY_SET;
        }
    }
    final FilterListView checksList = new FilterListView("listview", getPickList());
    this.add(checksList);
}

From source file:pl.bcichecki.rms.services.impl.PrivilegesServiceImpl.java

@Override
@SuppressWarnings("unchecked")
public Set<PrivilegeType> getAuthenticatedUsersPrivileges() {
    Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
    if (authentication == null) {
        return SetUtils.EMPTY_SET;
    }/* ww  w.  j  av  a 2 s.co m*/
    Set<PrivilegeType> privileges = new HashSet<PrivilegeType>();
    for (GrantedAuthority g : authentication.getAuthorities()) {
        privileges.add(PrivilegeType.fromString(g.getAuthority()));
    }
    return privileges;
}