Authzforce ABAC - Ошибка включения расширения постпроцессора результатов в домене

Я следую инструкциям по ссылке

1- Создан пакет jar расширения из класса TestCombinedDecisionXacmlJaxbResultPostprocessor, заменив тип на urn: ow2: authzforce: feature: pdp: result-postproc: xacml-json: default.

2- Поместите банку в каталог / opt / authzforce-ce-server / webapp / WEB-INF / lib.

3- Пытался включить расширение с помощью:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<pdpPropertiesUpdate xmlns="http://authzforce.github.io/rest-api-model/xmlns/authz/5">
 <feature 
 type="urn:ow2:authzforce:feature-type:pdp:result-postproc" 
 enabled="true">urn:ow2:authzforce:feature:pdp:result-postproc:xacml-json:default</feature>
 <rootPolicyRefExpression>root</rootPolicyRefExpression>
</pdpPropertiesUpdate>

и получил ответ:

<!doctype html><html lang="en"><head><title>HTTP Status 405 – Method Not Allowed</title><style type="text/css">body {font-family:Tahoma,Arial,sans-serif;
} h1, h2, h3, b {color:white;background-color:#525D76;
} h1 {font-size: 22px;
} h2 {font-size: 16px;
} h3 {font-size: 14px;
} p {font-size: 12px;
} a {color:black;
} .line {height: 1px;background-color:#525D76;border:none;
}</style></head><body><h1>HTTP Status 405 – Method Not Allowed</h1><hr class="line" /><p><b>Type</b> Status Report</p><p><b>Description</b> The method received in the request-line is known by the origin server but not supported by the target resource.</p><hr class="line" /><h3>Apache Tomcat/8.5.54 (Debian)</h3></body></html>

После этого я получаю HTTP-404 для всех запросов в домене. Вы можете предложить то, что мне не хватает? В чем основная причина этой проблемы?

Совместное использование исходного кода для пакета расширения:

public class PostprocessorLoader extends BaseXacmlJaxbResultPostprocessor  {
    private static final Set<String> FEATURES = ImmutableSet.of(DecisionResultPostprocessor.Features.XACML_MULTIPLE_DECISION_PROFILE_COMBINED_DECISION);
    private static final Response SIMPLE_INDETERMINATE_RESPONSE = new Response(
            Collections.singletonList(new Result(DecisionType.INDETERMINATE, new StatusHelper(XacmlStatusCode.PROCESSING_ERROR.value(), Optional.<String>empty()), null, null, null, null)));
    // private static final List<Result> INDETERMINATE_RESULT_SINGLETON_LIST_BECAUSE_NO_INDIVIDUAL = Collections.singletonList(new Result(DecisionType.INDETERMINATE, new StatusHelper(
    // StatusHelper.STATUS_PROCESSING_ERROR, "No <Result> to combine!"), null, null, null, null));
    private static final Response SIMPLE_PERMIT_RESPONSE = new Response(Collections.singletonList(new Result(DecisionType.PERMIT, StatusHelper.OK, null, null, null, null)));
    private static final Response SIMPLE_DENY_RESPONSE = new Response(Collections.singletonList(new Result(DecisionType.DENY, StatusHelper.OK, null, null, null, null)));
    private static final Response SIMPLE_NOT_APPLICABLE_RESPONSE = new Response(Collections.singletonList(new Result(DecisionType.NOT_APPLICABLE, StatusHelper.OK, null, null, null, null)));

    private PostprocessorLoader(final int clientRequestErrorVerbosityLevel) throws IllegalArgumentException {
        super(clientRequestErrorVerbosityLevel);
    }

    @Override
    public Set<String> getFeatures()
    {
        return FEATURES;
    }

    @Override
    public Response process(final Collection<Map.Entry<IndividualXacmlJaxbRequest, ? extends DecisionResult>> resultsByRequest)
    {
        System.out.println("#####################Inside process");
        if (resultsByRequest!=null){
            System.out.println(resultsByRequest.size());
        }else{
            System.out.println("#####################resultsByRequest is null!");
        }
        DecisionType combinedDecision = DecisionType.INDETERMINATE;
        for (final Map.Entry<? extends IndividualXacmlJaxbRequest, ? extends DecisionResult> resultEntry : resultsByRequest)
        {
            System.out.println("#####################resultEntry:"+resultEntry.getValue());
            final DecisionResult result = resultEntry.getValue();
            System.out.println("#####################getDecision:"+result.getDecision());
            if (result.getDecision() == DecisionType.INDETERMINATE)
            {
                // either all result must be indeterminate or we return Indeterminate as final result anyway
                return SIMPLE_INDETERMINATE_RESPONSE;
            }

            final ImmutableList<PepAction> pepActions = result.getPepActions();
            assert pepActions != null;

            if (!pepActions.isEmpty())
            {
                return SIMPLE_INDETERMINATE_RESPONSE;
            }

            final DecisionType individualDecision = result.getDecision();
            // if combinedDecision not initialized yet (indeterminate), set it to the result's decision
            if (combinedDecision == DecisionType.INDETERMINATE)
            {
                combinedDecision = individualDecision;
            } else
                // combinedDecision != Indeterminate
                if (individualDecision != combinedDecision)
                {
                    return SIMPLE_INDETERMINATE_RESPONSE;
                }
        }
        System.out.println("#####################Before CombinedDecision switch");
        try {
            System.out.printf("#####################process method!");
            //System.out.println(documentService.getIndividualHealthRoleByName("").toString());
        }catch(Exception ex){
            System.out.println("#####################process method err:"+ex.getCause());
        }

        switch (combinedDecision)
        {
            case PERMIT:
                return SIMPLE_PERMIT_RESPONSE;
            case DENY:
                return SIMPLE_DENY_RESPONSE;
            case NOT_APPLICABLE:
                return SIMPLE_NOT_APPLICABLE_RESPONSE;
            default:
                return SIMPLE_INDETERMINATE_RESPONSE;
        }
    }

    /**
     *
     * Factory for this type of result postprocessor filter that allows duplicate &lt;Attribute&gt; with same meta-data in the same &lt;Attributes&gt; element of a Request (complying with XACML 3.0
     * core spec, §7.3.3).
     *
     */
    public static final class Factory extends BaseXacmlJaxbResultPostprocessor.Factory
    {
        /**
         * ID of this {@link PdpExtension}
         */
        public static final String ID = "urn:ow2:authzforce:feature:pdp:result-postproc:xacml-json:default";

        /**
         * Constructor
         */
        public Factory()
        {
            super(ID);
        }

        @Override
        public DecisionResultPostprocessor<IndividualXacmlJaxbRequest, Response> getInstance(final int clientRequestErrorVerbosityLevel)
        {
            return new PostprocessorLoader(clientRequestErrorVerbosityLevel);
        }

    }
}

ПРИМЕЧАНИЕ. То же самое произошло, когда я поместил файл jar из maven artifactId = authzforce-ce-core-pdp-testutils в папку lib и попытался включить с помощью рекомендованного тела запроса в вышеупомянутой ссылке.


person Psyduck    schedule 24.05.2020    source источник
comment
@cdan может помочь   -  person David Brossard    schedule 25.05.2020
comment
Вы перезапустили Tomcat после шага 2? Не могли бы вы проверить журналы сервера (в / var / log / tomcat8), чтобы убедиться, что веб-приложение authzforce успешно развернуто без ошибок?   -  person cdan    schedule 26.05.2020
comment
Да, я перезапустил tomcat после # 2. Я вижу некоторые ошибки в /var/log/tomcat8/authzforce-ce/error.log: java.lang.IllegalArgumentException: Extension no.uio.sabac.bootstrap.PostprocessorLoader$Factory@c9b006 конфликтует с org.ow2.authzforce.core .pdp.io.xacml.json.BaseXacmlJsonResult Постпроцессор $ Factory @ 12402b6 зарегистрирован с тем же идентификатором: urn: ow2: authzforce: feature: pdp: result-postproc: xacml-json: default at org.ow2.authzforce.core.pdp. impl.PdpExtensions. ‹clinit› (PdpExtensions.java:110)   -  person Psyduck    schedule 27.05.2020
comment
хорошо, см. мой ответ сейчас, вы не можете использовать один и тот же идентификатор для двух разных реализаций.   -  person cdan    schedule 30.05.2020


Ответы (1)


Вы пытаетесь включить постпроцессор с идентификатором urn:ow2:authzforce:feature:pdp:result-postproc:xacml-json:default, который уже зарезервирован и предоставлен AuthzForce (для обработки ответа JSON в соответствии с профилем JSON XACML). Следовательно, вы не можете использовать один и тот же идентификатор для собственной реализации!

Так что измените идентификатор в своем коде (здесь просто пример, выберите свой собственный):

/**
  * ID of this {@link PdpExtension}
  */
public static final String ID = "my-own-postproc-id";

К вашему сведению, если все, что вам нужно, это функция CombinedDecision для XACML / XML, как кажется (но я могу ошибаться в том, чего вы пытаетесь достичь), это уже реализовано классом TestCombinedDecisionXacmlJaxbResultPostprocessor. Вам просто нужно развернуть JAR authzforce-ce-core-pdp-testutils в WEB-INF / lib (в той же версии, что и JAR authzforce-ce-core-pdp-engine), перезапустить и включить его, как вы это делали в шаг 3, но с идентификатором функции urn:ow2:authzforce:feature:pdp:result-postproc:xacml-xml:multiple:test-combined-decision.

person cdan    schedule 29.05.2020