diff --git a/.github/workflows/java-source.yml b/.github/workflows/java-source.yml index 30c37c840..73533f177 100644 --- a/.github/workflows/java-source.yml +++ b/.github/workflows/java-source.yml @@ -4,8 +4,8 @@ on: push: branches-ignore: ['main', 'integration'] paths: - - 'java/src/**' - - 'java/pom.xml' + - 'java/*/src/**' + - 'java/*/pom.xml' jobs: buildtest: runs-on: ubuntu-20.04 @@ -20,7 +20,7 @@ jobs: uses: actions/cache@v2 with: path: ~/.m2 - key: ${{ runner.os }}-m2-${{ hashFiles('java/pom.xml') }} + key: ${{ runner.os }}-m2-${{ hashFiles('java/customization-api/pom.xml') }} restore-keys: ${{ runner.os }}-m2 - name: Set up JDK @@ -30,7 +30,7 @@ jobs: distribution: 'adopt' - name: Test with Maven - run: cd java && mvn --batch-mode test + run: cd java/customization-api && mvn --batch-mode test diff --git a/.github/workflows/testall.yml b/.github/workflows/testall.yml index 5891a55a6..2e34ec0ca 100644 --- a/.github/workflows/testall.yml +++ b/.github/workflows/testall.yml @@ -29,8 +29,8 @@ jobs: - name: Build & Run Python Tests via Docker run: cd docker && ./testall python - - name: Build & Run Java Tests via Docker - run: cd docker && ./makedist java + - name: Test Java via Docker + run: cd docker && ./testall java - name: Build Angular Code run: cd docker && ./makedist angular diff --git a/java/customization-api/--spring.output.ansi.enabled=always/.mvn/wrapper/.gitignore b/java/customization-api/--spring.output.ansi.enabled=always/.mvn/wrapper/.gitignore deleted file mode 100644 index d392f0e82..000000000 --- a/java/customization-api/--spring.output.ansi.enabled=always/.mvn/wrapper/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.jar diff --git a/java/customization-api/pom.xml b/java/customization-api/pom.xml index c7287e3d5..d9abc19b5 100644 --- a/java/customization-api/pom.xml +++ b/java/customization-api/pom.xml @@ -1,35 +1,49 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.springframework.boot spring-boot-starter-parent - 2.1.3.RELEASE + 2.5.4 - gov.nist.oar.custom + gov.nist.oar.customizationapi customization-api 0.0.1-SNAPSHOT customization-api Spring boot application to save customization changes from PDR - + jar 1.8 - Greenwich.RELEASE - 2.9.2 + 2020.0.4 + 3.0.3.RELEASE + 4.3.1 + 1.1.3 + 4.1.0 + 3.2.0.RELEASE + 4.0.5 - org.springframework.boot spring-boot-starter-actuator - org.springframework.boot - spring-boot-starter-data-mongodb + org.springframework.data + spring-data-mongodb + + + org.mongodb + mongodb-driver-sync + + + org.mongodb + mongodb-driver-reactivestreams + + org.springframework.boot spring-boot-starter-web @@ -55,7 +69,7 @@ org.springframework.security.extensions spring-security-saml2-core - 1.0.3.RELEASE + 1.0.10.RELEASE org.springframework.boot @@ -74,44 +88,35 @@ org.bouncycastle bcprov-jdk15on - 1.62 + 1.69 org.bouncycastle bcpkix-jdk15on - 1.62 + 1.69 + com.nimbusds nimbus-jose-jwt - 7.9 + + javax.inject javax.inject 1 - - io.springfox - springfox-swagger-ui - ${springfox.version} - - - - io.springfox - springfox-swagger2 - ${springfox.version} - org.powermock powermock-module-junit4 - 2.0.4 + 2.0.9 test org.powermock powermock-api-mockito2 - 2.0.4 + 2.0.9 test @@ -133,17 +138,35 @@ org.apache.httpcomponents httpclient - org.springframework spring-test - test - - + + org.springdoc + springdoc-openapi-ui + 1.5.7 + + + + org.opensaml + opensaml + 2.6.1 + + + org.springframework.cloud + spring-cloud-starter-bootstrap + + + + org.junit.vintage + junit-vintage-engine + test + + @@ -155,7 +178,6 @@ - customization-api @@ -174,7 +196,6 @@ - spring-milestones @@ -189,6 +210,11 @@ spring-releases https://repo.spring.io/libs-release + + Shibbolet + Shibbolet + https://build.shibboleth.net/nexus/content/repositories/releases/ + @@ -196,5 +222,4 @@ https://repo.spring.io/libs-release - diff --git a/java/customization-api/src/main/java/gov/nist/oar/customizationapi/CustomizationApiApplication.java b/java/customization-api/src/main/java/gov/nist/oar/customizationapi/CustomizationApiApplication.java index 7fddc4747..c5a19106e 100644 --- a/java/customization-api/src/main/java/gov/nist/oar/customizationapi/CustomizationApiApplication.java +++ b/java/customization-api/src/main/java/gov/nist/oar/customizationapi/CustomizationApiApplication.java @@ -1,5 +1,11 @@ package gov.nist.oar.customizationapi; +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.List; + import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration; @@ -7,7 +13,15 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration; import org.springframework.cloud.context.config.annotation.RefreshScope; +import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; + +import io.swagger.v3.oas.models.Components; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.info.License; +import io.swagger.v3.oas.models.security.SecurityScheme; +import io.swagger.v3.oas.models.servers.Server; /*** * The class is an entry point for an application to start running on server. * @author Deoyani Nandrekar-Heinis @@ -23,4 +37,55 @@ public static void main(String[] args) { SpringApplication.run(CustomizationApiApplication.class, args); } + @Bean + public OpenAPI customOpenAPI(@Value("1.1.0") String appVersion) { + appVersion = VERSION; + List servers = new ArrayList<>(); + servers.add(new Server().url("/customization")); + String description = "These are set of APIs which are used by data publishing workflow to edit new dataset metadata records."; + + + return new OpenAPI() + .components(new Components().addSecuritySchemes("basicScheme", + new SecurityScheme().type(SecurityScheme.Type.HTTP).scheme("basic"))) + .components(new Components()).servers(servers) + .info(new Info().title("Metadata Cutomization API") + .description(description) + .version(appVersion) + + .license(new License().name("NIST Software").url("https://www.nist.gov/open/copyright-fair-use-and-licensing-statements-srd-data-software-and-technical-series-publications"))); + } + + /** + * The service name + */ + public final static String NAME; + + /** + * The version of the service + */ + public final static String VERSION; + + static { + String name = null; + String version = null; + try (InputStream verf = CustomizationApiApplication.class.getClassLoader().getResourceAsStream("VERSION")) { + if (verf == null) { + name = "oar-customization"; + version = "not set"; + } + else { + BufferedReader vrdr = new BufferedReader(new InputStreamReader(verf)); + String line = vrdr.readLine(); + String[] parts = line.split("\\s+"); + name = parts[0]; + version = (parts.length > 1) ? parts[1] : "missing"; + } + } catch (Exception ex) { + name = "oar-customization"; + version = "unknown"; + } + NAME = name; + VERSION = version; + } } \ No newline at end of file diff --git a/java/customization-api/src/main/java/gov/nist/oar/customizationapi/config/MongoConfig.java b/java/customization-api/src/main/java/gov/nist/oar/customizationapi/config/MongoConfig.java index dcbd4cb68..ce2319060 100644 --- a/java/customization-api/src/main/java/gov/nist/oar/customizationapi/config/MongoConfig.java +++ b/java/customization-api/src/main/java/gov/nist/oar/customizationapi/config/MongoConfig.java @@ -13,6 +13,7 @@ package gov.nist.oar.customizationapi.config; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import javax.annotation.PostConstruct; @@ -25,14 +26,18 @@ import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Configuration; -import com.mongodb.Mongo; -import com.mongodb.MongoClient; -import com.mongodb.MongoClientOptions; +//import com.mongodb.Mongo; +//import com.mongodb.MongoClient; +//import com.mongodb.MongoClientOptions; import com.mongodb.MongoCredential; import com.mongodb.ServerAddress; import com.mongodb.client.MongoCollection; import com.mongodb.client.MongoDatabase; +import com.mongodb.ConnectionString; +import com.mongodb.MongoClientSettings; +import com.mongodb.client.MongoClient; +import com.mongodb.client.MongoClients; @Configuration @ConfigurationProperties @EnableAutoConfiguration @@ -76,7 +81,7 @@ public class MongoConfig { @PostConstruct public void initIt() throws Exception { - mongoClient = (MongoClient) this.mongo(); + mongoClient = this.mongo(); log.info("#### Initialize MongoDB with dbname:"+this.dbname+"####"); this.setMongodb(this.dbname); this.setRecordCollection(this.record); @@ -164,9 +169,28 @@ public String getMDSecret() { * @return * @throws Exception */ - public Mongo mongo() throws Exception { - servers.add(new ServerAddress(host, port)); - return new MongoClient(servers, MongoCredential.createCredential(user, dbname, password.toCharArray()), - MongoClientOptions.builder().build()); + public MongoClient mongo() throws Exception { +// servers.add(new ServerAddress(host, port)); + +// MongoCredential credential = MongoCredential.createCredential(user, dbname, password.toCharArray()); +// ServerAddress serverAddress = new ServerAddress(host, port); +// +// // Mongo Client +// MongoClient mongoClient = new MongoClient(serverAddress,Arrays.asList(credential)); +// +// return new MongoClient(servers, MongoCredential.createCredential(user, dbname, password.toCharArray()), +// MongoClientOptions.builder().build()); +// + MongoCredential credential = MongoCredential.createCredential(user, dbname, password.toCharArray()); + + MongoClientSettings settings = MongoClientSettings.builder() + .credential(credential) + .applyToSslSettings(builder -> builder.enabled(false)) + .applyToClusterSettings(builder -> + builder.hosts(Arrays.asList(new ServerAddress(host, port)))) + .build(); + + MongoClient mongoClient = MongoClients.create(settings); + return mongoClient; } } diff --git a/java/customization-api/src/main/java/gov/nist/oar/customizationapi/config/SAMLConfig/SamlSecurityConfig.java b/java/customization-api/src/main/java/gov/nist/oar/customizationapi/config/SAMLConfig/SamlSecurityConfig.java index b740215ec..a20606d17 100644 --- a/java/customization-api/src/main/java/gov/nist/oar/customizationapi/config/SAMLConfig/SamlSecurityConfig.java +++ b/java/customization-api/src/main/java/gov/nist/oar/customizationapi/config/SAMLConfig/SamlSecurityConfig.java @@ -23,6 +23,8 @@ import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager; import org.apache.commons.httpclient.protocol.Protocol; import org.apache.commons.httpclient.protocol.ProtocolSocketFactory; +//import org.apache.http.client.HttpClient; + import org.apache.velocity.app.VelocityEngine; import org.opensaml.saml2.metadata.provider.MetadataProvider; import org.opensaml.saml2.metadata.provider.MetadataProviderException; @@ -44,6 +46,11 @@ import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.builders.WebSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; +import org.springframework.security.saml.SAMLDiscovery; +import org.springframework.security.saml.SAMLEntryPoint; +import org.springframework.security.saml.SAMLProcessingFilter; +import org.springframework.security.saml.metadata.MetadataDisplayFilter; +import org.springframework.security.saml.websso.WebSSOProfileOptions; import org.springframework.security.saml.SAMLAuthenticationProvider; import org.springframework.security.saml.SAMLBootstrap; import org.springframework.security.saml.SAMLEntryPoint; @@ -196,16 +203,11 @@ CustomFilter customFilter() { * @throws ConfigurationException */ @Bean - public WebSSOProfileOptions defaultWebSSOProfileOptions() throws ConfigurationException { - logger.info("Setting up authticated service redirect by setting web sso profiles."); - WebSSOProfileOptions webSSOProfileOptions = new WebSSOProfileOptions(); - webSSOProfileOptions.setIncludeScoping(false); - /// Adding this force authenticate on failure to validate SAML cache - webSSOProfileOptions.setForceAuthN(true); - // Relay state can also be set here it will always go to this URL once - // authenticated - // webSSOProfileOptions.setRelayState("https://data.nist.gov/sdp"); - return webSSOProfileOptions; + public WebSSOProfileOptions defaultWebSSOProfileOptions() { + WebSSOProfileOptions webSSOProfileOptions = new WebSSOProfileOptions(); + webSSOProfileOptions.setIncludeScoping(false); + webSSOProfileOptions.setForceAuthN(true); + return webSSOProfileOptions; } /** @@ -215,14 +217,17 @@ public WebSSOProfileOptions defaultWebSSOProfileOptions() throws ConfigurationEx * @return * @throws ConfigurationException */ + @Bean - public SAMLEntryPoint samlEntryPoint() throws ConfigurationException { + public SAMLEntryPoint samlEntryPoint() { logger.info("SAML Entry point. with application url " + applicationURL); SAMLEntryPoint samlEntryPoint = new SamlWithRelayStateEntryPoint(applicationURL); samlEntryPoint.setDefaultProfileOptions(defaultWebSSOProfileOptions()); return samlEntryPoint; } + + /** * Metadatadisplay filter is called to use IDP metadata and set up SP service * @@ -278,6 +283,22 @@ public SAMLProcessingFilter samlWebSSOProcessingFilter() throws ConfigurationExc return samlWebSSOProcessingFilter; } + + +// @Bean +// public SAMLProcessingFilter samlWebSSOProcessingFilter() throws Exception { +// SAMLProcessingFilter samlWebSSOProcessingFilter = new SAMLProcessingFilter(); +// samlWebSSOProcessingFilter.setAuthenticationManager(authenticationManager()); +// samlWebSSOProcessingFilter.setAuthenticationSuccessHandler(successRedirectHandler()); +// samlWebSSOProcessingFilter.setAuthenticationFailureHandler(authenticationFailureHandler()); +// return samlWebSSOProcessingFilter; +// } + + @Bean + public SAMLDiscovery samlDiscovery() { + SAMLDiscovery idpDiscovery = new SAMLDiscovery(); + return idpDiscovery; + } /** * successLogoutHandler @@ -398,8 +419,6 @@ public FilterChainProxy samlFilter() throws ConfigurationException { logger.info("Setting up different saml filters and endpoints"); List chains = new ArrayList<>(); - chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/metadata/**"), - metadataDisplayFilter())); chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/login/**"),customFilter(), samlEntryPoint())); @@ -411,8 +430,29 @@ public FilterChainProxy samlFilter() throws ConfigurationException { chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/singleLogout/**"), samlLogoutProcessingFilter())); + chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/metadata/**"), + metadataDisplayFilter())); + return new FilterChainProxy(chains); } + +// @Bean +// public FilterChainProxy samlFilter() throws Exception { +// List chains = new ArrayList<>(); +// chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/SSO/**"), +// samlWebSSOProcessingFilter())); +// chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/discovery/**"), +// samlDiscovery())); +// chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/metadata/**"), +// metadataDisplayFilter())); +// chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/login/**"), +// customFilter(), samlEntryPoint())); +// chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/logout/**"), +// samlLogoutFilter())); +// chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/SingleLogout/**"), +// samlLogoutProcessingFilter())); +// return new FilterChainProxy(chains); +// } /** * Making sure TLS security @@ -755,13 +795,14 @@ protected void configure(HttpSecurity http) throws ConfigurationException { try { - http.addFilterBefore(corsFilter(), SessionManagementFilter.class).exceptionHandling() - .authenticationEntryPoint(samlEntryPoint()); + http.csrf().disable(); http.addFilterBefore(metadataGeneratorFilter(), ChannelProcessingFilter.class).addFilterAfter(samlFilter(), BasicAuthenticationFilter.class); + http.addFilterBefore(corsFilter(), SessionManagementFilter.class).exceptionHandling() + .authenticationEntryPoint(samlEntryPoint()); http.authorizeRequests() .antMatchers("/error").permitAll() diff --git a/java/customization-api/src/main/java/gov/nist/oar/customizationapi/config/SwaggerConfig.java b/java/customization-api/src/main/java/gov/nist/oar/customizationapi/config/SwaggerConfig.java deleted file mode 100644 index 1654f35a7..000000000 --- a/java/customization-api/src/main/java/gov/nist/oar/customizationapi/config/SwaggerConfig.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * This software was developed at the National Institute of Standards and Technology by employees of - * the Federal Government in the course of their official duties. Pursuant to title 17 Section 105 - * of the United States Code this software is not subject to copyright protection and is in the - * public domain. This is an experimental system. NIST assumes no responsibility whatsoever for its - * use by other parties, and makes no guarantees, expressed or implied, about its quality, - * reliability, or any other characteristic. We would appreciate acknowledgement if the software is - * used. This software can be redistributed and/or modified freely provided that any derivative - * works bear some notice that they are derived from it, and any modified versions bear some notice - * that they have been modified. - * @author: Deoyani Nandrekar-Heinis - */ -package gov.nist.oar.customizationapi.config; - -import java.util.ArrayList; -import java.util.List; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; - -import springfox.documentation.builders.PathSelectors; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.builders.ResponseMessageBuilder; -import springfox.documentation.schema.ModelRef; -import springfox.documentation.service.ApiInfo; -import springfox.documentation.service.ResponseMessage; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger.web.DocExpansion; -import springfox.documentation.swagger.web.UiConfiguration; -import springfox.documentation.swagger.web.UiConfigurationBuilder; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -@Configuration -@EnableSwagger2 -@ComponentScan({ "gov.nist.oar.customization" }) -/** - * Swagger configuration class takes care of Initializing swagger to be used to - * generate documentation for the code. - * - * @author Deoyani Nandrekar-Heinis - * - */ -public class SwaggerConfig { - - private static Logger log = LoggerFactory.getLogger(SwaggerConfig.class); - private static List responseMessageList = new ArrayList<>(); - - static { - responseMessageList.add(new ResponseMessageBuilder().code(500).message("500 - Internal Server Error") - .responseModel(new ModelRef("Error")).build()); - responseMessageList.add(new ResponseMessageBuilder().code(403).message("403 - Forbidden").build()); - } - - @Bean - /** - * Swagger api setting - * - * @return Docket - */ - public Docket api() { - - return new Docket(DocumentationType.SWAGGER_2).select() - .apis(RequestHandlerSelectors.basePackage("gov.nist.oar.custom")).paths(PathSelectors.any()).build() - .apiInfo(apiInfo()); - } - - /** - * Swagger user interface configuration - * - * @return - */ - @Bean - UiConfiguration uiConfig() { - return UiConfigurationBuilder.builder().docExpansion(DocExpansion.LIST).build(); - } - - /** - * Swagger Api Info - * - * @return return ApiInfo - * - */ - private ApiInfo apiInfo() { - - log.info("### Swagger Initialization ####"); - @SuppressWarnings("deprecation") - ApiInfo apiInfo = new ApiInfo("Landing page Customization api", - "This api is developed for authoriozed users to edit records using customization UI", "Build-1.0.0", - "This is a REST based web service to edit, create and delete data.", "", "NIST Public license", - "https://www.nist.gov/director/licensing"); - return apiInfo; - } - -} diff --git a/java/customization-api/src/main/java/gov/nist/oar/customizationapi/web/AuthController.java b/java/customization-api/src/main/java/gov/nist/oar/customizationapi/web/AuthController.java index c0ae7db8c..b122533e7 100644 --- a/java/customization-api/src/main/java/gov/nist/oar/customizationapi/web/AuthController.java +++ b/java/customization-api/src/main/java/gov/nist/oar/customizationapi/web/AuthController.java @@ -43,7 +43,10 @@ import gov.nist.oar.customizationapi.service.JWTTokenGenerator; import gov.nist.oar.customizationapi.service.ResourceNotFoundException; import gov.nist.oar.customizationapi.service.UserToken; -import io.swagger.annotations.ApiOperation; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; + /** * This controller sends JWT, a token generated after successful authentication. @@ -76,8 +79,10 @@ public class AuthController { * @throws UnAuthenticatedUserException */ @RequestMapping(value = { "_perm/{ediid}" }, method = RequestMethod.GET, produces = "application/json") - @ApiOperation(value = "", nickname = "Authorize user to edit the record", notes = "Resource returns a JSON if Authorized user.") - + @Parameters ({ + @Parameter(name = "Authentication", description = "authentication object."), + @Parameter(name = "ediid", description = "The recordid for which user authorization is checked.")}) + @Operation(summary = "Get the authorized token.", description = "Resource returns a JSON if Authorized user.") public UserToken token( Authentication authentication,@PathVariable @Valid String ediid) throws UnAuthorizedUserException, CustomizationException, UnAuthenticatedUserException, BadGetwayException { @@ -109,6 +114,11 @@ public UserToken token( Authentication authentication,@PathVariable @Valid Strin */ @RequestMapping(value = { "/_logininfo" }, method = RequestMethod.GET, produces = "application/json") + @Parameters ({ + @Parameter(name = "authentication", description = "authentication object."), + @Parameter(name = "response", description = "HttpServletResponse .")}) + @Operation(summary = "Get the authorized token.", description = "Resource returns a JSON if Authorized user.") + public ResponseEntity login(HttpServletResponse response, Authentication authentication) throws IOException { logger.info("Get the authenticated user info."); // final Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); diff --git a/java/customization-api/src/main/java/gov/nist/oar/customizationapi/web/DraftController.java b/java/customization-api/src/main/java/gov/nist/oar/customizationapi/web/DraftController.java index 07f5d60dc..e643ce683 100644 --- a/java/customization-api/src/main/java/gov/nist/oar/customizationapi/web/DraftController.java +++ b/java/customization-api/src/main/java/gov/nist/oar/customizationapi/web/DraftController.java @@ -45,8 +45,10 @@ import gov.nist.oar.customizationapi.repositories.DraftService; //import gov.nist.oar.customizationapi.repositories.UpdateRepository; import gov.nist.oar.customizationapi.service.ResourceNotFoundException; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.tags.Tag; /** * This is a webservice/restapi controller which gives access to customization @@ -62,7 +64,7 @@ * */ @RestController -@Api(value = "Api endpoints to access editable data, update changes to data, save in the backend", tags = "Customization API") +@Tag(description = "Api endpoints to access editable data, update changes to data, save in the backend", name = "Customization API") //@Validated @RequestMapping("/pdr/lp/draft/") public class DraftController { @@ -85,7 +87,7 @@ public class DraftController { * @throws ResourceNotFoundException */ @RequestMapping(value = { "{ediid}" }, method = RequestMethod.GET, produces = "application/json") - @ApiOperation(value = ".", nickname = "Access editable Record", notes = "Resource returns a record if it is editable and user is authenticated.") + @Operation(summary = "Access editable Record", description = "Resource returns a record if it is editable and user is authenticated.") public Document getData(@PathVariable @Valid String ediid, @RequestParam(required = false) String view, @RequestHeader(value = "Authorization", required = false) String serviceAuth, HttpServletRequest request) throws CustomizationException, UnsatisfiedServletRequestParameterException, ResourceNotFoundException, InvalidInputException { @@ -106,7 +108,7 @@ public Document getData(@PathVariable @Valid String ediid, @RequestParam(require * @throws CustomizationException */ @RequestMapping(value = { "{ediid}" }, method = RequestMethod.DELETE, produces = "application/json") - @ApiOperation(value = ".", nickname = "Delete the Record from drafts", notes = "This will allow user to delete all the changes made in the record in draft mode, original published record will remain as it is.") + @Operation(summary = "Delete the Record from drafts", description = "This will allow user to delete all the changes made in the record in draft mode, original published record will remain as it is.") public boolean deleteRecord(@PathVariable @Valid String ediid, @RequestHeader(value = "Authorization", required = false) String serviceAuth, HttpServletRequest request) throws CustomizationException { @@ -129,7 +131,7 @@ public boolean deleteRecord(@PathVariable @Valid String ediid, */ @RequestMapping(value = { "{ediid}" }, method = RequestMethod.PUT, headers = "accept=application/json", produces = "application/json") - @ApiOperation(value = ".", nickname = "Save changes to server", notes = "Resource returns a boolean based on success or failure of the request.") + @Operation(summary = "Save changes to server", description = "Resource returns a boolean based on success or failure of the request.") @ResponseStatus(HttpStatus.CREATED) public void createRecord(@PathVariable @Valid String ediid, @Valid @RequestBody Document params, @RequestHeader(value = "Authorization", required = false) String serviceAuth, HttpServletRequest request) diff --git a/java/customization-api/src/main/java/gov/nist/oar/customizationapi/web/EditorController.java b/java/customization-api/src/main/java/gov/nist/oar/customizationapi/web/EditorController.java index dd4970060..bbf88a063 100644 --- a/java/customization-api/src/main/java/gov/nist/oar/customizationapi/web/EditorController.java +++ b/java/customization-api/src/main/java/gov/nist/oar/customizationapi/web/EditorController.java @@ -39,8 +39,8 @@ import gov.nist.oar.customizationapi.repositories.EditorService; //import gov.nist.oar.customizationapi.repositories.UpdateRepository; import gov.nist.oar.customizationapi.service.ResourceNotFoundException; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; /** * This is a webservice/restapi controller which gives options to access, update @@ -58,7 +58,7 @@ * */ @RestController -@Api(value = "Api endpoints to access editable data, update changes to data, save in the backend", tags = "Customization API") +@Tag(description = "Api endpoints to access editable data, update changes to data, save in the backend", name = "Customization API") @Validated @CrossOrigin(origins = "*", allowedHeaders = "*") @RequestMapping("/pdr/lp/editor/") @@ -79,7 +79,7 @@ public class EditorController { */ @RequestMapping(value = { "{ediid}" }, method = RequestMethod.PATCH, headers = "accept=application/json", produces = "application/json") - @ApiOperation(value = ".", nickname = "Cache Record Changes", notes = "Resource returns a record if it is editable and user is authenticated.") + @Operation(summary = "Cache Record Changes", description = "Resource returns a record if it is editable and user is authenticated.") public Document updateRecord(@PathVariable @Valid String ediid, @Valid @RequestBody String params) throws CustomizationException, InvalidInputException { @@ -96,7 +96,7 @@ public Document updateRecord(@PathVariable @Valid String ediid, @Valid @RequestB * @throws CustomizationException */ @RequestMapping(value = { "{ediid}" }, method = RequestMethod.GET, produces = "application/json") - @ApiOperation(value = ".", nickname = "Access editable Record", notes = "Resource returns a record if it is editable and user is authenticated.") + @Operation(summary = "Access editable Record", description = "Resource returns a record if it is editable and user is authenticated.") public Document getRecord(@PathVariable @Valid String ediid) throws CustomizationException, ResourceNotFoundException { logger.info("Access the record to be edited by ediid " + ediid); return uRepo.getRecord(ediid); @@ -110,7 +110,7 @@ public Document getRecord(@PathVariable @Valid String ediid) throws Customizatio * @throws CustomizationException */ @RequestMapping(value = { "{ediid}" }, method = RequestMethod.DELETE, produces = "application/json" ) - @ApiOperation(value = ".", nickname = "Access editable Record", notes = "Resource returns a record if it is editable and user is authenticated.") + @Operation(summary = "Access editable Record", description = "Resource returns a record if it is editable and user is authenticated.") public Document deleteChanges(@PathVariable @Valid String ediid) throws CustomizationException, ResourceNotFoundException { logger.info("Delete the changes made from client side of the record respresented by " + ediid); return uRepo.deleteRecordChanges(ediid); diff --git a/java/customization-api/src/main/resources/bootstrap.yml b/java/customization-api/src/main/resources/bootstrap.yml index a5f8bb0ee..b53322a94 100644 --- a/java/customization-api/src/main/resources/bootstrap.yml +++ b/java/customization-api/src/main/resources/bootstrap.yml @@ -9,11 +9,21 @@ spring: uri: http://localhost:8084 logging: - path : /var/log/customization-api + file: + path: /var/log/customization-api exception-conversion-word: '%wEx' -#samlauth: -# enabled: false +springdoc: + swagger-ui: + tagsSorter: alpha + path: /swagger-ui.html +# configUrl: /v3/api-docs/swagger-config +# enabled: true + disable-swagger-default-url: true +# packagesToScan: gov.nist.oar.rmm +# pathsToMatch: /rmm +samlauth: + enabled: true server: servlet: diff --git a/scripts/testall.java b/scripts/testall.java index 8e0e77be2..92dc1dad9 100755 --- a/scripts/testall.java +++ b/scripts/testall.java @@ -9,5 +9,5 @@ PACKAGE_DIR=`(cd $execdir/.. > /dev/null 2>&1; pwd)` $PACKAGE_DIR/scripts/setversion.sh -(cd java/customization-api && mvn test) +(cd java/customization-api && mvn --batch-mode test)