1 package org.apache.archiva.rest.api.services.v2;/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing,
12 * software distributed under the License is distributed on an
13 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 * KIND, either express or implied. See the License for the
15 * specific language governing permissions and limitations
19 import io.swagger.v3.oas.annotations.Operation;
20 import io.swagger.v3.oas.annotations.Parameter;
21 import io.swagger.v3.oas.annotations.Parameters;
22 import io.swagger.v3.oas.annotations.enums.ParameterIn;
23 import io.swagger.v3.oas.annotations.media.ArraySchema;
24 import io.swagger.v3.oas.annotations.media.Content;
25 import io.swagger.v3.oas.annotations.media.Schema;
26 import io.swagger.v3.oas.annotations.parameters.RequestBody;
27 import io.swagger.v3.oas.annotations.responses.ApiResponse;
28 import io.swagger.v3.oas.annotations.security.SecurityRequirement;
29 import io.swagger.v3.oas.annotations.tags.Tag;
30 import org.apache.archiva.components.rest.model.PagedResult;
31 import org.apache.archiva.components.rest.model.PropertyEntry;
32 import org.apache.archiva.redback.authorization.RedbackAuthorization;
33 import org.apache.archiva.rest.api.model.v2.BeanInformation;
34 import org.apache.archiva.rest.api.model.v2.CacheConfiguration;
35 import org.apache.archiva.rest.api.model.v2.LdapConfiguration;
36 import org.apache.archiva.rest.api.model.v2.SecurityConfiguration;
37 import org.apache.archiva.security.common.ArchivaRoleConstants;
39 import javax.ws.rs.Consumes;
40 import javax.ws.rs.DefaultValue;
41 import javax.ws.rs.GET;
42 import javax.ws.rs.POST;
43 import javax.ws.rs.PUT;
44 import javax.ws.rs.Path;
45 import javax.ws.rs.PathParam;
46 import javax.ws.rs.Produces;
47 import javax.ws.rs.QueryParam;
48 import javax.ws.rs.core.MediaType;
49 import javax.ws.rs.core.Response;
50 import java.util.List;
52 import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
53 import static org.apache.archiva.rest.api.services.v2.Configuration.DEFAULT_PAGE_LIMIT;
57 * Service for configuration of redback and security related settings.
59 * @author Martin Stockhammer <martin_s@apache.org>
64 @Tag(name = "v2/Security")
65 @SecurityRequirement(name = "BearerAuth")
66 public interface SecurityConfigurationService
70 @Produces({ APPLICATION_JSON })
71 @RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION)
72 @Operation( summary = "Returns the security configuration that is currently active.",
75 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
79 @ApiResponse( responseCode = "200",
80 description = "If the configuration could be retrieved",
81 content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = SecurityConfiguration.class))
83 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to gather the information",
84 content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = ArchivaRestError.class )) )
87 SecurityConfiguration getConfiguration()
88 throws ArchivaRestServiceException;
92 @Consumes({ APPLICATION_JSON })
93 @RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION)
94 @Operation( summary = "Updates the security configuration.",
97 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
101 @ApiResponse( responseCode = "200",
102 description = "If the configuration was updated"
104 @ApiResponse( responseCode = "422", description = "Invalid content data",
105 content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = ArchivaRestError.class )) ),
106 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to update the configuration",
107 content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = ArchivaRestError.class )) )
110 SecurityConfiguration updateConfiguration( SecurityConfiguration newConfiguration)
111 throws ArchivaRestServiceException;
114 @Path( "config/properties" )
116 @Produces( { APPLICATION_JSON } )
117 @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
118 @Operation( summary = "Returns all configuration properties. The result is paged.",
120 @Parameter(name = "q", description = "Search term"),
121 @Parameter(name = "offset", description = "The offset of the first element returned"),
122 @Parameter(name = "limit", description = "Maximum number of items to return in the response"),
123 @Parameter(name = "orderBy", description = "List of attribute used for sorting (key, value)"),
124 @Parameter(name = "order", description = "The sort order. Either ascending (asc) or descending (desc)")
127 @SecurityRequirement(
128 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
132 @ApiResponse( responseCode = "200",
133 description = "If the list could be returned",
134 content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = PagedResult.class))
136 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to gather the information",
137 content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = ArchivaRestError.class )) )
140 PagedResult<PropertyEntry> getConfigurationProperties( @QueryParam("q") @DefaultValue( "" ) String searchTerm,
141 @QueryParam( "offset" ) @DefaultValue( "0" ) Integer offset,
142 @QueryParam( "limit" ) @DefaultValue( value = DEFAULT_PAGE_LIMIT ) Integer limit,
143 @QueryParam( "orderBy") @DefaultValue( "key" ) List<String> orderBy,
144 @QueryParam("order") @DefaultValue( "asc" ) String order ) throws ArchivaRestServiceException;
146 @Path("config/properties/{propertyName}")
148 @Produces({ APPLICATION_JSON })
149 @RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION)
150 @Operation( summary = "Returns a single configuration property value.",
152 @SecurityRequirement(
153 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
157 @Parameter(in = ParameterIn.PATH, name="propertyName", description = "The name of the property to get the value for")
160 @ApiResponse( responseCode = "200",
161 description = "If the configuration could be retrieved",
162 content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = PropertyEntry.class))
164 @ApiResponse( responseCode = "404", description = "The given property name does not exist",
165 content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = ArchivaRestError.class )) ),
166 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to gather the information",
167 content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = ArchivaRestError.class )) )
170 PropertyEntry getConfigurationProperty( @PathParam ( "propertyName" ) String propertyName)
171 throws ArchivaRestServiceException;
174 @Path("config/properties/{propertyName}")
176 @Consumes({ APPLICATION_JSON})
177 @RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION)
178 @Operation( summary = "Updates a single property value of the security configuration.",
180 @SecurityRequirement(
181 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
185 @Parameter(in = ParameterIn.PATH, name="propertyName", description = "The name of the property to update")
188 @ApiResponse( responseCode = "200",
189 description = "If the property value was updated."
191 @ApiResponse( responseCode = "400", description = "The body data is not valid",
192 content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = ArchivaRestError.class )) ),
193 @ApiResponse( responseCode = "404", description = "The given property name does not exist",
194 content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = ArchivaRestError.class )) ),
195 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to gather the information",
196 content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = ArchivaRestError.class )) )
199 Response updateConfigurationProperty( @PathParam ( "propertyName" ) String propertyName, PropertyEntry propertyValue)
200 throws ArchivaRestServiceException;
205 @Produces({ APPLICATION_JSON })
206 @RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION)
207 @Operation( summary = "Returns the LDAP configuration that is currently active.",
209 @SecurityRequirement(
210 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
214 @ApiResponse( responseCode = "200",
215 description = "If the configuration could be retrieved",
216 content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = LdapConfiguration.class))
218 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to gather the information",
219 content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = ArchivaRestError.class )) )
222 LdapConfiguration getLdapConfiguration( ) throws ArchivaRestServiceException;
226 @Consumes({ APPLICATION_JSON })
227 @RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION)
228 @Operation( summary = "Updates the LDAP configuration that is currently active.",
230 @SecurityRequirement(
231 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
235 @ApiResponse( responseCode = "200",
236 description = "If the configuration was updated"
238 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to update the information",
239 content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = ArchivaRestError.class )) )
242 LdapConfiguration updateLdapConfiguration( LdapConfiguration configuration ) throws ArchivaRestServiceException;
244 @Path("config/ldap/verify")
246 @Consumes({ APPLICATION_JSON })
247 @RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION)
248 @Operation( summary = "Checks the given LDAP configuration.",
250 @SecurityRequirement(
251 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
255 @ApiResponse( responseCode = "200",
256 description = "If the check was successful"
258 @ApiResponse( responseCode = "400",
259 description = "If the check was not successful",
260 content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = ArchivaRestError.class ))
262 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to update the information",
263 content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = ArchivaRestError.class )) )
266 Response verifyLdapConfiguration( LdapConfiguration configuration ) throws ArchivaRestServiceException;
268 @Path("config/cache")
270 @Produces({ APPLICATION_JSON })
271 @RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION)
272 @Operation( summary = "Returns the cache configuration that is currently active.",
274 @SecurityRequirement(
275 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
279 @ApiResponse( responseCode = "200",
280 description = "If the configuration could be retrieved",
281 content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = CacheConfiguration.class))
283 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to gather the information",
284 content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = ArchivaRestError.class )) )
287 CacheConfiguration getCacheConfiguration( ) throws ArchivaRestServiceException;
289 @Path("config/cache")
291 @Consumes({ APPLICATION_JSON })
292 @RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION)
293 @Operation( summary = "Updates the LDAP configuration that is currently active.",
295 @SecurityRequirement(
296 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
300 @ApiResponse( responseCode = "200",
301 description = "If the configuration was updated"
303 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to update the information",
304 content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = ArchivaRestError.class )) )
307 Response updateCacheConfiguration( CacheConfiguration cacheConfiguration ) throws ArchivaRestServiceException;
310 @Path("user_managers")
312 @Produces({ APPLICATION_JSON })
313 @RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION)
314 @Operation( summary = "Returns the available user manager implementations.",
316 @SecurityRequirement(
317 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
321 @ApiResponse( responseCode = "200",
322 description = "If the list could be retrieved",
323 content = @Content(mediaType = APPLICATION_JSON, array = @ArraySchema(
324 schema = @Schema(implementation = BeanInformation.class)))
326 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to gather the information",
327 content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = ArchivaRestError.class )) )
330 List<BeanInformation> getAvailableUserManagers()
331 throws ArchivaRestServiceException;
333 @Path("rbac_managers")
335 @Produces({ APPLICATION_JSON })
336 @RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION)
337 @Operation( summary = "Returns the available RBAC manager implementations.",
339 @SecurityRequirement(
340 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
344 @ApiResponse( responseCode = "200",
345 description = "If the list could be retrieved",
346 content = @Content(mediaType = APPLICATION_JSON, array = @ArraySchema(
347 schema = @Schema(implementation = BeanInformation.class)))
349 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to gather the information",
350 content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = ArchivaRestError.class )) )
353 List<BeanInformation> getAvailableRbacManagers()
354 throws ArchivaRestServiceException;