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.media.Content;
22 import io.swagger.v3.oas.annotations.media.Schema;
23 import io.swagger.v3.oas.annotations.responses.ApiResponse;
24 import io.swagger.v3.oas.annotations.security.SecurityRequirement;
25 import io.swagger.v3.oas.annotations.tags.Tag;
26 import org.apache.archiva.components.rest.model.PagedResult;
27 import org.apache.archiva.components.rest.model.PropertyEntry;
28 import org.apache.archiva.redback.authorization.RedbackAuthorization;
29 import org.apache.archiva.rest.api.model.v2.BeanInformation;
30 import org.apache.archiva.rest.api.model.v2.CacheConfiguration;
31 import org.apache.archiva.rest.api.model.v2.LdapConfiguration;
32 import org.apache.archiva.rest.api.model.v2.SecurityConfiguration;
33 import org.apache.archiva.security.common.ArchivaRoleConstants;
35 import javax.ws.rs.DefaultValue;
36 import javax.ws.rs.GET;
37 import javax.ws.rs.Path;
38 import javax.ws.rs.Produces;
39 import javax.ws.rs.QueryParam;
40 import javax.ws.rs.core.MediaType;
41 import java.util.List;
43 import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
44 import static org.apache.archiva.rest.api.services.v2.Configuration.DEFAULT_PAGE_LIMIT;
48 * Service for configuration of redback and security related settings.
50 * @author Martin Stockhammer <martin_s@apache.org>
55 @Tag(name = "v2/Security")
56 @SecurityRequirement(name = "BearerAuth")
57 public interface SecurityConfigurationService
61 @Produces({ MediaType.APPLICATION_JSON })
62 @RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION)
63 @Operation( summary = "Returns the security configuration that is currently active.",
66 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
70 @ApiResponse( responseCode = "200",
71 description = "If the configuration could be retrieved"
73 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to gather the information",
74 content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = ArchivaRestServiceException.class )) )
77 SecurityConfiguration getConfiguration()
78 throws ArchivaRestServiceException;
81 @Produces( { APPLICATION_JSON } )
82 @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
83 @Operation( summary = "Returns all configuration properties. The result is paged.",
85 @Parameter(name = "q", description = "Search term"),
86 @Parameter(name = "offset", description = "The offset of the first element returned"),
87 @Parameter(name = "limit", description = "Maximum number of items to return in the response"),
88 @Parameter(name = "orderBy", description = "List of attribute used for sorting (user_id, fullName, email, created"),
89 @Parameter(name = "order", description = "The sort order. Either ascending (asc) or descending (desc)")
93 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
97 @ApiResponse( responseCode = "200",
98 description = "If the list could be returned",
99 content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = PagedResult.class))
101 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to gather the information",
102 content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = ArchivaRestServiceException.class )) )
105 PagedResult<PropertyEntry> getConfigurationProperties( @QueryParam("q") @DefaultValue( "" ) String searchTerm,
106 @QueryParam( "offset" ) @DefaultValue( "0" ) Integer offset,
107 @QueryParam( "limit" ) @DefaultValue( value = DEFAULT_PAGE_LIMIT ) Integer limit,
108 @QueryParam( "orderBy") @DefaultValue( "id" ) List<String> orderBy,
109 @QueryParam("order") @DefaultValue( "asc" ) String order ) throws ArchivaRestServiceException;
113 @Produces({ MediaType.APPLICATION_JSON })
114 @RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION)
115 @Operation( summary = "Returns the LDAP configuration that is currently active.",
117 @SecurityRequirement(
118 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
122 @ApiResponse( responseCode = "200",
123 description = "If the configuration could be retrieved"
125 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to gather the information",
126 content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = ArchivaRestServiceException.class )) )
129 LdapConfiguration getLdapConfiguration( ) throws ArchivaRestServiceException;
134 @Produces({ MediaType.APPLICATION_JSON })
135 @RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION)
136 @Operation( summary = "Returns the cache configuration that is currently active.",
138 @SecurityRequirement(
139 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
143 @ApiResponse( responseCode = "200",
144 description = "If the configuration could be retrieved"
146 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to gather the information",
147 content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = ArchivaRestServiceException.class )) )
150 CacheConfiguration getCacheConfiguration( ) throws ArchivaRestServiceException;
152 @Path("user/managers")
154 @Produces({ MediaType.APPLICATION_JSON })
155 @RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION)
156 @Operation( summary = "Returns the available user manager implementations.",
158 @SecurityRequirement(
159 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
163 @ApiResponse( responseCode = "200",
164 description = "If the list could be retrieved"
166 @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to gather the information",
167 content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = ArchivaRestServiceException.class )) )
170 List<BeanInformation> getAvailableUserManagers()
171 throws ArchivaRestServiceException;
173 @Path("rbac/managers")
175 @Produces({ MediaType.APPLICATION_JSON })
176 @RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION)
177 @Operation( summary = "Returns the available RBAC manager implementations.",
179 @SecurityRequirement(
180 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
184 @ApiResponse( responseCode = "200",
185 description = "If the list could be retrieved"
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 List<BeanInformation> getAvailableRbacManagers()
192 throws ArchivaRestServiceException;