Skip to content

Commit 2188f2f

Browse files
committed
[TEST] 애플 로그인 오류 확인 로그 기록
[TEST] 애플 로그인 테스트 [TEST] 애플 로그인 테스트
1 parent bbf16bd commit 2188f2f

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

.github/workflows/CD.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ jobs:
2929
env:
3030
API_KEY: ${{ secrets.APPSTORE_API_KEY_ID }}
3131
run: |
32-
mkdir -p src/main/resources/static
33-
echo "${{ secrets.APPLE_AUTH_KEY }}" > src/main/resources/static/AuthKey_$API_KEY.p8
32+
mkdir -p src/main/resources/static/apple
33+
echo "${{ secrets.APPLE_AUTH_KEY }}" > src/main/resources/static/apple/AuthKey_$API_KEY.p8
3434
3535
- name: Grant execute permission for gradlew
3636
run: chmod +x gradlew

.github/workflows/CI.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
build: # job 이름: build
1212
runs-on: ubuntu-22.04 # VM의 OS 지정 (EC2와 동일 버전)
1313

14-
steps:
14+
steps:
1515
- name: Checkout
1616
uses: actions/checkout@v3
1717

@@ -20,7 +20,7 @@ jobs:
2020
with:
2121
distribution: 'corretto'
2222
java-version: '17'
23-
23+
2424
- name: Create application.yml and application-prod.yml
2525
run: |
2626
mkdir src/main/resources
@@ -32,8 +32,8 @@ jobs:
3232
env:
3333
API_KEY: ${{ secrets.APPSTORE_API_KEY_ID }}
3434
run: |
35-
mkdir -p src/main/resources/static
36-
echo "${{ secrets.APPLE_AUTH_KEY }}" > src/main/resources/static/AuthKey_$API_KEY.p8
35+
mkdir -p src/main/resources/static/apple
36+
echo "${{ secrets.APPLE_AUTH_KEY }}" > src/main/resources/static/apple/AuthKey_$API_KEY.p8
3737
3838
- name: Grant execute permission for gradlew
3939
run: chmod +x gradlew

src/main/java/org/websoso/WSSServer/oauth2/service/AppleService.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
import io.jsonwebtoken.JwtException;
2424
import io.jsonwebtoken.Jwts;
2525
import io.jsonwebtoken.UnsupportedJwtException;
26-
import java.io.FileReader;
2726
import java.io.IOException;
27+
import java.io.InputStreamReader;
2828
import java.math.BigInteger;
2929
import java.security.KeyFactory;
3030
import 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

Comments
 (0)