Search in sources :

Example 1 with Oas20SecurityDefinitions

use of io.apicurio.datamodels.openapi.v2.models.Oas20SecurityDefinitions in project apicurio-data-models by Apicurio.

the class DeleteSecuritySchemeCommand_20 method doDeleteScheme.

/**
 * @see io.apicurio.datamodels.cmd.commands.DeleteSecuritySchemeCommand#doDeleteScheme(io.apicurio.datamodels.core.models.Document)
 */
@Override
protected Object doDeleteScheme(Document document) {
    Oas20Document doc20 = (Oas20Document) document;
    Oas20SecurityDefinitions definitions = doc20.securityDefinitions;
    if (this.isNullOrUndefined(definitions)) {
        return null;
    }
    return Library.writeNode(definitions.removeSecurityScheme(this._schemeName));
}
Also used : Oas20SecurityDefinitions(io.apicurio.datamodels.openapi.v2.models.Oas20SecurityDefinitions) Oas20Document(io.apicurio.datamodels.openapi.v2.models.Oas20Document)

Example 2 with Oas20SecurityDefinitions

use of io.apicurio.datamodels.openapi.v2.models.Oas20SecurityDefinitions in project apicurio-data-models by Apicurio.

the class DeleteSecuritySchemeCommand_20 method doRestoreScheme.

/**
 * @see io.apicurio.datamodels.cmd.commands.DeleteSecuritySchemeCommand#doRestoreScheme(io.apicurio.datamodels.core.models.Document, java.lang.Object)
 */
@Override
protected void doRestoreScheme(Document document, Object oldScheme) {
    Oas20Document doc20 = (Oas20Document) document;
    Oas20SecurityDefinitions definitions = doc20.securityDefinitions;
    if (this.isNullOrUndefined(definitions) || this.isNullOrUndefined(oldScheme)) {
        return;
    }
    Oas20SecurityScheme scheme = definitions.createSecurityScheme(this._schemeName);
    Library.readNode(oldScheme, scheme);
    definitions.addSecurityScheme(this._schemeName, scheme);
}
Also used : Oas20SecurityDefinitions(io.apicurio.datamodels.openapi.v2.models.Oas20SecurityDefinitions) Oas20Document(io.apicurio.datamodels.openapi.v2.models.Oas20Document) Oas20SecurityScheme(io.apicurio.datamodels.openapi.v2.models.Oas20SecurityScheme)

Example 3 with Oas20SecurityDefinitions

use of io.apicurio.datamodels.openapi.v2.models.Oas20SecurityDefinitions in project apicurio-data-models by Apicurio.

the class Oas20DataModelReader method readSecurityDefinitions.

/**
 * Reads the security definitions.
 * @param json
 * @param node
 */
public void readSecurityDefinitions(Object json, Oas20SecurityDefinitions node) {
    List<String> names = JsonCompat.keys(json);
    for (String name : names) {
        Object schemeJson = JsonCompat.consumeProperty(json, name);
        Oas20SecurityScheme schemeModel = node.createSecurityScheme(name);
        this.readSecurityScheme(schemeJson, schemeModel);
        node.addSecurityScheme(name, schemeModel);
    }
}
Also used : Oas20SecurityScheme(io.apicurio.datamodels.openapi.v2.models.Oas20SecurityScheme)

Example 4 with Oas20SecurityDefinitions

use of io.apicurio.datamodels.openapi.v2.models.Oas20SecurityDefinitions in project apicurio-data-models by Apicurio.

the class OasUnexpectedSecurityRequirementScopesRule method visitSecurityRequirement.

/**
 * @see io.apicurio.datamodels.combined.visitors.CombinedAllNodeVisitor#visitSecurityRequirement(io.apicurio.datamodels.core.models.common.SecurityRequirement)
 */
@Override
public void visitSecurityRequirement(SecurityRequirement node) {
    List<String> snames = node.getSecurityRequirementNames();
    snames.forEach(sname -> {
        Oas20SecurityDefinitions sdefs = ((Oas20Document) node.ownerDocument()).securityDefinitions;
        if (hasValue(sdefs)) {
            Oas20SecurityScheme scheme = sdefs.getSecurityScheme(sname);
            if (hasValue(scheme)) {
                if (equals(scheme.type, "oauth2")) {
                    Oas20Scopes definedScopes = scheme.scopes;
                    List<String> requiredScopes = node.getScopes(sname);
                    this.reportIfInvalid(isValidScopes(requiredScopes, definedScopes), node, null, map("sname", sname));
                }
            }
        }
    });
}
Also used : Oas20SecurityDefinitions(io.apicurio.datamodels.openapi.v2.models.Oas20SecurityDefinitions) Oas20Document(io.apicurio.datamodels.openapi.v2.models.Oas20Document) Oas20SecurityScheme(io.apicurio.datamodels.openapi.v2.models.Oas20SecurityScheme) Oas20Scopes(io.apicurio.datamodels.openapi.v2.models.Oas20Scopes)

Aggregations

Oas20Document (io.apicurio.datamodels.openapi.v2.models.Oas20Document)3 Oas20SecurityDefinitions (io.apicurio.datamodels.openapi.v2.models.Oas20SecurityDefinitions)3 Oas20SecurityScheme (io.apicurio.datamodels.openapi.v2.models.Oas20SecurityScheme)3 Oas20Scopes (io.apicurio.datamodels.openapi.v2.models.Oas20Scopes)1