2010-03-17 195 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;  
}