Custom OWSM Security Policy for JAX-WS, GenericFault

I tried to create custom security and policies given here: http://download.oracle.com/docs/cd/E15523_01/relnotes.1111/e10132/owsm.htm#CIADFGGC

when I run the client client application, it succeeds.

   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); 
        } 
    } 

Console output:

public execute valid_ips 127.0.0.1,192.168.1.1 isPresent true result Succeeded public execute full

but webservice throws GenericFault.

Arguments: [void] Error: GenericFault: general error

I don’t know what could be wrong, any ideas?

here is the full stack trace:

"main" javax.xml.ws.soap.SOAPFaultException: GenericFault: com.sun.xml.internal.ws.fault.SOAP12Fault.getProtocolException(SOAP12Fault.java:210) com.sun.xml.internal.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:119) com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:108) com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:78) com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:107) $Proxy30.sayHello( ) creditproxy.CreditRatingSoap12HttpPortClient.main(CreditRatingSoap12HttpPortClient.java:21) : javax.xml.ws.soap.SOAPFaultException: GenericFault: weblogic.wsee.jaxws.framework.jaxrpc.TubeFactory $JAXRPCTube.processRequest(TubeFactory.java:203) weblogic.wsee.jaxws.tubeline.FlowControlTube.processRequest(FlowControlTube.java:99) com.sun.xml.ws.api.pipe.Fiber.__ doRun (Fiber.java:604) com.sun.xml.ws.api.pipe.Fiber._doRun (Fiber.java:563) com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:548) com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:445) 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.handle(HttpAdapter.java:250) com.sun.xml.ws.transport.http.servlet.ServletAdapter.handle(ServletAdapter.java:140) 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) weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292) weblogic.servlet.internal.TailFilter.doFilter(TailFilter.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) weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121) weblogic.servlet.internal.WebAppServletContext.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.

+3
3

. wls, , WSMMessageContext . IllegalArgumentExeception , , , "GenericFault: ", WSMAgentHook, . , , , Custom Security Assert. .

0

, 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;    
}
+1
        result.setFault(null);

. .

0
source

Source: https://habr.com/ru/post/1737287/


All Articles