2323import io .jsonwebtoken .JwtException ;
2424import io .jsonwebtoken .Jwts ;
2525import io .jsonwebtoken .UnsupportedJwtException ;
26- import java .io .FileReader ;
2726import java .io .IOException ;
27+ import java .io .InputStreamReader ;
2828import java .math .BigInteger ;
2929import java .security .KeyFactory ;
3030import java .security .NoSuchAlgorithmException ;
@@ -170,6 +170,7 @@ private Claims extractClaims(String appleToken, PublicKey publicKey) {
170170 } catch (IllegalArgumentException e ) {
171171 throw new CustomAppleLoginException (EMPTY_JWT , "empty jwt" );
172172 } catch (JwtException e ) {
173+ System .out .println (e .getMessage ());
173174 throw new CustomAppleLoginException (JWT_VERIFICATION_FAILED , "jwt validation or analysis failed" );
174175 }
175176 }
@@ -184,6 +185,7 @@ private String createClientSecret() {
184185
185186 return jwt .serialize ();
186187 } catch (Exception e ) {
188+ System .out .println (e .getMessage ());
187189 throw new CustomAppleLoginException (CLIENT_SECRET_CREATION_FAILED , "failed to generate client secret" );
188190 }
189191 }
@@ -209,16 +211,20 @@ private void signJwt(SignedJWT jwt) {
209211 JWSSigner signer = new ECDSASigner (ecPrivateKey .getS ());
210212 jwt .sign (signer );
211213 } catch (Exception e ) {
214+ System .out .println (e .getMessage ());
212215 throw new CustomAppleLoginException (CLIENT_SECRET_CREATION_FAILED , "failed to create client secret" );
213216 }
214217 }
215218
216219 private byte [] readPrivateKey (String keyPath ) {
217220 Resource resource = new ClassPathResource (keyPath );
218- try (PemReader pemReader = new PemReader (new FileReader (resource .getFile ()))) {
221+ System .out .println ("Resource exists: " + resource .exists ());
222+ System .out .println ("Resource file path: " + resource .getFilename ());
223+ try (PemReader pemReader = new PemReader (new InputStreamReader (resource .getInputStream ()))) {
219224 PemObject pemObject = pemReader .readPemObject ();
220225 return pemObject .getContent ();
221226 } catch (IOException e ) {
227+ System .out .println (e .getMessage ());
222228 throw new CustomAppleLoginException (PRIVATE_KEY_READ_FAILED , "failed to read private key" );
223229 }
224230 }
@@ -233,6 +239,7 @@ private AppleTokenResponse requestAppleToken(String authorizationCode, String cl
233239 .retrieve ()
234240 .body (AppleTokenResponse .class );
235241 } catch (Exception e ) {
242+ System .out .println (e .getMessage ());
236243 throw new CustomAppleLoginException (TOKEN_REQUEST_FAILED , "failed to get token from Apple server" );
237244 }
238245 }
0 commit comments