https://github.com/WASdev/sample.batch.sleepybatchlet
我正在尝试运行上面的git示例。 我能够在自由中配置和运行ant build java批处理项目。 但是当谈到maven项目时, 我无法使用其他服务来控制jobs.i使用defaultKeyStore存在用户身份验证问题。 我注意到上面的maven项目中有一个server.xml,但是我无法创建密钥库密码。 它说“不能找到自由运行时间”。
在liberty server.xml中 我在basicRegistry中使用了一个用户 和security-role为同一用户的“batchadmin”
应该在项目内的server.xml中进行哪些更改以传递服务器身份验证。
答案 0 :(得分:0)
为了在配置基于批处理角色的身份验证时从servlet执行批处理操作,您需要向servlet添加身份验证质询,以便它在特定用户下运行,而不是 UNAUTHENTICATED 。
你可以像这样添加到样本中:
import javax.servlet.annotation.HttpConstraint;
import javax.servlet.annotation.HttpMethodConstraint;
import javax.servlet.annotation.ServletSecurity;
import javax.servlet.annotation.WebServlet;
// ...
@ServletSecurity(value = @HttpConstraint(transportGuarantee = ServletSecurity.TransportGuarantee.CONFIDENTIAL),
httpMethodConstraints = { @HttpMethodConstraint(value = "POST", emptyRoleSemantic = ServletSecurity.EmptyRoleSemantic.PERMIT),
@HttpMethodConstraint(value = "GET", emptyRoleSemantic = ServletSecurity.EmptyRoleSemantic.PERMIT),
@HttpMethodConstraint(value = "PUT", emptyRoleSemantic = ServletSecurity.EmptyRoleSemantic.PERMIT) })
@WebServlet(urlPatterns = { "/joboperator" })
public class JobOperatorServlet extends HttpServlet {
除了定义用户注册表和用户之外,还允许他们访问您引用的文档中的批处理角色,这里有一个片段:
<httpEndpoint httpPort="9080" httpsPort="9443" id="defaultHttpEndpoint"/>
<keyStore id="defaultKeyStore" password="Liberty"/>
<basicRegistry id="basic" realm="ibm/api">
<user name="bob" password="bobpwd"/>
<user name="jane" password="janepwd"/>
</basicRegistry>
<authorization-roles id="com.ibm.ws.batch">
<security-role name="batchSubmitter">
<user name="bob"/>
</security-role>
<security-role name="batchAdmin">
<user name="jane"/>
</security-role>
</authorization-roles>
现在,有一个单独的但相关的问题是如何配置批处理安全性,即哪些功能将批处理安全性带入图片中。但我会留下这个问题作为后续问题,并将其视为理所当然的存在。