// Path: src/main/java/com/github/segator/proxylive/helper/AuthorityRoles.java
// public enum AuthorityRoles {
//     USER("USER"),
//     SERVICE_ACCOUNT("SERVICE_ACCOUNT"),
//     ALLOW_ENCODING("ENCODE_PULLER"),
//     ADMIN("ADMIN");
//     private String authority;
//     AuthorityRoles(String authority) {
//         this.authority = authority;
//     }
// 
//     public String getAuthority() {
//         return authority;
//     }
// }
// 
// Path: src/main/java/com/github/segator/proxylive/helper/JwtHelper.java
// @Component
// public class JwtHelper {
//     private JwtConfiguration jwtConfiguration;
// 
//     public JwtHelper(JwtConfiguration jwtConfiguration) {
//         this.jwtConfiguration = jwtConfiguration;
//     }
//     public String createJwtForClaims(String subject, List<GrantedAuthority> grantedAuthorities) {
//         Calendar calendar = Calendar.getInstance();
//         calendar.setTimeInMillis(Instant.now().toEpochMilli());
//         calendar.add(Calendar.HOUR, jwtConfiguration.getExpireInHours());
//         return createJwtForClaims(subject,grantedAuthorities,calendar.getTime());
//     }
//     public String createJwtForClaims(String subject, List<GrantedAuthority> grantedAuthorities,Date expirationDate) {
//         JwtBuilder builder =  Jwts.builder().setId("proxylive")
//             .setSubject(subject)
//             .claim("authorities",grantedAuthorities.stream()
//                     .map(GrantedAuthority::getAuthority)
//                     .collect(Collectors.toList()))
//             .setIssuedAt(new Date(System.currentTimeMillis()));
// 
//         if(expirationDate!=null) {
//             builder.setExpiration(expirationDate);
//         }
//         return builder.signWith(SignatureAlgorithm.HS512,
//                 jwtConfiguration.getSecret().getBytes()).compact();
//     }
// }


import com.github.segator.proxylive.helper.AuthorityRoles;
import com.github.segator.proxylive.helper.JwtHelper;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.stereotype.Service;
import java.time.Instant;
import java.util.Calendar;
import java.util.List;
package com.github.segator.proxylive.service;



@Service
public class TokenService {
    private final JwtHelper jwtHelper;

// Path: src/main/java/com/github/segator/proxylive/helper/AuthorityRoles.java
// public enum AuthorityRoles {
//     USER("USER"),
//     SERVICE_ACCOUNT("SERVICE_ACCOUNT"),
//     ALLOW_ENCODING("ENCODE_PULLER"),
//     ADMIN("ADMIN");
//     private String authority;
//     AuthorityRoles(String authority) {
//         this.authority = authority;
//     }
// 
//     public String getAuthority() {
//         return authority;
//     }
// }
// 
// Path: src/main/java/com/github/segator/proxylive/helper/JwtHelper.java
// @Component
// public class JwtHelper {
//     private JwtConfiguration jwtConfiguration;
// 
//     public JwtHelper(JwtConfiguration jwtConfiguration) {
//         this.jwtConfiguration = jwtConfiguration;
//     }
//     public String createJwtForClaims(String subject, List<GrantedAuthority> grantedAuthorities) {
//         Calendar calendar = Calendar.getInstance();
//         calendar.setTimeInMillis(Instant.now().toEpochMilli());
//         calendar.add(Calendar.HOUR, jwtConfiguration.getExpireInHours());
//         return createJwtForClaims(subject,grantedAuthorities,calendar.getTime());
//     }
//     public String createJwtForClaims(String subject, List<GrantedAuthority> grantedAuthorities,Date expirationDate) {
//         JwtBuilder builder =  Jwts.builder().setId("proxylive")
//             .setSubject(subject)
//             .claim("authorities",grantedAuthorities.stream()
//                     .map(GrantedAuthority::getAuthority)
//                     .collect(Collectors.toList()))
//             .setIssuedAt(new Date(System.currentTimeMillis()));
// 
//         if(expirationDate!=null) {
//             builder.setExpiration(expirationDate);
//         }
//         return builder.signWith(SignatureAlgorithm.HS512,
//                 jwtConfiguration.getSecret().getBytes()).compact();
//     }
// }


// Path: src/main/java/com/github/segator/proxylive/service/TokenService.java
import com.github.segator.proxylive.helper.AuthorityRoles;
import com.github.segator.proxylive.helper.JwtHelper;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.stereotype.Service;
import java.time.Instant;
import java.util.Calendar;
import java.util.List;

package com.github.segator.proxylive.service;



@Service
public class TokenService {
    private final JwtHelper jwtHelper;

    public TokenService(JwtHelper jwtHelper) {