Java Code Examples for org.springframework.security.oauth2.jwt.Jwt#getExpiresAt()
The following examples show how to use
org.springframework.security.oauth2.jwt.Jwt#getExpiresAt() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OidcUserManagementAutoConfiguration.java From hawkbit with Eclipse Public License 1.0 | 5 votes |
@Override public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain) throws IOException, ServletException { final Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); if (authentication instanceof JwtAuthenticationToken) { final String defaultTenant = "DEFAULT"; final JwtAuthenticationToken jwtAuthenticationToken = (JwtAuthenticationToken) authentication; final Jwt jwt = jwtAuthenticationToken.getToken(); final OidcIdToken idToken = new OidcIdToken(jwt.getTokenValue(), jwt.getIssuedAt(), jwt.getExpiresAt(), jwt.getClaims()); final OidcUserInfo userInfo = new OidcUserInfo(jwt.getClaims()); final Set<GrantedAuthority> authorities = authoritiesExtractor.extract(clientRegistration.getClientId(), jwt.getClaims()); if (authorities.isEmpty()) { ((HttpServletResponse) response).sendError(HttpServletResponse.SC_FORBIDDEN); return; } final DefaultOidcUser user = new DefaultOidcUser(authorities, idToken, userInfo); final OAuth2AuthenticationToken oAuth2AuthenticationToken = new OAuth2AuthenticationToken(user, authorities, clientRegistration.getRegistrationId()); oAuth2AuthenticationToken.setDetails(new TenantAwareAuthenticationDetails(defaultTenant, false)); systemSecurityContext.runAsSystemAsTenant(systemManagement::getTenantMetadata, defaultTenant); SecurityContextHolder.getContext().setAuthentication(oAuth2AuthenticationToken); } chain.doFilter(request, response); }
Example 2
Source File: XsuaaToken.java From cloud-security-xsuaa-integration with Apache License 2.0 | 2 votes |
/** * @param jwt * token */ protected XsuaaToken(Jwt jwt) { super(jwt.getTokenValue(), jwt.getIssuedAt(), jwt.getExpiresAt(), jwt.getHeaders(), jwt.getClaims()); }