2017-04-11 3 views
0

JBoss認可(@RolesAllowedおよび@SecurityDomain)の下でsoap/wsdlメッセージを使用してファイルを送信する際に問題があります。 @SecurityDomainや@RolesAllowedのアノテーションを有効にしない限り、以下のコードは機能します。私はJBossにユーザーを追加しました。他のすべてのWebサービスは正常に動作します(「hello」とかオブジェクトの配列を送信するなど)が、権限を復元しようとすると直ちにエラーがスローされます。 JBossを起動すると警告メッセージが表示されるので、私の現在のアイデアは何か理由があるかもしれませんが、一度作成しようとしましたが、まったく役に立たなかった(しかし、間違っているかもしれません)。また、WildFly管理コンソールでセキュリティ設定を操作しようとしましたが、アプリケーションレベルの認証を変更できるかどうかはわかりません。とにかく助けにはならなかった。JBoss authorization、javax.ws annotationsのsoap/wsdlメッセージにファイルを送信

import org.jboss.ejb3.annotation.SecurityDomain; 
import org.jboss.ws.api.annotation.WebContext; 

import javax.annotation.security.PermitAll; 
import javax.ejb.Stateless; 
import javax.jws.WebMethod; 
import javax.jws.WebParam; 
import javax.jws.WebResult; 
import javax.jws.WebService; 
import javax.xml.bind.annotation.XmlElement; 
import javax.xml.ws.soap.MTOM; 
import java.io.File; 
import java.io.FileInputStream; 
import java.io.FileNotFoundException; 
import java.io.IOException; 

@Stateless 
@WebService 
//@RolesAllowed("user") // < --if I put @PermitAll here, everything works ok 
//@SecurityDomain("other") 
//@WebContext(contextRoot="/lab-soa1c-soap", urlPattern="/*", authMethod="BASIC", transportGuarantee="NONE", secureWSDLAccess = false) 
//@javax.jws.soap.SOAPBinding(style= javax.jws.soap.SOAPBinding.Style.RPC) 
public class FileSenderApache { 

     //@PermitAll 
     //@MTOM(enabled = true, threshold = 2048) 
     @WebMethod(action = "apacheSend") 
     @WebResult(name = "fileSent") 

     public String Send (@WebParam(name = "path") String path){ 

      File file = new File(path); 

      String encodedfile = null; 
      try { 
       FileInputStream fileInputStreamReader = new FileInputStream(file); 
       byte[] bytes = new byte[(int) file.length()]; 
       System.out.println((int) file.length()); 
       System.out.println(file.length()); 
       fileInputStreamReader.read(bytes); 

       byte[] apacheBytes = org.apache.commons.codec.binary.Base64.encodeBase64(bytes); 
       encodedfile = new String(apacheBytes); 

     } catch (FileNotFoundException e) { 
       encodedfile = "File does not exist"; 
      } catch (IOException e) { 
       encodedfile = "Sending error"; 
      } 


      return encodedfile; 

     } 
} 

これは、クライアント側のコードです:

import javax.swing.*; 
import java.awt.*; 
import java.awt.image.BufferedImage; 

    public class Painter{ 
    BufferedImage image; 

    public Painter(final BufferedImage image) throws Exception 
    { 
     SwingUtilities.invokeLater(new Runnable() 
     { 
      public void run() 
      { 
       JFrame editorFrame = new JFrame("Image Demo"); 
       editorFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); 


       ImageIcon imageIcon = new ImageIcon(image); 
       JLabel jLabel = new JLabel(); 
       jLabel.setIcon(imageIcon); 
       editorFrame.getContentPane().add(jLabel, BorderLayout.CENTER); 

       editorFrame.pack(); 
       editorFrame.setLocationRelativeTo(null); 
       editorFrame.setVisible(true); 
     } 
     }); 
    } 
} 

もう1:ここでは

import client.*; 

import javax.xml.ws.BindingProvider; 
import java.awt.image.BufferedImage; 
import java.util.List; 
import client.Course; 

import client.Hello; 
import client.HelloService; 
import client.HelloWorld; 
import client.HelloWorldService; 
import client.ReceiveStudentArrayList; 
import client.ReceiveStudentArrayListService; 
import client.ReturnStudentHashMap2; 
import client.ReturnStudentHashMap2Service; 
import client.Student; 

import java.awt.image.BufferedImage; 
import java.util.List; 
import javax.xml.ws.BindingProvider; 

public class Main { 

     public static void main(String[] args) throws Exception { 

      System.out.println("-------------------PICTURE---------------------"); 

      FileSenderService fsas = new FileSenderService(); 
      FileSender fsa = fsas.getFileSenderPort(); 
      setCredentials((BindingProvider)fsa); 
      String img = fsa.send("/Users/user/SOAP_KUBA_2/lab-soa1c/lab-soa1c-soap/pics/images-3.jpeg"); 
      DecodeToImage dec = new DecodeToImage(); 
      BufferedImage image = DecodeToImage.decode(img); 
      new Painter(image); 

      System.out.println("------------------END OF PICTURE-----------------"); 
     } 

     private static void setCredentials(BindingProvider port) { 
      port.getRequestContext().put("javax.xml.ws.security.auth.username", "user"); 
      port.getRequestContext().put("javax.xml.ws.security.auth.password", "user"); 
     } 
    } 

は、クライアント側の追加クラスです

import java.awt.*; 

public class MyPanel extends Panel { 
    Image i; 

    public void paintImage(Graphics g, Image i){ 
     super.paint(g); 
     g.drawImage(i, 0, 0, 1920, 1200, Color.gray, null); 
    } 

    public void paint(Graphics g) 
    { 
     paintImage(g,i); 
    } 

    public void setImage(Image i) 
    { 
     this.i = i; 
    } 
} 

そして最後に1:

import sun.misc.BASE64Decoder; 

import javax.imageio.ImageIO; 
import java.awt.image.BufferedImage; 
import java.io.ByteArrayInputStream; 
import java.io.IOException; 

public class DecodeToImage { 
    public static BufferedImage decode(String imageString){ 
     BufferedImage image = null; 
     byte[] imageByte; 
     try{ 
      BASE64Decoder decoder = new BASE64Decoder(); 
      imageByte = decoder.decodeBuffer(imageString); 
      ByteArrayInputStream bis = new ByteArrayInputStream(imageByte); 
      image = ImageIO.read(bis); 
      bis.close(); 
     } catch (IOException e) { 
      e.printStackTrace(); 
     } 
     return image; 
    } 
} 

最後に、@RolesAllowed( "user")アノテーションを有効にしようとすると、このメッセージがスローされます。

Exception in thread "main"  com.sun.xml.internal.ws.fault.ServerSOAPFaultException: Client received SOAP Fault from server: WFLYEJB0364: Invocation on method: public java.lang.String pl.edu.agh.kis.FileSenderApache.Send(java.lang.String) of bean: FileSenderApache is not allowed Please see the server log to find more detail regarding exact cause of the failure. 
    at com.sun.xml.internal.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:178) 
    at com.sun.xml.internal.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:116) 
    at com.sun.xml.internal.ws.client.sei.StubHandler.readResponse(StubHandler.java:238) 
    at com.sun.xml.internal.ws.db.DatabindingImpl.deserializeResponse(DatabindingImpl.java:189) 
    at com.sun.xml.internal.ws.db.DatabindingImpl.deserializeResponse(DatabindingImpl.java:276) 
    at  com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:104) 
    at  com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:77) 
    at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:147) 
    at com.sun.proxy.$Proxy36.send(Unknown Source) 
    at pl.edu.kis.Main.main(Main.java:99) 

Serverログ:

12:12:44,768 ERROR [org.jboss.as.ejb3.invocation] (default task-19) WFLYEJB0034: EJB Invocation failed on component FileSenderApache for method public java.lang.String pl.edu.agh.kis.FileSenderApache.Send(java.lang.String): javax.ejb.EJBAccessException: WFLYEJB0364: Invocation on method: public java.lang.String pl.edu.agh.kis.FileSenderApache.Send(java.lang.String) of bean: FileSenderApache is not allowed 
    at org.jboss.as.ejb3.security.AuthorizationInterceptor.processInvocation(AuthorizationInterceptor.java:134) 
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) 
    at org.jboss.as.ejb3.security.SecurityContextInterceptor.processInvocation(SecurityContextInterceptor.java:100) 
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) 
    at org.jboss.as.ejb3.deployment.processors.StartupAwaitInterceptor.processInvocation(StartupAwaitInterceptor.java:22) 
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) 
    at org.jboss.as.ejb3.component.interceptors.ShutDownInterceptorFactory$1.processInvocation(ShutDownInterceptorFactory.java:64) 
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) 
    at org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:67) 
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) 
    at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50) 
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) 
    at org.jboss.as.ejb3.component.interceptors.AdditionalSetupInterceptor.processInvocation(AdditionalSetupInterceptor.java:54) 
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) 
    at org.jboss.invocation.ContextClassLoaderInterceptor.processInvocation(ContextClassLoaderInterceptor.java:64) 
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) 
    at org.jboss.invocation.InterceptorContext.run(InterceptorContext.java:356) 
    at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:636) 
    at org.jboss.invocation.AccessCheckingInterceptor.processInvocation(AccessCheckingInterceptor.java:61) 
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) 
    at org.jboss.invocation.InterceptorContext.run(InterceptorContext.java:356) 
    at org.jboss.invocation.PrivilegedWithCombinerInterceptor.processInvocation(PrivilegedWithCombinerInterceptor.java:80) 
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) 
    at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) 
    at org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:198) 
    at org.jboss.as.webservices.invocation.AbstractInvocationHandler.invoke(AbstractInvocationHandler.java:137) 
    at org.jboss.wsf.stack.cxf.JBossWSInvoker.performInvocation(JBossWSInvoker.java:169) 
    at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96) 
    at org.apache.cxf.jaxws.AbstractJAXWSMethodInvoker.invoke(AbstractJAXWSMethodInvoker.java:232) 
    at org.apache.cxf.jaxws.JAXWSMethodInvoker.invoke(JAXWSMethodInvoker.java:85) 
    at org.jboss.wsf.stack.cxf.JBossWSInvoker.invoke(JBossWSInvoker.java:145) 
    at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:59) 
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) 
at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
    at org.apache.cxf.interceptor.ServiceInvokerInterceptor$2.run(ServiceInvokerInterceptor.java:126) 
    at org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37) 
    at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:131) 
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308) 
    at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121) 
    at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:254) 
    at org.jboss.wsf.stack.cxf.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:108) 
    at org.jboss.wsf.stack.cxf.transport.ServletHelper.callRequestHandler(ServletHelper.java:134) 
    at org.jboss.wsf.stack.cxf.CXFServletExt.invoke(CXFServletExt.java:88) 
    at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:298) 
    at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:217) 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:707) 
    at org.jboss.wsf.stack.cxf.CXFServletExt.service(CXFServletExt.java:136) 
    at org.jboss.wsf.spi.deployment.WSFServlet.service(WSFServlet.java:140) 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) 
    at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85) 
    at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) 
    at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) 
    at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78) 
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) 
    at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131) 
    at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) 
    at io.undertow.server.handlers.DisableCacheHandler.handleRequest(DisableCacheHandler.java:33) 
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) 
    at io.undertow.security.handlers.AuthenticationConstraintHandler.handleRequest(AuthenticationConstraintHandler.java:53) 
    at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) 
    at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) 
    at io.undertow.servlet.handlers.security.ServletSecurityConstraintHandler.handleRequest(ServletSecurityConstraintHandler.java:59) 
    at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) 
    at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) 
    at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50) 
    at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) 
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) 
    at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61) 
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) 
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) 
    at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:292) 
    at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:81) 
    at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:138) 
    at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135) 
    at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) 
    at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) 
    at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44) 
    at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44) 
    at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44) 
    at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44) 
    at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44) 
    at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272) 
    at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81) 
    at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:104) 
    at io.undertow.server.Connectors.executeRootHandler(Connectors.java:202) 
    at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:805) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 
    at java.lang.Thread.run(Thread.java:745) 

12:12:44,775 WARNING [org.apache.cxf.phase.PhaseInterceptorChain] (default task-19) Application {http://kis.agh.edu.pl/}FileSenderApacheService#{http://kis.agh.edu.pl/}Send has thrown exception, unwinding now: org.apache.cxf.interceptor.Fault: WFLYEJB0364: Invocation on method: public java.lang.String pl.edu.agh.kis.FileSenderApache.Send(java.lang.String) of bean: FileSenderApache is not allowed 
    at org.apache.cxf.service.invoker.AbstractInvoker.createFault(AbstractInvoker.java:162) 
    at org.apache.cxf.jaxws.AbstractJAXWSMethodInvoker.createFault(AbstractJAXWSMethodInvoker.java:267) 
    at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:128) 
    at org.apache.cxf.jaxws.AbstractJAXWSMethodInvoker.invoke(AbstractJAXWSMethodInvoker.java:232) 
    at org.apache.cxf.jaxws.JAXWSMethodInvoker.invoke(JAXWSMethodInvoker.java:85) 
    at org.jboss.wsf.stack.cxf.JBossWSInvoker.invoke(JBossWSInvoker.java:145) 
    at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:59) 
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) 
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
    at org.apache.cxf.interceptor.ServiceInvokerInterceptor$2.run(ServiceInvokerInterceptor.java:126) 
    at org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37) 
    at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:131) 
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308) 
    at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121) 
    at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:254) 
    at org.jboss.wsf.stack.cxf.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:108) 
    at org.jboss.wsf.stack.cxf.transport.ServletHelper.callRequestHandler(ServletHelper.java:134) 
    at org.jboss.wsf.stack.cxf.CXFServletExt.invoke(CXFServletExt.java:88) 
    at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:298) 
    at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:217) 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:707) 
    at org.jboss.wsf.stack.cxf.CXFServletExt.service(CXFServletExt.java:136) 
    at org.jboss.wsf.spi.deployment.WSFServlet.service(WSFServlet.java:140) 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) 
    at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85) 
    at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) 
    at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) 
    at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78) 
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) 
    at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131) 
    at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) 
    at io.undertow.server.handlers.DisableCacheHandler.handleRequest(DisableCacheHandler.java:33) 
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) 
    at io.undertow.security.handlers.AuthenticationConstraintHandler.handleRequest(AuthenticationConstraintHandler.java:53) 
    at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) 
    at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) 
    at io.undertow.servlet.handlers.security.ServletSecurityConstraintHandler.handleRequest(ServletSecurityConstraintHandler.java:59) 
    at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) 
    at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) 
    at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50) 
    at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) 
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) 
    at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61) 
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) 
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) 
    at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:292) 
    at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:81) 
    at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:138) 
    at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135) 
    at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) 
    at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) 
    at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44) 
    at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44) 
    at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44) 
    at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44) 
    at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44) 
    at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272) 
    at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81) 
    at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:104) 
    at io.undertow.server.Connectors.executeRootHandler(Connectors.java:202) 
    at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:805) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 
    at java.lang.Thread.run(Thread.java:745) 
Caused by: javax.ejb.EJBAccessException: WFLYEJB0364: Invocation on method: public java.lang.String  pl.edu.agh.kis.FileSenderApache.Send(java.lang.String) of bean: FileSenderApache is not allowed 
    at org.jboss.as.ejb3.security.AuthorizationInterceptor.processInvocation(AuthorizationInterceptor.java:134) 
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) 
    at org.jboss.as.ejb3.security.SecurityContextInterceptor.processInvocation(SecurityContextInterceptor.java:100) 
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) 
    at org.jboss.as.ejb3.deployment.processors.StartupAwaitInterceptor.processInvocation(StartupAwaitInterceptor.java:22) 
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) 
    at org.jboss.as.ejb3.component.interceptors.ShutDownInterceptorFactory$1.processInvocation(ShutDownInterceptorFactory.java:64) 
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) 
    at org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:67) 
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) 
    at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50) 
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) 
    at org.jboss.as.ejb3.component.interceptors.AdditionalSetupInterceptor.processInvocation(AdditionalSetupInterceptor.java:54) 
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) 
    at org.jboss.invocation.ContextClassLoaderInterceptor.processInvocation(ContextClassLoaderInterceptor.java:64) 
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) 
    at org.jboss.invocation.InterceptorContext.run(InterceptorContext.java:356) 
    at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:636) 
    at org.jboss.invocation.AccessCheckingInterceptor.processInvocation(AccessCheckingInterceptor.java:61) 
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) 
    at org.jboss.invocation.InterceptorContext.run(InterceptorContext.java:356) 
    at org.jboss.invocation.PrivilegedWithCombinerInterceptor.processInvocation(PrivilegedWithCombinerInterceptor.java:80) 
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) 
    at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) 
at org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:198) 
    at org.jboss.as.webservices.invocation.AbstractInvocationHandler.invoke(AbstractInvocationHandler.java:137) 
    at org.jboss.wsf.stack.cxf.JBossWSInvoker.performInvocation(JBossWSInvoker.java:169) 
    at  org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96) 
    ... 61 more 

@RolesAllowed( "ユーザー")を追加するのはなぜ問題が発生します - 他のすべてのWebサービスが正常に動作しますが、この1。

問題は、この行を次のとおりです。

String img = fsa.send("/Users/user/SOAP_KUBA_2/lab-soa1c/lab-soa1c-soap/pics/images-3.jpeg"); 

答えて

0

私はラッパークラスを使用して問題を解決しました。ファイルへのパスは属性であり、ファイルをエンコードするメソッドはゲッター内にあります。 getterを呼び出すと、文字列にエンコードされた画像が返されます。 Webサービスはクラス全体のインスタンスを送信し、ゲッターを使用して画像を復元します。

関連する問題