1515 */
1616package software .xdev .bzst .dip .client .util ;
1717
18- import static software .xdev .bzst .dip .client .webclient .BearerTokenRequester .MDS_POSTFIX ;
19-
2018import java .io .IOException ;
21- import java .io .InputStream ;
2219import java .io .StringReader ;
23- import java .security .KeyStore ;
24- import java .security .PrivateKey ;
25- import java .time .Duration ;
2620import java .util .ArrayList ;
27- import java .util .Date ;
2821import java .util .List ;
29- import java .util .UUID ;
3022
3123import javax .xml .parsers .DocumentBuilder ;
3224import javax .xml .parsers .DocumentBuilderFactory ;
4133import org .xml .sax .InputSource ;
4234import org .xml .sax .SAXException ;
4335
44- import io .jsonwebtoken .Jwts ;
45- import software .xdev .bzst .dip .client .exception .EncryptionException ;
4636import software .xdev .bzst .dip .client .factory .DocumentBuilderFactoryNoExternalEntities ;
47- import software .xdev .bzst .dip .client .model .configuration .BzstDipConfiguration ;
4837
4938
5039/**
@@ -59,41 +48,6 @@ private WebClientUtil()
5948 {
6049 }
6150
62- public static String createRequestToken (final BzstDipConfiguration configuration )
63- {
64- LOGGER .debug ("Creating jwt token..." );
65- try (final InputStream keystoreInputStream = configuration .getCertificateKeystoreInputStream ().get ())
66- {
67- final KeyStore .PrivateKeyEntry privateKeyEntry = SigningUtil .getPrivateKeyEntry (
68- keystoreInputStream ,
69- configuration .getKeyStorePrivateKeyAlias (),
70- configuration .getCertificateKeystorePassword (),
71- SigningUtil .KEYSTORE_TYPE
72- );
73-
74- final PrivateKey privateKey = privateKeyEntry .getPrivateKey ();
75- final String clientId = configuration .getClientId ();
76- LOGGER .debug ("Using client id: {}" , clientId );
77-
78- return Jwts .builder ()
79- .issuer (clientId )
80- .subject (clientId )
81- .audience ().add (
82- configuration .getRealmEnvironmentBaseUrl () + MDS_POSTFIX )
83- .and ()
84- .issuedAt (new Date ())
85- .expiration (new Date (System .currentTimeMillis () + Duration .ofMinutes (5 ).toMillis ()))
86- .id (UUID .randomUUID ().toString ())
87- .notBefore (new Date (System .currentTimeMillis () - Duration .ofMinutes (1 ).toMillis ()))
88- .signWith (privateKey , Jwts .SIG .RS256 )
89- .compact ();
90- }
91- catch (final IOException ioException )
92- {
93- throw new EncryptionException ("An error occurred while creating the request token." , ioException );
94- }
95- }
96-
9751 public static List <String > extractTransferNumberFromXml (final String xmlString ) throws IOException
9852 {
9953 try
0 commit comments