Сервер идентификации WSO2 - отправка нескольких атрибутов в запросе в точку информации о настраиваемой политике (PIP) в WSO2IS

Я использую WSO2IS 5.3.0 и следую инструкциям на этом веб-сайте: https://docs.wso2.com/display/IS530/Writing+a+Custom+Policy+Info+Point

Я успешно реализовал собственный поиск атрибутов PIP (KMarketJDBCAttributeFinder), пока все хорошо. Проблема, с которой я столкнулся, заключается в том, что я хочу отправить более одного атрибута, но AttributeFinder выбирает только один. Далее моя политика и просьба:

Политика XACML:

<Policy xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17"
        xmlns:xacml="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17"
        PolicyId="My-Custom-Policy"
        RuleCombiningAlgId="urn:oasis:names:tc:xacml:1.0:rule-combining-algorithm:first-applicable"
        Version="1.0">
<Target>
  <AnyOf>
    <AllOf>
      <Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-regexp-match">
        <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">subj-id</AttributeValue>
        <AttributeDesignator
                MustBePresent="false"
                Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject"
                AttributeId="urn:oasis:names:tc:xacml:1.0:subject:subject-id"
                DataType="http://www.w3.org/2001/XMLSchema#string"/>
      </Match>
    </AllOf>
  </AnyOf>
</Target>
<Rule RuleId="rule1" Effect="Permit">
  <Target>
    <AnyOf>
      <AllOf>
        <Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
          <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">action-value</AttributeValue>
          <AttributeDesignator
                  MustBePresent="false"
                  Category="urn:oasis:names:tc:xacml:3.0:attribute-category:action"
                  AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id"
                  DataType="http://www.w3.org/2001/XMLSchema#string"/>
        </Match>
      </AllOf>
    </AnyOf>
  </Target>
  <Condition>
    <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:any-of">
      <Function FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-equal"/>
      <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">some-value-returned-by-custom-pip-finder-jar</AttributeValue>
      <AttributeDesignator
              Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource"
              AttributeId="urn:my:custom:id:data-one"
              DataType="http://www.w3.org/2001/XMLSchema#string"
              MustBePresent="false"/>
    </Apply>
  </Condition>
</Rule>
<Rule RuleId="rule2" Effect="Deny"/>
</Policy>

Запрос XACML:

<Request xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" CombinedDecision="false" ReturnPolicyIdList="false">
    <Attributes Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject">
        <Attribute AttributeId="urn:oasis:names:tc:xacml:1.0:subject:subject-id" IncludeInResult="false">
            <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">subj-id</AttributeValue>
        </Attribute>
    </Attributes>

    <Attributes Category="urn:oasis:names:tc:xacml:3.0:attribute-category:action">
        <Attribute AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id" IncludeInResult="false">
            <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">action-value</AttributeValue>
        </Attribute>
    </Attributes>

    <Attributes Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource">
        <Attribute AttributeId="urn:oasis:names:tc:xacml:1.0:resource:resource-id" IncludeInResult="false">
            <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">re-src-id</AttributeValue>
        </Attribute>
        <Attribute AttributeId="urn:my:custom:id:data-one" IncludeInResult="false">
            <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">data-one</AttributeValue>
        </Attribute>
        <Attribute AttributeId="urn:my:custom:id:data-two" IncludeInResult="false">
            <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">data-two</AttributeValue>
        </Attribute>
    </Attributes>
</Request>

Как видите, я отправляю три атрибута как часть категории ресурсов; но когда я отлаживаю код, я вижу только один из этих атрибутов (остальные игнорируются)

Кроме того, из запроса и политики я использовал таможенный AttributeId: urn:my:custom:id:data-one и urn:my:custom:id:data-two

¿Как я могу отправить несколько атрибутов (без использования опции «Несколько запросов», я только один, чтобы отправить один-единственный запрос) и подтвердить, что все атрибуты правильно получены моим настраиваемым расширением attributeFinder PIP?


person Edenshaw    schedule 08.03.2017    source источник


Ответы (1)


Анализируя код абстрактного класса, отвечающего за выбор атрибутов из запроса, метод, который создает набор атрибутов, выбирает только один; и таким образом мой тест не работает.

Решение, которое я нашел, заключалось в создании моего собственного абстрактного класса, реализующего класс PIPAttributeFinder, и получения всех атрибутов из запроса:

... (other code)

    List<String> resourceList = new ArrayList<String>();

    EvaluationResult resource = evaluationCtx.getAttribute(new URI("http://www.w3.org/2001/XMLSchema#string"), new URI("urn:oasis:names:tc:xacml:1.0:resource:resource-id"), issuer, new URI("urn:oasis:names:tc:xacml:3.0:attribute-category:resource"));
    if (resource != null && resource.getAttributeValue() != null && resource.getAttributeValue().isBag()) {
        key = (BagAttribute) resource.getAttributeValue();
        if (key.size() > 0) {
            Iterator iterator = key.iterator();
            String encodeAttribute = "";
            while(iterator.hasNext()) {
                AttributeValue attributeValue = (AttributeValue)iterator.next();
                encodeAttribute = attributeValue.encode();
                resourceList.add(encodeAttribute);
            }
            if (log.isDebugEnabled()) {
                log.debug(String.format("Finding attributes for the resource %1$s", new Object[]{encodeAttribute}));
            }
            resourceId = "empty-value";
        }
    }

... (other code)

    attributeValues = this.getAttributeValues(subjectId, resourceId, resourceList, actionId, environmentId, attributeId.toString(), issuer);

... (other code)

Имейте в виду, что вам нужно изменить подпись метода getAttributeValues

person Edenshaw    schedule 29.03.2017
comment
не могли бы вы поделиться полным образцом кода в ответе, например, что нужно вернуть в методе и абстрактном классе, который вы создали - person rahul; 02.07.2021