2424import io .getstream .chat .java .services .UserService ;
2525import io .getstream .chat .java .services .framework .Client ;
2626import io .jsonwebtoken .Jwts ;
27- import io .jsonwebtoken .SignatureAlgorithm ;
27+ import io .jsonwebtoken .security . Keys ;
2828import java .nio .charset .StandardCharsets ;
2929import java .text .DateFormat ;
3030import java .text .SimpleDateFormat ;
3131import java .util .*;
3232import java .util .stream .Collectors ;
33- import javax .crypto .spec .SecretKeySpec ;
3433import lombok .*;
3534import org .jetbrains .annotations .NotNull ;
3635import org .jetbrains .annotations .Nullable ;
@@ -1473,9 +1472,7 @@ public static String createToken(
14731472 @ NotNull String userId ,
14741473 @ Nullable Date expiresAt ,
14751474 @ Nullable Date issuedAt ) {
1476- var signingKey =
1477- new SecretKeySpec (
1478- apiSecret .getBytes (StandardCharsets .UTF_8 ), SignatureAlgorithm .HS256 .getJcaName ());
1475+ var signingKey = Keys .hmacShaKeyFor (apiSecret .getBytes (StandardCharsets .UTF_8 ));
14791476
14801477 if (issuedAt == null ) {
14811478 GregorianCalendar calendar = new GregorianCalendar ();
@@ -1485,11 +1482,11 @@ public static String createToken(
14851482
14861483 return Jwts .builder ()
14871484 .claim ("user_id" , userId )
1488- .setExpiration (expiresAt )
1489- .setIssuedAt (issuedAt )
1490- .setIssuer ("Stream Chat Java SDK" )
1491- .setSubject ("Stream Chat Java SDK" )
1492- .signWith (signingKey , SignatureAlgorithm .HS256 )
1485+ .expiration (expiresAt )
1486+ .issuedAt (issuedAt )
1487+ .issuer ("Stream Chat Java SDK" )
1488+ .subject ("Stream Chat Java SDK" )
1489+ .signWith (signingKey , Jwts . SIG .HS256 )
14931490 .compact ();
14941491 }
14951492}
0 commit comments