001// Generated by delombok at Mon Oct 12 23:00:28 BST 2020
002/*
003 *  Licensed to the Apache Software Foundation (ASF) under one
004 *  or more contributor license agreements.  See the NOTICE file
005 *  distributed with this work for additional information
006 *  regarding copyright ownership.  The ASF licenses this file
007 *  to you under the Apache License, Version 2.0 (the
008 *  "License"); you may not use this file except in compliance
009 *  with the License.  You may obtain a copy of the License at
010 *
011 *        http://www.apache.org/licenses/LICENSE-2.0
012 *
013 *  Unless required by applicable law or agreed to in writing,
014 *  software distributed under the License is distributed on an
015 *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
016 *  KIND, either express or implied.  See the License for the
017 *  specific language governing permissions and limitations
018 *  under the License.
019 */
020package org.apache.isis.extensions.secman.api.permission;
021
022import java.util.Collection;
023import java.util.Collections;
024import org.apache.isis.commons.internal.collections._Lists;
025
026/**
027 * An implementation whereby a VETO permission for a feature overrides an ALLOW (for same scope).
028 */
029public class PermissionsEvaluationServiceVetoBeatsAllow extends PermissionsEvaluationServiceAbstract {
030    private static final long serialVersionUID = 1L;
031
032    /**
033     * Reverses the natural order of the {@link org.apache.isis.extensions.secman.api.permission.ApplicationPermissionValue}s.
034
035     *
036
037     * <p>
038
039     *     This implementation relies on the fact that the {@link org.apache.isis.extensions.secman.api.permission.ApplicationPermissionValue}s are
040
041     * passed through in natural order, with the leading part based on the
042
043     * {@link org.apache.isis.extensions.secman.api.permission.ApplicationPermissionValue#getRule() rule} and with
044
045     * {@link ApplicationPermissionRule} in turn comparable so that {@link ApplicationPermissionRule#ALLOW allow}
046
047     * is ordered before {@link ApplicationPermissionRule#VETO veto}.
048
049     * </p>
050     */
051    @Override
052    protected Collection<ApplicationPermissionValue> ordered(final Collection<ApplicationPermissionValue> permissionValues) {
053        final java.util.ArrayList<org.apache.isis.extensions.secman.api.permission.ApplicationPermissionValue> reversed = _Lists.<ApplicationPermissionValue>newArrayList(permissionValues);
054        Collections.reverse(reversed);
055        return reversed;
056    }
057}