对接sso单点登录认证时response报错

凡人多烦事 发布于 2019/08/27 10:02
阅读 73
收藏 0

小白一个,对接统一身份认证但是response报错

@ControllerBind(controllerKey = "/myconsole", viewPath = "/WEB-INF/view")
public class ConsoleController extends Controller {
	@Before(AuthInterceptor.class)
	public void index() {
		setAttr("perm_menu", getSessionAttr("perm_menu"));

		LoginService loginService = new LoginService();
		loginService.initApp(getRequest());

		// 保存session副本,以便可以根据sessionid获取session
		SessionContext.getInstance().AddSession(getSession());



		User user = User.dao.findById(((User) getSessionAttr("User")).getStr("keyid"));
		if (user.getStr("userpwd").compareTo(LoginService.encryptPassword(Const.LoginPwd.DEFAULT_PWD)) == 0) {
			modifypwd();
			return;
		}
		String uamCertPath = "F:/桌面/Desktop/oa接口/测试环境证书(1)/UAM.cer";//统一身份公钥路径
		String appJKSPath = "F:/桌面/Desktop/oa接口/测试环境证书(1)/UAM_hx.jks";//应用系统证书库路径
		String appKeyStoreAlias = "newhx";//应用系统证书别名(应用系统)
		String appKeyStoreAliasPwd = "123456";//应用系统证书库密码(应用系统)
		String keyStoreType ="JKS";//证书库类型 UAMApp_HX.jks
		String returnUrl = "http://localhost:8080/myconsole/";//认证完成后,应用接受票据的页面"http://localhost:8080/myconsole/"
		String serverUrl = "uamtest.gpic.com.cn";//认证完成后,应用接受票据的页面

		//证书map封装
		Map certMap = new HashMap();
		certMap.put("uamCertPath",uamCertPath);
		certMap.put("appJKSPath",appJKSPath);
		certMap.put("appKeyStoreAlias",appKeyStoreAlias);
		certMap.put("appKeyStoreAliasPwd",appKeyStoreAliasPwd);
		certMap.put("keyStoreType",keyStoreType);

		//应用信息封装
		JSONObject json = new JSONObject();

		AuthenticationTools authenticationTools = new AuthenticationTools();
		json.put("appid", "TJSJFXPT"); //应用程序在统一身份平台的唯一编码,统一身份提供 (必填)
		json.put("authMethod","0"); //0为用户名密码,1为手机号登陆,2邮箱登录,应用端强制登录方式,如果为空,将采用应用注册时配置的登录方式(必填)
		json.put("reqTime",(new Date()).getTime()); //请求认证时间  (必填)
		json.put("retUrl",returnUrl);//返回应用URL(必填
		json.put("redUrl",returnUrl);//返回应用URL(必填
		//统一身份地址
		//调用统一身份认证方法进行认证
		authenticationTools.ssoAuth(json,certMap,getRequest(),getResponse(),"uamtest.gpic.com.cn");

		
		render("console.html");
	}

前段代码

function submitForm() {
	var formData = $("#ff").serialize();
	$.post("${ctx}/myconsole/loginAction",formData,function(data){
	    if (data == 'ok') {
	    	//保存密码
	      	if ($("#rememberPW").prop('checked')) {
	    		time = 7;//1周
	    	}else{
	    		time=0;//不保存
	    	}
	    	var userid = $("#userid").val();
	    	var password = $("#password").val();
	    	//console.log(userid+"--"+password+"--"+time);
	    	$.cookie("userid", Base64.encode(userid), {expires: time, path: "/"});
	    	$.cookie("password", Base64.encode(password), {expires: time, path: "/"});

			window.location.href = "${ctx}/myconsole/";
		} else {
			layer.msg(data);
			$("#captchaPic").attr("src","${ctx}/myconsole/getCaptcha?"+Math.random());
		}
  });
RROR: /myconsole/loginAction 	(com.jfinal.core.ActionHandler) [2019-08-26 11:08:12,755]
com.jfinal.render.RenderException: java.lang.IllegalStateException: getOutputStream() has already been called for this response
	at com.jfinal.render.FreeMarkerRender.render(FreeMarkerRender.java:147)
	at com.jfinal.core.ActionHandler.handle(ActionHandler.java:97)
	at com.fsm.interceptor.ExcludeHandler.handle(ExcludeHandler.java:28)
	at com.jfinal.ext.handler.ContextPathHandler.handle(ContextPathHandler.java:47)
	at com.fsm.core.XssHandler.handle(XssHandler.java:32)
	at com.jfinal.core.JFinalFilter.doFilter(JFinalFilter.java:72)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
	at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61)
	at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
	at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
	at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
	at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
	at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
	at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
	at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
	at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
	at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)
	at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
	at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
	at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
	at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
	at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:176)
	at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:145)
	at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92)
	at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:389)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
	at com.fsm.core.base.BaseFilter.doFilter(Unknown Source)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:442)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1083)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:640)
	at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2517)
	at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2506)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalStateException: getOutputStream() has already been called for this response
	at org.apache.catalina.connector.Response.getWriter(Response.java:662)
	at org.apache.catalina.connector.ResponseFacade.getWriter(ResponseFacade.java:213)
	at javax.servlet.ServletResponseWrapper.getWriter(ServletResponseWrapper.java:104)
	at com.jfinal.render.FreeMarkerRender.render(FreeMarkerRender.java:144)
	... 48 more

各位大神能指导一下吗?是因为重定向吗,如果是那应该怎么解决,

加载中
OSCHINA
登录后可查看更多优质内容
返回顶部
顶部