1. 注解bonita-server-rest web.xml,注解内容如下
<!--
<security-constraint>
<web-resource-collection>
<web-resource-name>BonitaSecuredMethods</web-resource-name>
<url-pattern>/API/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>restuser</role-name>
</auth-constraint>
</security-constraint>
<security-constraint>
<web-resource-collection>
<web-resource-name>BonitaUncheckedMethods</web-resource-name>
<url-pattern>/API/managementAPI/checkUserCredentials/*</url-pattern>
<url-pattern>/API/managementAPI/checkUserCredentialsWithPasswordHash/*</url-pattern>
<url-pattern>/API/webAPI/getIdentityKeyFromTemporaryToken/*</url-pattern>
</web-resource-collection>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>BonitaRESTServer</realm-name>
</login-config>
<security-role>
<role-name>restuser</role-name>
</security-role>
-->
2. 改写bonita-server-5.4.2.jar的org.ow2.bonita.facade.rest.interceptor.LoginPreProcessorInterceptor.java
1>下载路径 http://svn.bonitasoft.org/bonita-runtime/branches/bonita-runtime-5.4.2/bonita-server/src/main/java/org/ow2/bonita/facade/rest/interceptor/
2>改写代码
String encodedUserPassword = null;
if ( authorization !=null && authorization.size()>0){
encodedUserPassword = authorization.get(0).replaceFirst(AUTHENTICATION_SCHEME + " ", "");
} else {
List<String> userPassword = request.getDecodedFormParameters().get(AUTHORIZATION_PROPERTY);
if ( userPassword !=null )
encodedUserPassword = userPassword.get(0).replaceFirst(AUTHENTICATION_SCHEME + " ", "");
}
3. 访问
1>Rest 客户端软件
2>html 页面访问
<form action="http://127.0.0.1:9000/bonita-server-rest/API/identityAPI/getAllUsers" method="post">
<input type="hidden" name="Connection" value="keep-alive" />
<input type="hidden" name="Authorization" value="Basic cmVzdHVzZXI6cmVzdGJwbQ==" /> //这里可以通过Rest客户端工具来产生
<input type="hidden" name="options" value="user:admin" />
<input type="hidden" name="options" value="domain:http://127.0.0.1:9000/" />
<input type="submit" Value="Get All User" />
</form>