Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/jdk17-dev' into jdk17-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
lbw committed Dec 6, 2023
2 parents 009bb6f + 7ad4f3c commit 0299771
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.pig4cloud.pig.auth.support;

import org.springframework.lang.Nullable;
import org.springframework.security.crypto.keygen.Base64StringKeyGenerator;
import org.springframework.security.crypto.keygen.StringKeyGenerator;
import org.springframework.security.oauth2.core.ClaimAccessor;
import org.springframework.security.oauth2.core.OAuth2AccessToken;
import org.springframework.security.oauth2.core.endpoint.OAuth2ParameterNames;
Expand All @@ -13,10 +15,7 @@
import org.springframework.util.StringUtils;

import java.time.Instant;
import java.util.Collections;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.*;

/**
* @author lengleng
Expand All @@ -25,6 +24,9 @@
public class CustomeOAuth2AccessTokenGenerator implements OAuth2TokenGenerator<OAuth2AccessToken> {

private OAuth2TokenCustomizer<OAuth2TokenClaimsContext> accessTokenCustomizer;
private final StringKeyGenerator accessTokenGenerator =
new Base64StringKeyGenerator(Base64.getUrlEncoder().withoutPadding(), 96);


@Nullable
@Override
Expand Down Expand Up @@ -83,7 +85,7 @@ public OAuth2AccessToken generate(OAuth2TokenContext context) {

OAuth2TokenClaimsSet accessTokenClaimsSet = claimsBuilder.build();
return new CustomeOAuth2AccessTokenGenerator.OAuth2AccessTokenClaims(OAuth2AccessToken.TokenType.BEARER,
UUID.randomUUID().toString(), accessTokenClaimsSet.getIssuedAt(), accessTokenClaimsSet.getExpiresAt(),
this.accessTokenGenerator.generateKey(), accessTokenClaimsSet.getIssuedAt(), accessTokenClaimsSet.getExpiresAt(),
context.getAuthorizedScopes(), accessTokenClaimsSet.getClaims());
}

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<url>https://www.pig4cloud.com</url>

<properties>
<spring-boot.version>3.1.5</spring-boot.version>
<spring-boot.version>3.1.6</spring-boot.version>
<spring-cloud.version>2022.0.4</spring-cloud.version>
<spring-cloud-alibaba.version>2022.0.0.0</spring-cloud-alibaba.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down

0 comments on commit 0299771

Please sign in to comment.