如何定制Bonita Rest, 去掉JAAS用户认证

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>

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值