简体   繁体   English

java.lang.IllegalStateException:Current user principal is not of type when i try to integrate keycloak with spring boot web + spring security project

[英]java.lang.IllegalStateException:Current user principal is not of type when i try to integrate keycloak with spring boot web + spring security project

I Created a spring boot web project (.war) to be deployed in an application server.I want to integrate keycloak sso with spring security.The redirection to keycloak login page is working fine.我创建了一个 spring 引导 web 项目(.war)以部署在应用程序服务器中。我想将 keycloak sso 与 spring 集成到安全性。 But after that it is throwing error in browser.但在那之后它在浏览器中抛出错误。

Error which is getting thrown in browser在浏览器中抛出的错误

There was an unexpected error (type=Internal Server Error, status=500).出现意外错误(类型=内部服务器错误,状态=500)。 Current user principal is not of type [org.keycloak.KeycloakPrincipal]: org.keycloak.adapters.springsecurity.token.KeycloakAuthenticationToken@450ca8a1: Principal: da02ad1b-32c1-4dde-a6f4-b56a06d7dc2e;当前用户主体不是 [org.keycloak.KeycloakPrincipal] 类型:org.keycloak.adapters.springsecurity.token.KeycloakAuthenticationToken@450ca8a1:主体:da02ad1b-32c1-4dde-a6f4-b56a06d7dc2e; Credentials: [PROTECTED];凭证:[受保护]; Authenticated: true;已认证:真实; Details: org.keycloak.adapters.springsecurity.account.SimpleKeycloakAccount@20e00226;详细信息:org.keycloak.adapters.springsecurity.account.SimpleKeycloakAccount@20e00226; Not granted any authorities未授予任何权限

Error in application server console应用程序服务器控制台中的错误

2019-11-12 14:29:38.306 ERROR 6280 --- [nio-8089-exec-5] osbwservlet.support.ErrorPageFilter: Forwarding to error page from request [/] due to exception [Current user principal is not of type [org.keycloak.KeycloakPrincipal]: org.keycloak.adapters.springsecurity.token.KeycloakAuthenticationToken@f4a97409: Principal: da02ad1b-32c1-4dde-a6f4-b56a06d7dc2e; 2019-11-12 14:29:38.306 错误 6280 --- [nio-8089-exec-5] osbwservlet.support.ErrorPageFilter:由于异常 [当前用户主体不是类型,从请求 [/] 转发到错误页面[org.keycloak.KeycloakPrincipal]:org.keycloak.adapters.springsecurity.token.KeycloakAuthenticationToken@f4a97409:主体:da02ad1b-32c1-4dde-a6f4-b56a06d7dc2e; Credentials: [PROTECTED];凭证:[受保护]; Authenticated: true;已认证:真实; Details: org.keycloak.adapters.springsecurity.account.SimpleKeycloakAccount@11f292bf;详细信息:org.keycloak.adapters.springsecurity.account.SimpleKeycloakAccount@11f292bf; Granted Authorities: KeycloakRole{role='user-premium'}, KeycloakRole{role='user'}]授予权限:KeycloakRole{role='user-premium'}、KeycloakRole{role='user'}]

java.lang.IllegalStateException: Current user principal is not of type [org.keycloak.KeycloakPrincipal]: org.keycloak.adapters.springsecurity.token.KeycloakAuthenticationToken@f4a97409: Principal: da02ad1b-32c1-4dde-a6f4-b56a06d7dc2e; java.lang.IllegalStateException:当前用户主体不是类型 [org.keycloak.KeycloakPrincipal]:org.keycloak.adapters.springsecurity.token.KeycloakAuthenticationToken@f4a97409:主体:da02ad1b-32c1-4dde-a2f4-b56a06d;7d Credentials: [PROTECTED];凭证:[受保护]; Authenticated: true;已认证:真实; Details: org.keycloak.adapters.springsecurity.account.SimpleKeycloakAccount@11f292bf;详细信息:org.keycloak.adapters.springsecurity.account.SimpleKeycloakAccount@11f292bf; Granted Authorities: KeycloakRole{role='user-premium'}, KeycloakRole{role='user'} at org.springframework.web.servlet.mvc.method.annotation.ServletRequestMethodArgumentResolver.resolveArgument(ServletRequestMethodArgumentResolver.java:166) ~[spring-webmvc-5.1.6.RELEASE.jar:5.1.6.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.ServletRequestMethodArgumentResolver.resolveArgument(ServletRequestMethodArgumentResolver.java:121) ~[spring-webmvc-5.1.6.RELEASE.jar:5.1.6.RELEASE] at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:126) ~[spring-web-5.1.6.RELEASE.jar:5.1.6.RELEASE] at org.springframework.Z2567A5EC9705EB Granted Authorities: KeycloakRole{role='user-premium'}, KeycloakRole{role='user'} at org.springframework.web.servlet.mvc.method.annotation.ServletRequestMethodArgumentResolver.resolveArgument(ServletRequestMethodArgumentResolver.java:166) ~[spring -webmvc-5.1.6.RELEASE.jar:5.1.6.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.ServletRequestMethodArgumentResolver.resolveArgument(ServletRequestMethodArgumentResolver.java:121) ~[spring-webmvc-5.1. 6.RELEASE.jar:5.1.6.RELEASE] at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:126) ~[spring-web-5.1.6.RELEASE.jar:5.1.6 .RELEASE] 在 org.springframework.Z2567A5EC9705EB 7AC2C984033E06189DZ.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:166) ~[spring-web-5.1.6.RELEASE.jar:5.1.6.RELEASE] 7AC2C984033E06189DZ.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:166)~[spring-web-5.1.6.RELEASE.Z68995FCBF432492D15484D04A9D2ASE]4:Z55.1.6.RELEACASE

exception [Current user principal is not of type [org.keycloak.KeycloakPrincipal]异常 [当前用户主体不是 [org.keycloak.KeycloakPrincipal] 类型

you should use KeycloakAuthenticationToken instead of KeycloakPrincipal你应该使用KeycloakAuthenticationToken而不是KeycloakPrincipal

Issue was like i used KeycloakPrincipal principal in contoller method问题就像我在控制器方法中使用 KeycloakPrincipal 主体

暂无
暂无

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

相关问题 春季启动 java.lang.IllegalStateException - Spring boot java.lang.IllegalStateException Spring Boot App 在启动时崩溃 - java.lang.IllegalStateException - Spring Boot App crashes at startup - java.lang.IllegalStateException (Spring Boot 2)java.lang.IllegalStateException:无法加载ApplicationContex - (Spring Boot 2 ) java.lang.IllegalStateException: Failed to load ApplicationContex Spring Boot应用程序在云铸造厂java.lang.IllegalStateException上崩溃 - spring boot app crashing on cloud foundry java.lang.IllegalStateException Spring Boot Web应用程序:引发java.lang.IllegalStateException:此响应已调用getOutputStream() - Spring Boot Web Application: throwing java.lang.IllegalStateException: getOutputStream() has already been called for this response 从websocket调用ControllerLinkBuilder.linkTo时的Spring Boot,java.lang.IllegalStateException - Spring Boot, java.lang.IllegalStateException when calling ControllerLinkBuilder.linkTo from a websocket 当我尝试在库项目中使用getSystemService时获取java.lang.IllegalStateException - Getting java.lang.IllegalStateException when I try to use getSystemService in library project 当我尝试通过 Jenkins 在 Linux 服务器中运行我的项目时,出现“java.lang.IllegalStateException: The driver is not executable” - "java.lang.IllegalStateException: The driver is not executable" when I try to run my project in Linux server through Jenkins 当我尝试通过ID查找GridLayout时出现java.lang.IllegalStateException - java.lang.IllegalStateException when I try to find GridLayout by id 在Spring Web App中运行junit时,出现错误:java.lang.IllegalStateException:无法加载ApplicationContext - when running junit in spring web app, get an error: java.lang.IllegalStateException: Failed to load ApplicationContext
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM