org.eclipse.ditto.wot.model.BearerSecurityScheme Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ditto-wot-model Show documentation
Show all versions of ditto-wot-model Show documentation
Eclipse Ditto is a framework for creating and managing digital twins in the IoT.
/*
* Copyright (c) 2022 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.ditto.wot.model;
import static org.eclipse.ditto.base.model.common.ConditionChecker.checkNotNull;
import java.util.Optional;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;
import org.eclipse.ditto.json.JsonFactory;
import org.eclipse.ditto.json.JsonFieldDefinition;
import org.eclipse.ditto.json.JsonObject;
/**
* A BearerSecurityScheme is a {@link SecurityScheme} indicating to use {@code Bearer Tokens} "independently of OAuth2".
*
* @see RFC6750 - Bearer Token
* @see WoT TD BearerSecurityScheme
* @since 2.4.0
*/
public interface BearerSecurityScheme extends SecurityScheme {
static BearerSecurityScheme fromJson(final String securitySchemeName, final JsonObject jsonObject) {
return new ImmutableBearerSecurityScheme(securitySchemeName, jsonObject);
}
static BearerSecurityScheme.Builder newBuilder(final CharSequence securitySchemeName) {
return BearerSecurityScheme.Builder.newBuilder(securitySchemeName);
}
static BearerSecurityScheme.Builder newBuilder(final CharSequence securitySchemeName, final JsonObject jsonObject) {
return BearerSecurityScheme.Builder.newBuilder(securitySchemeName, jsonObject);
}
@Override
default SecuritySchemeScheme getScheme() {
return SecuritySchemeScheme.BEARER;
}
Optional getAuthorization();
Optional getAlg();
Optional getFormat();
Optional getIn();
Optional getName();
interface Builder extends SecurityScheme.Builder {
static Builder newBuilder(final CharSequence securitySchemeName) {
return new MutableBearerSecuritySchemeBuilder(
checkNotNull(securitySchemeName, "securitySchemeName").toString(),
JsonObject.newBuilder());
}
static Builder newBuilder(final CharSequence securitySchemeName, final JsonObject jsonObject) {
return new MutableBearerSecuritySchemeBuilder(
checkNotNull(securitySchemeName, "securitySchemeName").toString(),
jsonObject.toBuilder());
}
Builder setAuthorization(@Nullable IRI authorization);
Builder setAlg(@Nullable String alg);
Builder setFormat(@Nullable String format);
Builder setIn(@Nullable String in);
Builder setName(@Nullable String name);
}
/**
* An enumeration of the known {@link JsonFieldDefinition}s of a BearerSecurityScheme.
*/
@Immutable
final class JsonFields {
public static final JsonFieldDefinition AUTHORIZATION = JsonFactory.newStringFieldDefinition(
"authorization");
public static final JsonFieldDefinition ALG = JsonFactory.newStringFieldDefinition(
"alg");
public static final JsonFieldDefinition FORMAT = JsonFactory.newStringFieldDefinition(
"format");
public static final JsonFieldDefinition IN = JsonFactory.newStringFieldDefinition(
"in");
public static final JsonFieldDefinition NAME = JsonFactory.newStringFieldDefinition(
"name");
private JsonFields() {
throw new AssertionError();
}
}
}