You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SecurityConfigurationService.java 9.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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. import io.swagger.v3.oas.annotations.Operation;
  19. import io.swagger.v3.oas.annotations.Parameter;
  20. import io.swagger.v3.oas.annotations.media.Content;
  21. import io.swagger.v3.oas.annotations.media.Schema;
  22. import io.swagger.v3.oas.annotations.responses.ApiResponse;
  23. import io.swagger.v3.oas.annotations.security.SecurityRequirement;
  24. import io.swagger.v3.oas.annotations.tags.Tag;
  25. import org.apache.archiva.components.rest.model.PagedResult;
  26. import org.apache.archiva.components.rest.model.PropertyEntry;
  27. import org.apache.archiva.redback.authorization.RedbackAuthorization;
  28. import org.apache.archiva.rest.api.model.v2.BeanInformation;
  29. import org.apache.archiva.rest.api.model.v2.CacheConfiguration;
  30. import org.apache.archiva.rest.api.model.v2.LdapConfiguration;
  31. import org.apache.archiva.rest.api.model.v2.SecurityConfiguration;
  32. import org.apache.archiva.security.common.ArchivaRoleConstants;
  33. import javax.ws.rs.DefaultValue;
  34. import javax.ws.rs.GET;
  35. import javax.ws.rs.Path;
  36. import javax.ws.rs.Produces;
  37. import javax.ws.rs.QueryParam;
  38. import javax.ws.rs.core.MediaType;
  39. import java.util.List;
  40. import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
  41. import static org.apache.archiva.rest.api.services.v2.Configuration.DEFAULT_PAGE_LIMIT;
  42. /**
  43. *
  44. * Service for configuration of redback and security related settings.
  45. *
  46. * @author Martin Stockhammer <martin_s@apache.org>
  47. * @since 3.0
  48. */
  49. @Path( "/security" )
  50. @Tag(name = "v2")
  51. @Tag(name = "v2/Security")
  52. @SecurityRequirement(name = "BearerAuth")
  53. public interface SecurityConfigurationService
  54. {
  55. @Path("config")
  56. @GET
  57. @Produces({ MediaType.APPLICATION_JSON })
  58. @RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION)
  59. @Operation( summary = "Returns the security configuration that is currently active.",
  60. security = {
  61. @SecurityRequirement(
  62. name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
  63. )
  64. },
  65. responses = {
  66. @ApiResponse( responseCode = "200",
  67. description = "If the configuration could be retrieved"
  68. ),
  69. @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to gather the information",
  70. content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = ArchivaRestServiceException.class )) )
  71. }
  72. )
  73. SecurityConfiguration getConfiguration()
  74. throws ArchivaRestServiceException;
  75. @GET
  76. @Produces( { APPLICATION_JSON } )
  77. @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
  78. @Operation( summary = "Returns all configuration properties. The result is paged.",
  79. parameters = {
  80. @Parameter(name = "q", description = "Search term"),
  81. @Parameter(name = "offset", description = "The offset of the first element returned"),
  82. @Parameter(name = "limit", description = "Maximum number of items to return in the response"),
  83. @Parameter(name = "orderBy", description = "List of attribute used for sorting (user_id, fullName, email, created"),
  84. @Parameter(name = "order", description = "The sort order. Either ascending (asc) or descending (desc)")
  85. },
  86. security = {
  87. @SecurityRequirement(
  88. name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
  89. )
  90. },
  91. responses = {
  92. @ApiResponse( responseCode = "200",
  93. description = "If the list could be returned",
  94. content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = PagedResult.class))
  95. ),
  96. @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to gather the information",
  97. content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = ArchivaRestServiceException.class )) )
  98. }
  99. )
  100. PagedResult<PropertyEntry> getConfigurationProperties( @QueryParam("q") @DefaultValue( "" ) String searchTerm,
  101. @QueryParam( "offset" ) @DefaultValue( "0" ) Integer offset,
  102. @QueryParam( "limit" ) @DefaultValue( value = DEFAULT_PAGE_LIMIT ) Integer limit,
  103. @QueryParam( "orderBy") @DefaultValue( "id" ) List<String> orderBy,
  104. @QueryParam("order") @DefaultValue( "asc" ) String order ) throws ArchivaRestServiceException;
  105. @Path("ldap")
  106. @GET
  107. @Produces({ MediaType.APPLICATION_JSON })
  108. @RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION)
  109. @Operation( summary = "Returns the LDAP configuration that is currently active.",
  110. security = {
  111. @SecurityRequirement(
  112. name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
  113. )
  114. },
  115. responses = {
  116. @ApiResponse( responseCode = "200",
  117. description = "If the configuration could be retrieved"
  118. ),
  119. @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to gather the information",
  120. content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = ArchivaRestServiceException.class )) )
  121. }
  122. )
  123. LdapConfiguration getLdapConfiguration( ) throws ArchivaRestServiceException;
  124. @Path("user/cache")
  125. @GET
  126. @Produces({ MediaType.APPLICATION_JSON })
  127. @RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION)
  128. @Operation( summary = "Returns the cache configuration that is currently active.",
  129. security = {
  130. @SecurityRequirement(
  131. name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
  132. )
  133. },
  134. responses = {
  135. @ApiResponse( responseCode = "200",
  136. description = "If the configuration could be retrieved"
  137. ),
  138. @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to gather the information",
  139. content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = ArchivaRestServiceException.class )) )
  140. }
  141. )
  142. CacheConfiguration getCacheConfiguration( ) throws ArchivaRestServiceException;
  143. @Path("user/managers")
  144. @GET
  145. @Produces({ MediaType.APPLICATION_JSON })
  146. @RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION)
  147. @Operation( summary = "Returns the available user manager implementations.",
  148. security = {
  149. @SecurityRequirement(
  150. name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
  151. )
  152. },
  153. responses = {
  154. @ApiResponse( responseCode = "200",
  155. description = "If the list could be retrieved"
  156. ),
  157. @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to gather the information",
  158. content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = ArchivaRestServiceException.class )) )
  159. }
  160. )
  161. List<BeanInformation> getAvailableUserManagers()
  162. throws ArchivaRestServiceException;
  163. @Path("rbac/managers")
  164. @GET
  165. @Produces({ MediaType.APPLICATION_JSON })
  166. @RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION)
  167. @Operation( summary = "Returns the available RBAC manager implementations.",
  168. security = {
  169. @SecurityRequirement(
  170. name = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
  171. )
  172. },
  173. responses = {
  174. @ApiResponse( responseCode = "200",
  175. description = "If the list could be retrieved"
  176. ),
  177. @ApiResponse( responseCode = "403", description = "Authenticated user is not permitted to gather the information",
  178. content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = ArchivaRestServiceException.class )) )
  179. }
  180. )
  181. List<BeanInformation> getAvailableRbacManagers()
  182. throws ArchivaRestServiceException;
  183. }