123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356 |
- package org.apache.archiva.rest.api.services.v2;/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
- import io.swagger.v3.oas.annotations.Operation;
- import io.swagger.v3.oas.annotations.Parameter;
- import io.swagger.v3.oas.annotations.Parameters;
- import io.swagger.v3.oas.annotations.enums.ParameterIn;
- import io.swagger.v3.oas.annotations.media.ArraySchema;
- import io.swagger.v3.oas.annotations.media.Content;
- import io.swagger.v3.oas.annotations.media.Schema;
- import io.swagger.v3.oas.annotations.parameters.RequestBody;
- import io.swagger.v3.oas.annotations.responses.ApiResponse;
- import io.swagger.v3.oas.annotations.security.SecurityRequirement;
- import io.swagger.v3.oas.annotations.tags.Tag;
- import org.apache.archiva.components.rest.model.PagedResult;
- import org.apache.archiva.components.rest.model.PropertyEntry;
- import org.apache.archiva.redback.authorization.RedbackAuthorization;
- import org.apache.archiva.rest.api.model.v2.BeanInformation;
- import org.apache.archiva.rest.api.model.v2.CacheConfiguration;
- import org.apache.archiva.rest.api.model.v2.LdapConfiguration;
- import org.apache.archiva.rest.api.model.v2.SecurityConfiguration;
- import org.apache.archiva.security.common.ArchivaRoleConstants;
-
- import javax.ws.rs.Consumes;
- import javax.ws.rs.DefaultValue;
- import javax.ws.rs.GET;
- import javax.ws.rs.POST;
- import javax.ws.rs.PUT;
- import javax.ws.rs.Path;
- import javax.ws.rs.PathParam;
- import javax.ws.rs.Produces;
- import javax.ws.rs.QueryParam;
- import javax.ws.rs.core.MediaType;
- import javax.ws.rs.core.Response;
- import java.util.List;
-
- import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
- import static org.apache.archiva.rest.api.services.v2.Configuration.DEFAULT_PAGE_LIMIT;
-
- /**
- *
- * Service for configuration of redback and security related settings.
- *
- * @author Martin Stockhammer <martin_s@apache.org>
- * @since 3.0
- */
- @Path( "/security" )
- @Tag(name = "v2")
- @Tag(name = "v2/Security")
- @SecurityRequirement(name = "BearerAuth")
- public interface SecurityConfigurationService
- {
- @Path("config")
- @GET
- @Produces({ APPLICATION_JSON })
- @RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION)
- @Operation( summary = "Returns the security configuration that is currently active.",
- security = {
- @SecurityRequirement(
- name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
- )
- },
- responses = {
- @ApiResponse( responseCode = "200",
- description = "If the configuration could be retrieved",
- content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = SecurityConfiguration.class))
- ),
- @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to gather the information",
- content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = ArchivaRestError.class )) )
- }
- )
- SecurityConfiguration getConfiguration()
- throws ArchivaRestServiceException;
-
- @Path("config")
- @PUT
- @Consumes({ APPLICATION_JSON })
- @RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION)
- @Operation( summary = "Updates the security configuration.",
- security = {
- @SecurityRequirement(
- name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
- )
- },
- responses = {
- @ApiResponse( responseCode = "200",
- description = "If the configuration was updated"
- ),
- @ApiResponse( responseCode = "422", description = "Invalid content data",
- content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = ArchivaRestError.class )) ),
- @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to update the configuration",
- content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = ArchivaRestError.class )) )
- }
- )
- SecurityConfiguration updateConfiguration( SecurityConfiguration newConfiguration)
- throws ArchivaRestServiceException;
-
-
- @Path( "config/properties" )
- @GET
- @Produces( { APPLICATION_JSON } )
- @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
- @Operation( summary = "Returns all configuration properties. The result is paged.",
- parameters = {
- @Parameter(name = "q", description = "Search term"),
- @Parameter(name = "offset", description = "The offset of the first element returned"),
- @Parameter(name = "limit", description = "Maximum number of items to return in the response"),
- @Parameter(name = "orderBy", description = "List of attribute used for sorting (key, value)"),
- @Parameter(name = "order", description = "The sort order. Either ascending (asc) or descending (desc)")
- },
- security = {
- @SecurityRequirement(
- name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
- )
- },
- responses = {
- @ApiResponse( responseCode = "200",
- description = "If the list could be returned",
- content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = PagedResult.class))
- ),
- @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to gather the information",
- content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = ArchivaRestError.class )) )
- }
- )
- PagedResult<PropertyEntry> getConfigurationProperties( @QueryParam("q") @DefaultValue( "" ) String searchTerm,
- @QueryParam( "offset" ) @DefaultValue( "0" ) Integer offset,
- @QueryParam( "limit" ) @DefaultValue( value = DEFAULT_PAGE_LIMIT ) Integer limit,
- @QueryParam( "orderBy") @DefaultValue( "key" ) List<String> orderBy,
- @QueryParam("order") @DefaultValue( "asc" ) String order ) throws ArchivaRestServiceException;
-
- @Path("config/properties/{propertyName}")
- @GET
- @Produces({ APPLICATION_JSON })
- @RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION)
- @Operation( summary = "Returns a single configuration property value.",
- security = {
- @SecurityRequirement(
- name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
- )
- },
- parameters = {
- @Parameter(in = ParameterIn.PATH, name="propertyName", description = "The name of the property to get the value for")
- },
- responses = {
- @ApiResponse( responseCode = "200",
- description = "If the configuration could be retrieved",
- content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = PropertyEntry.class))
- ),
- @ApiResponse( responseCode = "404", description = "The given property name does not exist",
- content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = ArchivaRestError.class )) ),
- @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to gather the information",
- content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = ArchivaRestError.class )) )
- }
- )
- PropertyEntry getConfigurationProperty( @PathParam ( "propertyName" ) String propertyName)
- throws ArchivaRestServiceException;
-
-
- @Path("config/properties/{propertyName}")
- @PUT
- @Consumes({ APPLICATION_JSON})
- @RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION)
- @Operation( summary = "Updates a single property value of the security configuration.",
- security = {
- @SecurityRequirement(
- name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
- )
- },
- parameters = {
- @Parameter(in = ParameterIn.PATH, name="propertyName", description = "The name of the property to update")
- },
- responses = {
- @ApiResponse( responseCode = "200",
- description = "If the property value was updated."
- ),
- @ApiResponse( responseCode = "400", description = "The body data is not valid",
- content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = ArchivaRestError.class )) ),
- @ApiResponse( responseCode = "404", description = "The given property name does not exist",
- content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = ArchivaRestError.class )) ),
- @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to gather the information",
- content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = ArchivaRestError.class )) )
- }
- )
- Response updateConfigurationProperty( @PathParam ( "propertyName" ) String propertyName, PropertyEntry propertyValue)
- throws ArchivaRestServiceException;
-
-
- @Path("config/ldap")
- @GET
- @Produces({ APPLICATION_JSON })
- @RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION)
- @Operation( summary = "Returns the LDAP configuration that is currently active.",
- security = {
- @SecurityRequirement(
- name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
- )
- },
- responses = {
- @ApiResponse( responseCode = "200",
- description = "If the configuration could be retrieved",
- content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = LdapConfiguration.class))
- ),
- @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to gather the information",
- content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = ArchivaRestError.class )) )
- }
- )
- LdapConfiguration getLdapConfiguration( ) throws ArchivaRestServiceException;
-
- @Path("config/ldap")
- @PUT
- @Consumes({ APPLICATION_JSON })
- @RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION)
- @Operation( summary = "Updates the LDAP configuration that is currently active.",
- security = {
- @SecurityRequirement(
- name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
- )
- },
- responses = {
- @ApiResponse( responseCode = "200",
- description = "If the configuration was updated"
- ),
- @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to update the information",
- content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = ArchivaRestError.class )) )
- }
- )
- LdapConfiguration updateLdapConfiguration( LdapConfiguration configuration ) throws ArchivaRestServiceException;
-
- @Path("config/ldap/verify")
- @POST
- @Consumes({ APPLICATION_JSON })
- @RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION)
- @Operation( summary = "Checks the given LDAP configuration.",
- security = {
- @SecurityRequirement(
- name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
- )
- },
- responses = {
- @ApiResponse( responseCode = "200",
- description = "If the check was successful"
- ),
- @ApiResponse( responseCode = "400",
- description = "If the check was not successful",
- content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = ArchivaRestError.class ))
- ),
- @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to update the information",
- content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = ArchivaRestError.class )) )
- }
- )
- Response verifyLdapConfiguration( LdapConfiguration configuration ) throws ArchivaRestServiceException;
-
- @Path("config/cache")
- @GET
- @Produces({ APPLICATION_JSON })
- @RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION)
- @Operation( summary = "Returns the cache configuration that is currently active.",
- security = {
- @SecurityRequirement(
- name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
- )
- },
- responses = {
- @ApiResponse( responseCode = "200",
- description = "If the configuration could be retrieved",
- content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = CacheConfiguration.class))
- ),
- @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to gather the information",
- content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = ArchivaRestError.class )) )
- }
- )
- CacheConfiguration getCacheConfiguration( ) throws ArchivaRestServiceException;
-
- @Path("config/cache")
- @PUT
- @Consumes({ APPLICATION_JSON })
- @RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION)
- @Operation( summary = "Updates the LDAP configuration that is currently active.",
- security = {
- @SecurityRequirement(
- name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
- )
- },
- responses = {
- @ApiResponse( responseCode = "200",
- description = "If the configuration was updated"
- ),
- @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to update the information",
- content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = ArchivaRestError.class )) )
- }
- )
- Response updateCacheConfiguration( CacheConfiguration cacheConfiguration ) throws ArchivaRestServiceException;
-
-
- @Path("user_managers")
- @GET
- @Produces({ APPLICATION_JSON })
- @RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION)
- @Operation( summary = "Returns the available user manager implementations.",
- security = {
- @SecurityRequirement(
- name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
- )
- },
- responses = {
- @ApiResponse( responseCode = "200",
- description = "If the list could be retrieved",
- content = @Content(mediaType = APPLICATION_JSON, array = @ArraySchema(
- schema = @Schema(implementation = BeanInformation.class)))
- ),
- @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to gather the information",
- content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = ArchivaRestError.class )) )
- }
- )
- List<BeanInformation> getAvailableUserManagers()
- throws ArchivaRestServiceException;
-
- @Path("rbac_managers")
- @GET
- @Produces({ APPLICATION_JSON })
- @RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION)
- @Operation( summary = "Returns the available RBAC manager implementations.",
- security = {
- @SecurityRequirement(
- name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
- )
- },
- responses = {
- @ApiResponse( responseCode = "200",
- description = "If the list could be retrieved",
- content = @Content(mediaType = APPLICATION_JSON, array = @ArraySchema(
- schema = @Schema(implementation = BeanInformation.class)))
- ),
- @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to gather the information",
- content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = ArchivaRestError.class )) )
- }
- )
- List<BeanInformation> getAvailableRbacManagers()
- throws ArchivaRestServiceException;
-
- }
|