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.Content;
24 import io.swagger.v3.oas.annotations.media.Schema;
25 import io.swagger.v3.oas.annotations.parameters.RequestBody;
26 import io.swagger.v3.oas.annotations.responses.ApiResponse;
27 import io.swagger.v3.oas.annotations.security.SecurityRequirement;
28 import io.swagger.v3.oas.annotations.tags.Tag;
29 import org.apache.archiva.components.rest.model.PagedResult;
30 import org.apache.archiva.components.rest.model.PropertyEntry;
31 import org.apache.archiva.redback.authorization.RedbackAuthorization;
32 import org.apache.archiva.rest.api.model.v2.BeanInformation;
33 import org.apache.archiva.rest.api.model.v2.CacheConfiguration;
34 import org.apache.archiva.rest.api.model.v2.LdapConfiguration;
35 import org.apache.archiva.rest.api.model.v2.SecurityConfiguration;
36 import org.apache.archiva.security.common.ArchivaRoleConstants;
38 import javax.ws.rs.Consumes;
39 import javax.ws.rs.DefaultValue;
40 import javax.ws.rs.GET;
41 import javax.ws.rs.PUT;
42 import javax.ws.rs.Path;
43 import javax.ws.rs.PathParam;
44 import javax.ws.rs.Produces;
45 import javax.ws.rs.QueryParam;
46 import javax.ws.rs.core.MediaType;
47 import javax.ws.rs.core.Response;
48 import java.util.List;
50 import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
51 import static org.apache.archiva.rest.api.services.v2.Configuration.DEFAULT_PAGE_LIMIT;
55 * Service for configuration of redback and security related settings.
57 * @author Martin Stockhammer <martin_s@apache.org>
62 @Tag(name = "v2/Security")
63 @SecurityRequirement(name = "BearerAuth")
64 public interface SecurityConfigurationService
68 @Produces({ APPLICATION_JSON })
69 @RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION)
70 @Operation( summary = "Returns the security configuration that is currently active.",
73 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
77 @ApiResponse( responseCode = "200",
78 description = "If the configuration could be retrieved"
80 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to gather the information",
81 content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = ArchivaRestServiceException.class )) )
84 SecurityConfiguration getConfiguration()
85 throws ArchivaRestServiceException;
89 @Consumes({ APPLICATION_JSON })
90 @RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION)
91 @Operation( summary = "Updates the security configuration.",
94 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
98 @ApiResponse( responseCode = "200",
99 description = "If the configuration was updated"
101 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to update the configuration",
102 content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = ArchivaRestServiceException.class )) )
105 Response updateConfiguration( SecurityConfiguration newConfiguration)
106 throws ArchivaRestServiceException;
109 @Path( "config/properties" )
111 @Produces( { APPLICATION_JSON } )
112 @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
113 @Operation( summary = "Returns all configuration properties. The result is paged.",
115 @Parameter(name = "q", description = "Search term"),
116 @Parameter(name = "offset", description = "The offset of the first element returned"),
117 @Parameter(name = "limit", description = "Maximum number of items to return in the response"),
118 @Parameter(name = "orderBy", description = "List of attribute used for sorting (key, value)"),
119 @Parameter(name = "order", description = "The sort order. Either ascending (asc) or descending (desc)")
122 @SecurityRequirement(
123 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
127 @ApiResponse( responseCode = "200",
128 description = "If the list could be returned",
129 content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = PagedResult.class))
131 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to gather the information",
132 content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = ArchivaRestServiceException.class )) )
135 PagedResult<PropertyEntry> getConfigurationProperties( @QueryParam("q") @DefaultValue( "" ) String searchTerm,
136 @QueryParam( "offset" ) @DefaultValue( "0" ) Integer offset,
137 @QueryParam( "limit" ) @DefaultValue( value = DEFAULT_PAGE_LIMIT ) Integer limit,
138 @QueryParam( "orderBy") @DefaultValue( "key" ) List<String> orderBy,
139 @QueryParam("order") @DefaultValue( "asc" ) String order ) throws ArchivaRestServiceException;
141 @Path("config/properties/{propertyName}")
143 @Produces({ APPLICATION_JSON })
144 @RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION)
145 @Operation( summary = "Returns a single configuration property value.",
147 @SecurityRequirement(
148 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
152 @Parameter(in = ParameterIn.PATH, name="propertyName", description = "The name of the property to update")
155 @ApiResponse( responseCode = "200",
156 description = "If the configuration could be retrieved"
158 @ApiResponse( responseCode = "404", description = "The given property name does not exist",
159 content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = ArchivaRestServiceException.class )) ),
160 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to gather the information",
161 content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = ArchivaRestServiceException.class )) )
164 PropertyEntry getConfigurationProperty( @PathParam ( "propertyName" ) String propertyName)
165 throws ArchivaRestServiceException;
168 @Path("config/properties/{propertyName}")
170 @Consumes({ APPLICATION_JSON})
171 @RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION)
172 @Operation( summary = "Updates a single property value of the security configuration.",
174 @SecurityRequirement(
175 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
179 @Parameter(in = ParameterIn.PATH, name="propertyName", description = "The name of the property to update")
182 @ApiResponse( responseCode = "200",
183 description = "If the property value was updated."
185 @ApiResponse( responseCode = "404", description = "The given property name does not exist",
186 content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = ArchivaRestServiceException.class )) ),
187 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to gather the information",
188 content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = ArchivaRestServiceException.class )) )
191 Response updateConfigurationProperty( @PathParam ( "propertyName" ) String propertyName, PropertyEntry propertyValue)
192 throws ArchivaRestServiceException;
197 @Produces({ APPLICATION_JSON })
198 @RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION)
199 @Operation( summary = "Returns the LDAP configuration that is currently active.",
201 @SecurityRequirement(
202 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
206 @ApiResponse( responseCode = "200",
207 description = "If the configuration could be retrieved"
209 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to gather the information",
210 content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = ArchivaRestServiceException.class )) )
213 LdapConfiguration getLdapConfiguration( ) throws ArchivaRestServiceException;
217 @Consumes({ APPLICATION_JSON })
218 @RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION)
219 @Operation( summary = "Updates the LDAP configuration that is currently active.",
221 @SecurityRequirement(
222 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
226 @ApiResponse( responseCode = "200",
227 description = "If the configuration was updated"
229 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to update the information",
230 content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = ArchivaRestServiceException.class )) )
233 Response updateLdapConfiguration( LdapConfiguration configuration ) throws ArchivaRestServiceException;
235 @Path("config/cache")
237 @Produces({ APPLICATION_JSON })
238 @RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION)
239 @Operation( summary = "Returns the cache configuration that is currently active.",
241 @SecurityRequirement(
242 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
246 @ApiResponse( responseCode = "200",
247 description = "If the configuration could be retrieved"
249 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to gather the information",
250 content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = ArchivaRestServiceException.class )) )
253 CacheConfiguration getCacheConfiguration( ) throws ArchivaRestServiceException;
255 @Path("config/cache")
257 @Consumes({ APPLICATION_JSON })
258 @RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION)
259 @Operation( summary = "Updates the LDAP configuration that is currently active.",
261 @SecurityRequirement(
262 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
266 @ApiResponse( responseCode = "200",
267 description = "If the configuration was updated"
269 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to update the information",
270 content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = ArchivaRestServiceException.class )) )
273 Response updateCacheConfiguration( CacheConfiguration cacheConfiguration ) throws ArchivaRestServiceException;
276 @Path("user_managers")
278 @Produces({ APPLICATION_JSON })
279 @RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION)
280 @Operation( summary = "Returns the available user manager implementations.",
282 @SecurityRequirement(
283 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
287 @ApiResponse( responseCode = "200",
288 description = "If the list could be retrieved"
290 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to gather the information",
291 content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = ArchivaRestServiceException.class )) )
294 List<BeanInformation> getAvailableUserManagers()
295 throws ArchivaRestServiceException;
297 @Path("rbac_managers")
299 @Produces({ APPLICATION_JSON })
300 @RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION)
301 @Operation( summary = "Returns the available RBAC manager implementations.",
303 @SecurityRequirement(
304 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
308 @ApiResponse( responseCode = "200",
309 description = "If the list could be retrieved"
311 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to gather the information",
312 content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = ArchivaRestServiceException.class )) )
315 List<BeanInformation> getAvailableRbacManagers()
316 throws ArchivaRestServiceException;