我正在尝试访问在localhost上的WSO2 IdentityServer上运行的EntitlementService。 我想评估IS用作XACML引擎。这只是概念验证代码和测试。
我尝试使用Java客户端和php客户端。
可以在这里下载的java代码: https://sites.google.com/site/securedecentralizedblog/is/EntitlementClient.java?attredirects=0&d=1
我只更改了wso2is相关内容的目录。运行它会在wso2is控制台中给出这些错误:
[2014-05-05 01:36:00,058] ERROR {org.wso2.carbon.core.services.authentication.AuthenticationAdmin} - Authentication Failed : Invalid remote address passed - https://localhost:9443/
[2014-05-05 01:36:29,127] WARN {org.wso2.carbon.core.services.authentication.AuthenticationUtil} - Could not find IP address for domain name : https://localhost:9443/
这似乎很奇怪,因为localhost通常会解析......
还尝试用手工制作的PHP脚本:
<?php
$context = stream_context_create(array(
'ssl' => array(
'verify_peer' => false,
'allow_self_signed' => true
)
));
$auth = array(
'trace' => true,
'login'=>'admin',
'password'=>'admin',
'stream_context'=>$context
);
$login_client = new SoapClient('https://localhost:9443/services/AuthenticationAdmin?wsdl',$auth);
$client = new SoapClient('https://localhost:9443/services/EntitlementService?wsdl',$auth);
$request = file_get_contents('../xacml_get_users.xml');
echo "\n\nGoing to start login call...\n\n";
try {
$login_response = $login_client->login($auth);
$response_headers = $login_client-> __getLastResponseHeaders();
$request_cookie = $login_client->_cookies;
$a_jsessionid = $request_cookie['JSESSIONID'];
$jsessionid = $a_jsessionid[0];
$cutstr = substr($response_headers,strpos($response_headers,'Set-Cookie: '));
$cookie = substr($cutstr,strlen('Set-Cookie: '));
$cookie = substr($cookie, 0, strpos($cookie,';'));
echo "\n\nGoing to start decision call...\n\n";
$cookie_name="JSESSIONID";
$cookie_value=$jsessionid;
$client->__setCookie($cookie_name, $cookie_value);
$client->getDecision($request);
} catch (Exception $e) {
echo $e->getMessage();
}
?>
我通过了登录呼叫,但是在“开始决定呼叫”之后,我在客户端收到此错误消息:
Error occurred while evaluating XACML request
在wso2is控制台中:
[2014-05-05 01:33:03,733] ERROR {org.wso2.carbon.identity.entitlement.EntitlementService} - Error occurred while evaluating XACML request
java.lang.NullPointerException
at org.wso2.carbon.identity.entitlement.cache.IdentityCacheKey.hashCode(IdentityCacheKey.java:62)
at java.util.concurrent.ConcurrentHashMap.hash(ConcurrentHashMap.java:333)
at java.util.concurrent.ConcurrentHashMap.containsKey(ConcurrentHashMap.java:1016)
at org.wso2.carbon.caching.impl.CacheImpl.containsKey(CacheImpl.java:260)
at org.wso2.carbon.identity.entitlement.cache.EntitlementBaseCache.getValueFromCache(EntitlementBaseCache.java:144)
at org.wso2.carbon.identity.entitlement.cache.DecisionCache.getFromCache(DecisionCache.java:49)
at org.wso2.carbon.identity.entitlement.pdp.EntitlementEngine.getFromCache(EntitlementEngine.java:384)
at org.wso2.carbon.identity.entitlement.pdp.EntitlementEngine.evaluate(EntitlementEngine.java:229)
at org.wso2.carbon.identity.entitlement.EntitlementService.getDecision(EntitlementService.java:51)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
可能出现什么问题?我需要这个工作,否则我们将无法为我们的项目选择wso2is。
此外,是否有针对此计划的REST API? 如果是,那么什么时候?
答案 0 :(得分:0)
这就是我最终似乎已经解决了它。 我使用了另一个可用的WSDL函数getDecisionByAttributes。
它仍会在wso2 IS服务器中产生一些奇怪的异常,但实际上我得到了回报 价值&#34;许可&#34;或&#34;拒绝&#34; (或&#34; Indeterminate&#34;)。
$context = stream_context_create(array(
'ssl' => array(
'verify_peer' => false,
'allow_self_signed' => true
)
));
$http_auth = array(
'trace' => true,
'login'=>'admin',
'password'=>'admin',
'stream_context'=>$context
);
$client = new SoapClient('https://localhost:9443/services/EntitlementService?wsdl',$http_auth);
try {
$res = $client->getDecisionByAttributes(array("subject"=>"okuser","resource"=>"https://api.example.org/api/v1/users","action"=>"GET"));
$xml = simplexml_load_string($res->return);
$decision = $xml->Result->Decision;;
echo $decision;
} catch (Exception $e) {
echo $e->getMessage();
}
答案 1 :(得分:0)
TryIt
也使用了Web服务方法......这意味着,当您从Web服务API发送请求时,它也必须工作..根据null pointer
,它似乎是您的SOAP消息中没有出现XACML请求。我想要从您的PHP客户端获取消息...另外,出于调试目的,您可以在WSO2IS中启用debug日志,这可以帮助您查看XACML请求/响应消息。
答案 2 :(得分:0)
在PHP脚本中,尝试替换
行$client->getDecision($request);
由:
$client->getDecision(["request" => $request]);
这应该处理你的NullPointerException。
这是因为根据WSDL,SOAP方法getDecision需要一个名为&#34; request&#34;的名为的参数,其中包含实际的XACML请求:
<xs:element name="getDecision">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="request" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>