JSP Authentication with the Method Server

本文介绍了一种解决Windchill环境下JSP页面自动认证问题的方法。通过使用特定代码片段,使得无需用户交互即可成功认证并执行服务器端代码,避免了多种错误的发生。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

During development for a customer, they wanted to access a JSP page that would execute some server-side code. The problem was that the page was being accessed by a program developed by the customer, so no user interaction could occur for authentication on Windchill's end.

The requirements prevented the code from being placed in the netmarkets folder or wtcore, but authentication was still required to execute the server-side code. Experimenting with automatic authentication caused a variety of errors:

  • wt.method.AuthenticationException
  • wt.method.MethodServerException: no active method context
  • wt.util.WTContextNestingException

Finally, the code that worked:

<%@ include file="/netmarkets/jsp/util/context.jsp" %>
<% 
try
{
GatewayAuthenticator auth = new GatewayAuthenticator();
wt.org.WTPrincipal admin = SessionHelper.manager.getAdministrator();
auth.setRemoteUser(admin.getName());
wtcontext.setAuthentication(auth);
SessionHelper.manager.setAdministrator();
...
%>

Some code will still need to be executed through a service so that it executes inside the Method Server, but with the above code, it will execute without causing authentication or context errors.

Be careful of the above code because all code will execute as the administrator. If access control is needed then the code needs modified to reflect the current user.

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值