2010-03-17 53 views
3

我試圖創建自定義的安全和策略如下給出: http://download.oracle.com/docs/cd/E15523_01/relnotes.1111/e10132/owsm.htm#CIADFGGCOWSM定製安全策略,GenericFault

當我運行該服務的客戶端自定義斷言

執行,成功返回。

public IResult execute(IContext context) throws WSMException { 
     try { 
      System.out.println("public execute"); 
      IAssertionBindings bindings = 
       ((SimpleAssertion)(this.assertion)).getBindings(); 
      IConfig config = bindings.getConfigs().get(0); 
      IPropertySet propertyset = config.getPropertySets().get(0); 
      String valid_ips = 
       propertyset.getPropertyByName("valid_ips").getValue(); 
      String ipAddr = ((IMessageContext)context).getRemoteAddr(); 
      IResult result = new Result(); 
      System.out.println("valid_ips "+valid_ips); 
      if (valid_ips != null && valid_ips.trim().length() > 0) { 
       String[] valid_ips_array = valid_ips.split(","); 
       boolean isPresent = false; 
       for (String valid_ip : valid_ips_array) { 
        if (ipAddr.equals(valid_ip.trim())) { 
         isPresent = true; 
        } 
       } 
       System.out.println("isPresent "+isPresent); 
       if (isPresent) { 
        result.setStatus(IResult.SUCCEEDED); 
       } else { 
        result.setStatus(IResult.FAILED); 
        result.setFault(new WSMException(WSMException.FAULT_FAILED_CHECK)); 
       } 
      } else { 
       result.setStatus(IResult.SUCCEEDED); 
      } 
      System.out.println("result "+result); 
      System.out.println("public execute complete"); 
      return result; 
     } catch (Exception e) { 
      System.out.println("Exception e"); 
      e.printStackTrace(); 

      throw new WSMException(WSMException.FAULT_FAILED_CHECK, e); 
     } 
    } 

控制檯輸出爲:

公共執行valid_ips 127.0.0.1,192.168.1.1 isPresent真實結果成功公共執行 完整

但是,Web服務拋出GenericFault。

參數:[空] 故障:GenericFault:一般錯誤

我不知道什麼可能是錯誤的,任何想法?

這裏是完整的堆棧跟蹤:

在線程異常 「主要」 javax.xml.ws.soap.SOAPFaultException: GenericFault:通用在 com.sun.xml.internal.ws錯誤(SOAPFaultBuilder.java:110) at com.sun.xml.internal.ws .client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:108) at com.sun.xml。 internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:78) at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:107) at $ Proxy30。在 weblogic.wsee.jaxws.framework一般錯誤:的sayHello(來源不明) 在 creditproxy.CreditRatingSoap12HttpPortClient.main(CreditRatingSoap12HttpPortClient.java:21) 造成的: javax.xml.ws.soap.SOAPFaultException: GenericFault。 jaxrpc.TubeFactory $ JAXRPCTube.processRequest(TubeFactory.java:203) 在 weblogic.wsee.jaxws.tubeline.FlowControlTube.processRequest(FlowControlTube.java:99) 在 com.sun.xml.ws.api.pipe。光纖.__ doRun (Fiber.java:604) at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:563) at com.sun.xml.ws.api.pipe.Fiber.doRun (Fiber.java:548) at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:445) at com.sun.xml.ws.server.WSEndpointImpl $ 2.process( WSEndpointImpl.java:275) 在 com.sun.xml.ws.transport.http.HttpAdapter $ HttpToolkit.handle(HttpAdapter.java:454) 在 com.sun.xml.ws.transport.http.HttpAdapter。句柄(HttpAdapter.java:250) at com.sun.xml.ws.transport.http.servlet.ServletAdapter.handle(ServletAdapter.java:140) at weblogic.wsee.jaxws.HttpServletAdapter $ AuthorizedInvoke.run(HttpServletAdapter.java:319) 在 weblogic.wsee.jaxws.HttpServletAdapter.post(HttpServletAdapter.java:232) 在 weblogic.wsee.jaxws.JAXWSServlet。的doPost(JAXWSServlet.java:310) 在 javax.servlet.http.HttpServlet.service(HttpServlet.java:727) 在 weblogic.wsee.jaxws.JAXWSServlet.service(JAXWSServlet.java:87) 在 的javax .servlet.http.HttpServlet.service(HttpServlet.java:820) 在 weblogic.servlet.internal.StubSecurityHelper $ ServletServiceAction.run(StubSecurityHelper.java:227) 在 weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper .java:125) at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292) at weblogic.servlet.internal.TailFilter.doFilter(TailFil ter.java:26) 在 weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) 在 oracle.dms.wls.DMSServletFilter.doFilter(DMSServletFilter.java:326) 在 weblogic.servlet .internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) 在 weblogic.servlet.internal.WebAppServletContext $ ServletInvocationAction.run(WebAppServletContext.java:3592) 在 weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject .java:321) at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121) at weblogic.servlet.internal.Web AppServletContext.securedExecute(WebAppServletContext.java:2202) 在 weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2108) 在 weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1432) 在 weblogic.work.ExecuteThread.execute(ExecuteThread.java:201) 在 weblogic.work.ExecuteThread.run(ExecuteThread.java:173) 過程退出,退出代碼1.

回答

0

我遇到了同樣的問題。深入瞭解wls類,我發現WSMMessageContext在主題中不包含正確的主體。並且事實上IllegalArgumentExeception被拋出,不幸的是,這個真正的異常被封裝包裝了很多次,我們可能會看到「GenericFault:generic error」,它是WSMAgentHook類中的最後一個,它在控制檯中執行輸出。不幸的是,我無法前進,似乎沒有人使用自定義安全聲明。所以沒有人可以幫助我們似乎

+0

@Yeah!似乎沒有人使用它...等待這麼多個月的任何答案。 – sachin 2010-12-03 16:11:36

0
 result.setFault(null); 

其中你正在設定成功的狀態。無論狀態的設置如何,它都使用故障值。

1

我有同樣的問題,但他們有Metalink解決方案(如果你還沒有看到它)。這將解決問題:

public IResult execute(IContext context) throws WSMException {  
    IResult result = new Result();   
    try {   
     oracle.wsm.common.sdk.IMessageContext.STAGE stage = ((oracle.wsm.common.sdk.IMessageContext)context).getStage();    
     if (stage == IMessageContext.STAGE.request) {  

      javax.security.auth.Subject subject = oracle.security.jps.util.SubjectUtil.getAnonymousSubject();     
      context.setProperty(oracle.wsm.common.sdk.IMessageContext.SECURITY_SUBJECT, subject);      
      IAssertionBindings bindings = ((SimpleAssertion)(this.assertion)).getBindings();    
      IConfig config = bindings.getConfigs().get(0);    
      IPropertySet propertyset = config.getPropertySets().get(0);     
      String valid_ips = propertyset.getPropertyByName("valid_ips").getValue();    
      String ipAddr = ((IMessageContext)context).getRemoteAddr(); 

      if (valid_ips != null && valid_ips.trim().length() > 0) {     
      String[] valid_ips_array = valid_ips.split(","); 
      boolean isPresent = false;      
      for (String valid_ip : valid_ips_array) {      
       if (ipAddr.equals(valid_ip.trim())) { 
        isPresent = true;      
       }      
      }     
      if (isPresent) {      
       result.setStatus(IResult.SUCCEEDED);      
      } else {       
       result.setStatus(IResult.FAILED);      
       result.setFault(new WSMException(WSMException.FAULT_FAILED_CHECK));      
      }    
      } else {     
       result.setStatus(IResult.SUCCEEDED);    
      }    
      return result;   
     }   
    } catch (Exception e) {    
     throw new WSMException(WSMException.FAULT_FAILED_CHECK, e);   
    }  
    return result;  
}