io.muserver.openapi.SecuritySchemeObjectBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mu-server Show documentation
Show all versions of mu-server Show documentation
A simple but powerful web server framework
package io.muserver.openapi;
import java.net.URI;
/**
* Defines a security scheme that can be used by the operations. Supported schemes are HTTP authentication, an API key
* (either as a header or as a query parameter), OAuth2's common flows (implicit, password, application and access code)
* as defined in RFC6749, and
* OpenID Connect Discovery.
*/
public class SecuritySchemeObjectBuilder {
private String type;
private String description;
private String name;
private String in;
private String scheme;
private String bearerFormat;
private OAuthFlowsObject flows;
private URI openIdConnectUrl;
/**
* @param type REQUIRED. The type of the security scheme. Valid values are "apiKey"
,
* "http"
, "oauth2"
, "openIdConnect"
.
* @return The current builder
*/
public SecuritySchemeObjectBuilder withType(String type) {
this.type = type;
return this;
}
/**
* @param description A short description for security scheme. CommonMark syntax
* MAY be used for rich text representation.
* @return The current builder
*/
public SecuritySchemeObjectBuilder withDescription(String description) {
this.description = description;
return this;
}
/**
* @param name REQUIRED (when type is apiKey). The name of the header, query or cookie parameter to be used.
* @return The current builder
*/
public SecuritySchemeObjectBuilder withName(String name) {
this.name = name;
return this;
}
/**
* @param in REQUIRED (when type is apiKey). The location of the API key. Valid values are "query"
,
* "header"
or "cookie"
.
* @return The current builder
*/
public SecuritySchemeObjectBuilder withIn(String in) {
this.in = in;
return this;
}
/**
* @param scheme REQUIRED (when type is http). The name of the HTTP Authorization scheme to be used in the
* Authorization header as defined in RFC7235.
* @return The current builder
*/
public SecuritySchemeObjectBuilder withScheme(String scheme) {
this.scheme = scheme;
return this;
}
/**
* @param bearerFormat A hint to the client to identify how the bearer token is formatted. Bearer tokens are usually
* generated by an authorization server, so this information is primarily for documentation purposes.
* @return The current builder
*/
public SecuritySchemeObjectBuilder withBearerFormat(String bearerFormat) {
this.bearerFormat = bearerFormat;
return this;
}
/**
* @param flows REQUIRED (when type is oauth2). An object containing configuration information for the flow types supported.
* @return The current builder
*/
public SecuritySchemeObjectBuilder withFlows(OAuthFlowsObject flows) {
this.flows = flows;
return this;
}
/**
* @param openIdConnectUrl REQUIRED (when type is openIdConnect). OpenId Connect URL to discover OAuth2 configuration values.
* This MUST be in the form of a URL.
* @return The current builder
*/
public SecuritySchemeObjectBuilder withOpenIdConnectUrl(URI openIdConnectUrl) {
this.openIdConnectUrl = openIdConnectUrl;
return this;
}
public SecuritySchemeObject build() {
return new SecuritySchemeObject(type, description, name, in, scheme, bearerFormat, flows, openIdConnectUrl);
}
/**
* Creates a builder for a {@link SecuritySchemeObject}
*
* @return A new builder
*/
public static SecuritySchemeObjectBuilder securitySchemeObject() {
return new SecuritySchemeObjectBuilder();
}
}