gpt4 book ai didi

java - Websphere 应用程序服务器安全 REST API

转载 作者:行者123 更新时间:2023-11-30 08:13:08 25 4
gpt4 key购买 nike

我想从 Webpshere Application Server 8 公开 REST API。我可以在没有安全性的情况下成功公开 REST 端点。但是在添加安全性时,我收到 404 错误代码,如下所示:

[5/6/15 7:44:20:369 CAT] 00000063 RequestProces I org.apache.wink.server.internal.RequestProcessor logException The following error occurred during the invocation of the handlers chain: WebApplicationException (404 - Not Found) with message 'null' while processing GET request sent to http://localhost:9080/StudentWeb/student/service/students/100

请找到使用的web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="3.0"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<servlet>
<servlet-name>StudentWebServelet</servlet-name>
<servlet-class>com.ibm.websphere.jaxrs.server.IBMRestServlet</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.student.rest.StudentApplication</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>StudentWebServelet</servlet-name>
<url-pattern>/student/*</url-pattern>
</servlet-mapping>
<security-role>
<description>Registered Users</description>
<role-name>RegisteredUsers</role-name>
</security-role>
<security-constraint>
<display-name>StudentSecurity</display-name>
<web-resource-collection>
<web-resource-name>Student resource</web-resource-name>
<url-pattern>/student/service/*</url-pattern>
<http-method>GET</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>RegisteredUsers</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>
</security-constraint>
</web-app>

最佳答案

我确实找到了解决方案。我所有的安全资源路径都是“/services/{resource name}”。

@Path(value="/secured/students")公共(public)类 StudentResource 扩展 AbstractResource {

@Inject
StudentBeanLocal studentBeanLocal;
<小时/>

}

不安全的资源类似于 @path(value="/address")。

关于java - Websphere 应用程序服务器安全 REST API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30068630/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com