-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Java, adds component SecuritySchemes (#383)
* Adds SecurityScheme * Adds ApiKeySecurityScheme * Adds 3 security schemes * Adds all securityScheme class types, many unimplemented * Updates security scheme files * Improves apikey constructor * Fixes component schema filenames for java * Adds readme links to nonexistent component security scheme docs * Adds component security scheme docs * Samples regen * Fixes java typos
- Loading branch information
Showing
42 changed files
with
990 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
samples/client/petstore/java/docs/components/securityschemes/ApiKey.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
org.openapijsonschematools.client.components.securityschemes.ApiKey | ||
# SecurityScheme ApiKey | ||
|
||
public class ApiKey | ||
extends ApiKeySecurityScheme | ||
|
||
A class that is used to apply auth to a request | ||
|
||
### Description | ||
apiKey in header | ||
|
||
### Method Summary | ||
| Modifier and Type | Method and Description | | ||
| ----------------- | ---------------------- | | ||
| void | applyAuth(Map<String, List<String>> headers, String resourcePath, String method, HttpRequest.BodyPublisher bodyPublisher, @Nullable String queryParamsSuffix, List<String> scopeNames) | | ||
|
||
### Constructor Summary | ||
| Constructor and Description | | ||
| --------------------------- | | ||
| ApiKey(String apiKey)<br>for header apiKey auth | | ||
|
||
[[Back to top]](#top) [[Back to Component Security Schemes]](../../../README.md#Component-SecuritySchemes) [[Back to README]](../../../README.md) |
22 changes: 22 additions & 0 deletions
22
samples/client/petstore/java/docs/components/securityschemes/ApiKeyQuery.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
org.openapijsonschematools.client.components.securityschemes.ApiKeyQuery | ||
# SecurityScheme ApiKeyQuery | ||
|
||
public class ApiKeyQuery | ||
extends ApiKeySecurityScheme | ||
|
||
A class that is used to apply auth to a request | ||
|
||
### Description | ||
apiKey in query | ||
|
||
### Method Summary | ||
| Modifier and Type | Method and Description | | ||
| ----------------- | ---------------------- | | ||
| void | applyAuth(Map<String, List<String>> headers, String resourcePath, String method, HttpRequest.BodyPublisher bodyPublisher, @Nullable String queryParamsSuffix, List<String> scopeNames) | | ||
|
||
### Constructor Summary | ||
| Constructor and Description | | ||
| --------------------------- | | ||
| ApiKeyQuery(String apiKey)<br>for query apiKey auth | | ||
|
||
[[Back to top]](#top) [[Back to Component Security Schemes]](../../../README.md#Component-SecuritySchemes) [[Back to README]](../../../README.md) |
22 changes: 22 additions & 0 deletions
22
samples/client/petstore/java/docs/components/securityschemes/BearerTest.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
org.openapijsonschematools.client.components.securityschemes.BearerTest | ||
# SecurityScheme BearerTest | ||
|
||
public class BearerTest | ||
extends HttpBearerSecurityScheme | ||
|
||
A class that is used to apply auth to a request | ||
|
||
### Description | ||
http bearer with JWT bearer format | ||
|
||
### Method Summary | ||
| Modifier and Type | Method and Description | | ||
| ----------------- | ---------------------- | | ||
| void | applyAuth(Map<String, List<String>> headers, String resourcePath, String method, HttpRequest.BodyPublisher bodyPublisher, @Nullable String queryParamsSuffix, List<String> scopeNames) | | ||
|
||
### Constructor Summary | ||
| Constructor and Description | | ||
| --------------------------- | | ||
| BearerTest(String accessToken) | | ||
|
||
[[Back to top]](#top) [[Back to Component Security Schemes]](../../../README.md#Component-SecuritySchemes) [[Back to README]](../../../README.md) |
22 changes: 22 additions & 0 deletions
22
samples/client/petstore/java/docs/components/securityschemes/HttpBasicTest.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
org.openapijsonschematools.client.components.securityschemes.HttpBasicTest | ||
# SecurityScheme HttpBasicTest | ||
|
||
public class HttpBasicTest | ||
extends HttpBasicSecurityScheme | ||
|
||
A class that is used to apply auth to a request | ||
|
||
### Description | ||
http basic | ||
|
||
### Method Summary | ||
| Modifier and Type | Method and Description | | ||
| ----------------- | ---------------------- | | ||
| void | applyAuth(Map<String, List<String>> headers, String resourcePath, String method, HttpRequest.BodyPublisher bodyPublisher, @Nullable String queryParamsSuffix, List<String> scopeNames) | | ||
|
||
### Constructor Summary | ||
| Constructor and Description | | ||
| --------------------------- | | ||
| HttpBasicTest(String userId, String password) | | ||
|
||
[[Back to top]](#top) [[Back to Component Security Schemes]](../../../README.md#Component-SecuritySchemes) [[Back to README]](../../../README.md) |
22 changes: 22 additions & 0 deletions
22
samples/client/petstore/java/docs/components/securityschemes/HttpSignatureTest.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
org.openapijsonschematools.client.components.securityschemes.HttpSignatureTest | ||
# SecurityScheme HttpSignatureTest | ||
|
||
public class HttpSignatureTest | ||
extends HttpSignatureSecurityScheme | ||
|
||
A class that is used to apply auth to a request | ||
|
||
### Description | ||
http + signature | ||
|
||
### Method Summary | ||
| Modifier and Type | Method and Description | | ||
| ----------------- | ---------------------- | | ||
| void | applyAuth(Map<String, List<String>> headers, String resourcePath, String method, HttpRequest.BodyPublisher bodyPublisher, @Nullable String queryParamsSuffix, List<String> scopeNames) | | ||
|
||
### Constructor Summary | ||
| Constructor and Description | | ||
| --------------------------- | | ||
| todo | | ||
|
||
[[Back to top]](#top) [[Back to Component Security Schemes]](../../../README.md#Component-SecuritySchemes) [[Back to README]](../../../README.md) |
22 changes: 22 additions & 0 deletions
22
samples/client/petstore/java/docs/components/securityschemes/OpenIdConnectTest.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
org.openapijsonschematools.client.components.securityschemes.OpenIdConnectTest | ||
# SecurityScheme OpenIdConnectTest | ||
|
||
public class OpenIdConnectTest | ||
extends OpenIdConnectSecurityScheme | ||
|
||
A class that is used to apply auth to a request | ||
|
||
### Description | ||
openIdConnect | ||
|
||
### Method Summary | ||
| Modifier and Type | Method and Description | | ||
| ----------------- | ---------------------- | | ||
| void | applyAuth(Map<String, List<String>> headers, String resourcePath, String method, HttpRequest.BodyPublisher bodyPublisher, @Nullable String queryParamsSuffix, List<String> scopeNames) | | ||
|
||
### Constructor Summary | ||
| Constructor and Description | | ||
| --------------------------- | | ||
| todo | | ||
|
||
[[Back to top]](#top) [[Back to Component Security Schemes]](../../../README.md#Component-SecuritySchemes) [[Back to README]](../../../README.md) |
22 changes: 22 additions & 0 deletions
22
samples/client/petstore/java/docs/components/securityschemes/PetstoreAuth.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
org.openapijsonschematools.client.components.securityschemes.PetstoreAuth | ||
# SecurityScheme PetstoreAuth | ||
|
||
public class PetstoreAuth | ||
extends Oauth2SecurityScheme | ||
|
||
A class that is used to apply auth to a request | ||
|
||
### Description | ||
oauth2 implicit flow with two scopes | ||
|
||
### Method Summary | ||
| Modifier and Type | Method and Description | | ||
| ----------------- | ---------------------- | | ||
| void | applyAuth(Map<String, List<String>> headers, String resourcePath, String method, HttpRequest.BodyPublisher bodyPublisher, @Nullable String queryParamsSuffix, List<String> scopeNames) | | ||
|
||
### Constructor Summary | ||
| Constructor and Description | | ||
| --------------------------- | | ||
| todo | | ||
|
||
[[Back to top]](#top) [[Back to Component Security Schemes]](../../../README.md#Component-SecuritySchemes) [[Back to README]](../../../README.md) |
13 changes: 13 additions & 0 deletions
13
...va/src/main/java/org/openapijsonschematools/client/components/securityschemes/ApiKey.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.openapijsonschematools.client.components.securityschemes; | ||
|
||
import org.openapijsonschematools.client.securityschemes.ApiKeySecurityScheme; | ||
import org.openapijsonschematools.client.securityschemes.ApiKeyInLocation; | ||
|
||
public class ApiKey extends ApiKeySecurityScheme { | ||
/* | ||
apiKey in header | ||
*/ | ||
public ApiKey(String apiKey) { | ||
super(apiKey, "api_key", ApiKeyInLocation.HEADER); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...c/main/java/org/openapijsonschematools/client/components/securityschemes/ApiKeyQuery.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.openapijsonschematools.client.components.securityschemes; | ||
|
||
import org.openapijsonschematools.client.securityschemes.ApiKeySecurityScheme; | ||
import org.openapijsonschematools.client.securityschemes.ApiKeyInLocation; | ||
|
||
public class ApiKeyQuery extends ApiKeySecurityScheme { | ||
/* | ||
apiKey in query | ||
*/ | ||
public ApiKeyQuery(String apiKey) { | ||
super(apiKey, "api_key_query", ApiKeyInLocation.QUERY); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...rc/main/java/org/openapijsonschematools/client/components/securityschemes/BearerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.openapijsonschematools.client.components.securityschemes; | ||
|
||
import org.openapijsonschematools.client.securityschemes.HttpBearerSecurityScheme; | ||
|
||
public class BearerTest extends HttpBearerSecurityScheme { | ||
/* | ||
http bearer with JWT bearer format | ||
*/ | ||
public BearerTest(String accessToken) { | ||
super(accessToken, "JWT"); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...main/java/org/openapijsonschematools/client/components/securityschemes/HttpBasicTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.openapijsonschematools.client.components.securityschemes; | ||
|
||
import org.openapijsonschematools.client.securityschemes.HttpBasicSecurityScheme; | ||
|
||
public class HttpBasicTest extends HttpBasicSecurityScheme { | ||
/* | ||
http basic | ||
*/ | ||
public HttpBasicTest(String userId, String password) { | ||
super(userId, password); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
.../java/org/openapijsonschematools/client/components/securityschemes/HttpSignatureTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.openapijsonschematools.client.components.securityschemes; | ||
|
||
import org.openapijsonschematools.client.securityschemes.HttpSignatureSecurityScheme; | ||
|
||
public class HttpSignatureTest extends HttpSignatureSecurityScheme { | ||
/* | ||
http + signature | ||
*/ | ||
} |
9 changes: 9 additions & 0 deletions
9
.../java/org/openapijsonschematools/client/components/securityschemes/OpenIdConnectTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.openapijsonschematools.client.components.securityschemes; | ||
|
||
import org.openapijsonschematools.client.securityschemes.OpenIdConnectSecurityScheme; | ||
|
||
public class OpenIdConnectTest extends OpenIdConnectSecurityScheme { | ||
/* | ||
openIdConnect | ||
*/ | ||
} |
10 changes: 10 additions & 0 deletions
10
.../main/java/org/openapijsonschematools/client/components/securityschemes/PetstoreAuth.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package org.openapijsonschematools.client.components.securityschemes; | ||
|
||
import org.openapijsonschematools.client.securityschemes.OAuth2SecurityScheme; | ||
|
||
public class PetstoreAuth extends OAuth2SecurityScheme { | ||
/* | ||
oauth2 implicit flow with two scopes | ||
*/ | ||
// todo add flows info | ||
} |
7 changes: 7 additions & 0 deletions
7
...ava/src/main/java/org/openapijsonschematools/client/securityschemes/ApiKeyInLocation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package org.openapijsonschematools.client.securityschemes; | ||
|
||
public enum ApiKeyInLocation{ | ||
QUERY, | ||
HEADER, | ||
COOKIE | ||
} |
35 changes: 35 additions & 0 deletions
35
...src/main/java/org/openapijsonschematools/client/securityschemes/ApiKeySecurityScheme.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package org.openapijsonschematools.client.securityschemes; | ||
|
||
import org.checkerframework.checker.nullness.qual.Nullable; | ||
|
||
import java.net.http.HttpRequest; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public class ApiKeySecurityScheme implements SecurityScheme { | ||
private final String apiKey; | ||
private final @Nullable String name; | ||
private final ApiKeyInLocation inLocation; | ||
|
||
protected ApiKeySecurityScheme(String apiKey, @Nullable String name, ApiKeyInLocation inLocation) { | ||
this.apiKey = apiKey; | ||
this.name = name; | ||
this.inLocation = inLocation; | ||
} | ||
|
||
@Override | ||
public void applyAuth(Map<String, List<String>> headers, String resourcePath, String method, HttpRequest.BodyPublisher bodyPublisher, @Nullable String queryParamsSuffix, List<String> scopeNames) { | ||
switch (inLocation) { | ||
case COOKIE -> { | ||
List<String> cookieValue = headers.getOrDefault("Cookie", new ArrayList<>()); | ||
cookieValue.add(apiKey); | ||
} | ||
case HEADER -> { | ||
List<String> headerValue = headers.getOrDefault(name, new ArrayList<>()); | ||
headerValue.add(apiKey); | ||
} | ||
case QUERY -> throw new UnsupportedOperationException("If you need this, submit a PR adding this feature"); | ||
} | ||
} | ||
} |
Oops, something went wrong.