Skip to content

Commit e09a0f9

Browse files
authored
Merge pull request #1041 from sigstore/add-conformance-token
Add option to use conformance token
2 parents 4fb7b09 + 61ae410 commit e09a0f9

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* Copyright 2025 The Sigstore Authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package dev.sigstore.testkit.oidc;
17+
18+
import dev.sigstore.oidc.client.TokenStringOidcClient;
19+
import java.io.IOException;
20+
import java.net.URI;
21+
import java.net.http.HttpClient;
22+
import java.net.http.HttpRequest;
23+
import java.net.http.HttpResponse;
24+
import java.nio.charset.StandardCharsets;
25+
26+
/**
27+
* A token provider that will grab the "unsafe" token from sigstore github conformance testing. This
28+
* should never be used by actual signers and should only be available in tests. Use this with the
29+
* {@link TokenStringOidcClient}.
30+
*/
31+
public class ConformanceTestingTokenProvider implements TokenStringOidcClient.TokenStringProvider {
32+
33+
public static ConformanceTestingTokenProvider newProvider() {
34+
return new ConformanceTestingTokenProvider();
35+
}
36+
37+
private ConformanceTestingTokenProvider() {}
38+
39+
@Override
40+
public String getTokenString() throws Exception {
41+
HttpClient client = HttpClient.newBuilder().followRedirects(HttpClient.Redirect.NORMAL).build();
42+
URI fileUri =
43+
new URI(
44+
"https://raw.githubusercontent.com/sigstore-conformance/extremely-dangerous-public-oidc-beacon/refs/heads/current-token/oidc-token.txt");
45+
HttpRequest request =
46+
HttpRequest.newBuilder()
47+
.uri(fileUri)
48+
.GET() // Specifies a GET request
49+
.build();
50+
HttpResponse<String> response =
51+
client.send(request, HttpResponse.BodyHandlers.ofString(StandardCharsets.UTF_8));
52+
if (response.statusCode() != 200) {
53+
throw new IOException("Failed to read remote test oidc token");
54+
}
55+
return response.body();
56+
}
57+
}

0 commit comments

Comments
 (0)