Created Appointment creation flow.
This commit is contained in:
@@ -51,6 +51,7 @@ import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.Mac;
|
||||
import javax.crypto.spec.IvParameterSpec;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
|
||||
@@ -580,4 +581,35 @@ public class Utils {
|
||||
// Clear the RequestContextHolder after task execution
|
||||
RequestContextHolder.resetRequestAttributes();
|
||||
}
|
||||
|
||||
public static String generateAuthTokenForLoginToOdessa() {
|
||||
|
||||
try {
|
||||
// Your weak secret key
|
||||
String secretKey = GepafinConstant.AUTH_JWT_SECRET_KEY;
|
||||
|
||||
// Header
|
||||
String header = GepafinConstant.JWT_ALGO_HEADER;
|
||||
String encodedHeader = Base64.getUrlEncoder().withoutPadding().encodeToString(header.getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
// Payload
|
||||
String payload = "{\"iat\":" + (System.currentTimeMillis() / 1000) + "}";
|
||||
String encodedPayload = Base64.getUrlEncoder().withoutPadding().encodeToString(payload.getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
// Combine header and payload
|
||||
String dataToSign = encodedHeader + "." + encodedPayload;
|
||||
|
||||
// Sign the token manually
|
||||
Mac mac = Mac.getInstance(GepafinConstant.HMAC_ALGO);
|
||||
SecretKeySpec secretKeySpec = new SecretKeySpec(secretKey.getBytes(StandardCharsets.UTF_8), GepafinConstant.HMAC_ALGO);
|
||||
mac.init(secretKeySpec);
|
||||
byte[] signatureBytes = mac.doFinal(dataToSign.getBytes(StandardCharsets.UTF_8));
|
||||
String signature = Base64.getUrlEncoder().withoutPadding().encodeToString(signatureBytes);
|
||||
|
||||
// Return the final JWT
|
||||
return dataToSign + "." + signature;
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Failed to generate JWT token", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user