简体   繁体   English

Glassfish基本身份验证错误

[英]Glassfish basic auth error

I have next method: 我有下一个方法:

@RolesAllowed("basicUser")
    @Override
    public boolean LogOn(String UserName, String Password) {
...
}

This my web.xml: 这是我的web.xml:

http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"> HelloService http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd“> HelloService

<session-config>
    <session-timeout>30</session-timeout>
</session-config>
<security-constraint>
    <display-name>SecurityConstraint</display-name>
    <!-- web resources that are protected -->
    <web-resource-collection>
        <web-resource-name>Secure Pages</web-resource-name>
        <url-pattern>/*</url-pattern>
    </web-resource-collection>
    <auth-constraint>
        <!-- role-name indicates roles that are allowed to access the web resource specified above -->
        <role-name>basicUser</role-name>
    </auth-constraint>
     <user-data-constraint>
        <transport-guarantee>NONE</transport-guarantee>
    </user-data-constraint>
</security-constraint>
<login-config>
    <auth-method>BASIC</auth-method>
    <realm-name>file</realm-name>
</login-config>
<security-role>
    <role-name>basicUser</role-name>
</security-role>

And sun-web: 和太阳网:

<security-role-mapping>
    <role-name>basicUser</role-name>
    <group-name>client</group-name>
</security-role-mapping>

In Glassfish server, in Server-config -> Secirity -> Realms - > File, Assign Groups: cleint , and user with group client present. 在Glassfish服务器中,在“服务器配置”->“安全性”->“领域”->“文件”中,分配组: cleint和具有组客户端的用户。 Deploy run success. 部署成功。 When i'm testing web-service, i'm get next error: 当我测试Web服务时,出现下一个错误:

INFO:   parsing WSDL...
INFO:   [ERROR] Server returned HTTP response code: 401 for URL:
http://localhost:8080/CalculatorWSApplication/WebServiceImplService?WSDL,
"http://localhost:8080/CalculatorWSApplication/WebServiceImplService?WSDL" needs 
authorization, please provide authorization file with read access at
C:\Users\user.t\.metro\auth or use -Xauthfile to give the authorization
file and on each line provide authorization information using this format :
http[s]://user:password@host:port//<url-path>

PS Without basic-authentication, web-service deploy and testing successfull. PS没有基本身份验证,Web服务部署和测试成功。

UPD UPD

Exceptions details : null 异常详细信息:null

    com.sun.tools.ws.wscompile.AbortException at 
com.sun.tools.ws.wsdl.parser.MetadataFinder$WSEntityResolver.resolveEntity(MetadataFinder.java:202) at 
com.sun.tools.ws.wsdl.parser.DOMForest.parse(DOMForest.java:212) at
com.sun.tools.ws.wsdl.parser.DOMForest.parse(DOMForest.java:148) at
com.sun.tools.ws.wsdl.parser.MetadataFinder.parseWSDL(MetadataFinder.java:111) at
com.sun.tools.ws.wscompile.WsimportTool.buildWsdlModel(WsimportTool.java:439) at
com.sun.tools.ws.wscompile.WsimportTool.run(WsimportTool.java:205) at
com.sun.tools.ws.wscompile.WsimportTool.run(WsimportTool.java:183) at
com.sun.tools.ws.util.WSToolsObjectFactoryImpl.wsimport(WSToolsObjectFactoryImpl.java:60)at 
com.sun.tools.ws.spi.WSToolsObjectFactory.wsimport(WSToolsObjectFactory.java:88) at
org.glassfish.webservices.monitoring.WebServiceTesterServlet.wsImport(WebServiceTesterServlet.java:642) at
org.glassfish.webservices.monitoring.WebServiceTesterServlet.initializePort(WebServiceTesterServlet.java:528) at 
org.glassfish.webservices.monitoring.WebServiceTesterServlet.doGet(WebServiceTesterServlet.java:169) at 
org.glassfish.webservices.monitoring.WebServiceTesterServlet.invoke(WebServiceTesterServlet.java:104) at 
org.glassfish.webservices.JAXWSServlet.doGet(JAXWSServlet.java:210) at
javax.servlet.http.HttpServlet.service(HttpServlet.java:687) at 
javax.servlet.http.HttpServlet.service(HttpServlet.java:790) at
org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682) at 
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318) at 
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160) at
org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734) at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673) at
com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99) at 
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174) at 
org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:357) at 
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260) at 
com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:188) at
org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191) at
org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168) at
org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189) at
org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119) at
org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288) at
org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206) at
org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)at 
org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)at 
org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77) at
org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)at 
org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113) at
org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115) at 
org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55) at
org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135) at
org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564) at
org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)at java.lang.Thread.run(Thread.java:744)

It seems you need to first create an authfile composed of the wsdl URI plus my username and password. 看来您首先需要创建一个由wsdl URI加上我的用户名和密码组成的authfile。 You can see the details here 您可以在此处查看详细信息

If you use JAX-WS, try add file sun-jaxws.xml with next contents: 如果您使用JAX-WS,请尝试添加文件sun-jaxws.xml及以下内容:

<endpoints xmlns='http://java.sun.com/xml/ns/jax-ws/ri/runtime' version='2.0'>
    <endpoint
        name='YOUR_NAME'
        implementation='yourpacket.Web_Service_Implementation'
        url-pattern='/*'/>
</endpoints>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM