]> source.dussan.org Git - archiva.git/blob
59c57c53ec88f7bd6d365a19cd7b36343ee58713
[archiva.git] /
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
9  *
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
16  * under the License.
17  */
18
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;
34
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;
42
43 import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
44 import static org.apache.archiva.rest.api.services.v2.Configuration.DEFAULT_PAGE_LIMIT;
45
46 /**
47  *
48  * Service for configuration of redback and security related settings.
49  *
50  * @author Martin Stockhammer <martin_s@apache.org>
51  * @since 3.0
52  */
53 @Path( "/security" )
54 @Tag(name = "v2")
55 @Tag(name = "v2/Security")
56 @SecurityRequirement(name = "BearerAuth")
57 public interface SecurityConfigurationService
58 {
59     @Path("config")
60     @GET
61     @Produces({ MediaType.APPLICATION_JSON })
62     @RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION)
63     @Operation( summary = "Returns the security configuration that is currently active.",
64         security = {
65             @SecurityRequirement(
66                 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
67             )
68         },
69         responses = {
70             @ApiResponse( responseCode = "200",
71                 description = "If the configuration could be retrieved"
72             ),
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 )) )
75         }
76     )
77     SecurityConfiguration getConfiguration()
78         throws ArchivaRestServiceException;
79
80     @GET
81     @Produces( { APPLICATION_JSON } )
82     @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
83     @Operation( summary = "Returns all configuration properties. The result is paged.",
84         parameters = {
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)")
90         },
91         security = {
92             @SecurityRequirement(
93                 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
94             )
95         },
96         responses = {
97             @ApiResponse( responseCode = "200",
98                 description = "If the list could be returned",
99                 content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = PagedResult.class))
100             ),
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 )) )
103         }
104     )
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;
110
111     @Path("ldap")
112     @GET
113     @Produces({ MediaType.APPLICATION_JSON })
114     @RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION)
115     @Operation( summary = "Returns the LDAP configuration that is currently active.",
116         security = {
117             @SecurityRequirement(
118                 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
119             )
120         },
121         responses = {
122             @ApiResponse( responseCode = "200",
123                 description = "If the configuration could be retrieved"
124             ),
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 )) )
127         }
128     )
129     LdapConfiguration getLdapConfiguration( ) throws ArchivaRestServiceException;
130
131
132     @Path("user/cache")
133     @GET
134     @Produces({ MediaType.APPLICATION_JSON })
135     @RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION)
136     @Operation( summary = "Returns the cache configuration that is currently active.",
137         security = {
138             @SecurityRequirement(
139                 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
140             )
141         },
142         responses = {
143             @ApiResponse( responseCode = "200",
144                 description = "If the configuration could be retrieved"
145             ),
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 )) )
148         }
149     )
150     CacheConfiguration getCacheConfiguration( ) throws ArchivaRestServiceException;
151
152     @Path("user/managers")
153     @GET
154     @Produces({ MediaType.APPLICATION_JSON })
155     @RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION)
156     @Operation( summary = "Returns the available user manager implementations.",
157         security = {
158             @SecurityRequirement(
159                 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
160             )
161         },
162         responses = {
163             @ApiResponse( responseCode = "200",
164                 description = "If the list could be retrieved"
165             ),
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 )) )
168         }
169     )
170     List<BeanInformation> getAvailableUserManagers()
171         throws ArchivaRestServiceException;
172
173     @Path("rbac/managers")
174     @GET
175     @Produces({ MediaType.APPLICATION_JSON })
176     @RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION)
177     @Operation( summary = "Returns the available RBAC manager implementations.",
178         security = {
179             @SecurityRequirement(
180                 name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
181             )
182         },
183         responses = {
184             @ApiResponse( responseCode = "200",
185                 description = "If the list could be retrieved"
186             ),
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 )) )
189         }
190     )
191     List<BeanInformation> getAvailableRbacManagers()
192         throws ArchivaRestServiceException;
193
194 }