Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</parent>
<groupId>io.mosip</groupId>
<artifactId>mimoto</artifactId>
<version>0.2.0-SNAPSHOT</version>
<version>1.2.0-SNAPSHOT</version>
<name>mimoto</name>
<description>Mobile server backend supporting Inji.</description>

Expand Down Expand Up @@ -529,14 +529,14 @@
</executions>
<configuration>
<generateGitPropertiesFile>true</generateGitPropertiesFile>
<generateGitPropertiesFilename>${project.build.outputDirectory}/build.json</generateGitPropertiesFilename>
<generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties</generateGitPropertiesFilename>
<includeOnlyProperties>
<includeOnlyProperty>^git.build.(time|version)$</includeOnlyProperty>
<includeOnlyProperty>^git.build.(time|version|host)$</includeOnlyProperty>
<includeOnlyProperty>^git.(branch|tags)$</includeOnlyProperty>
<includeOnlyProperty>^git.commit.id.(abbrev|full)$</includeOnlyProperty>
<includeOnlyProperty>^git.branch$</includeOnlyProperty>
</includeOnlyProperties>
<commitIdGenerationMode>full</commitIdGenerationMode>
<format>json</format>
</configuration>
</plugin>
</plugins>
Expand Down
23 changes: 0 additions & 23 deletions src/main/java/io/mosip/mimoto/MimotoServiceApplication.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package io.mosip.mimoto;

import com.fasterxml.jackson.databind.ObjectMapper;

import org.json.simple.JSONObject;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration;
Expand Down Expand Up @@ -44,27 +41,7 @@ public ThreadPoolTaskScheduler taskScheduler() {
return threadPoolTaskScheduler;
}

public static JSONObject getGitProp() {
try {
return (new ObjectMapper()).readValue(
MimotoServiceApplication.class.getClassLoader().getResourceAsStream("build.json"),
JSONObject.class
);
} catch (Exception e) {
System.err.println("Error when trying to read build.json file: " + e);
}
return new JSONObject();
}

public static void main(String[] args) {
JSONObject gitProp = getGitProp();
System.out.println(
String.format(
"Mimoto Service version: %s - revision: %s @ branch: %s | build @ %s",
gitProp.get("git.build.version"),
gitProp.get("git.commit.id.abbrev"),
gitProp.get("git.branch"),
gitProp.get("git.build.time")));
SpringApplication.run(MimotoServiceApplication.class, args);
}

Expand Down
7 changes: 0 additions & 7 deletions src/main/java/io/mosip/mimoto/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,7 @@ protected void configure(HttpSecurity http) throws Exception {
if (!isCSRFEnable) {
http = http.csrf().disable();
}
// http.authorizeRequests().antMatchers("*").authenticated().and().exceptionHandling()
// .authenticationEntryPoint(new AuthEntryPoint()).and().sessionManagement()
// .sessionCreationPolicy(SessionCreationPolicy.STATELESS);

// http.addFilterBefore(authFilter(),
// UsernamePasswordAuthenticationFilter.class);

// FIXME: web security is disabled for all enpoints
http.authorizeRequests().antMatchers("*").authenticated().anyRequest().permitAll().and().exceptionHandling();
if (isCORSEnable) {
http.addFilterBefore(new CorsFilter(origins), AuthFilter.class);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.mosip.mimoto.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
Expand All @@ -17,7 +16,6 @@
import io.mosip.mimoto.util.AttestationOnlineVerify;
import io.mosip.mimoto.util.LoggerUtil;

@SpringBootApplication
@RestController
@RequestMapping(value = "/safetynet")
public class AttestationServiceController {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public class CredentialShareController {
* @throws Exception
*/
@PostMapping(path = "/callback/notify", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthenticateContentAndVerifyIntent(secret = "${mosip.event.secret}", callback = "/v1/mimoto/credentialshare/callback/notify", topic = "${mosip.event.topic}")
@PreAuthenticateContentAndVerifyIntent(secret = "${mosip.event.secret}", callback = "/credentialshare/callback/notify", topic = "${mosip.event.topic}")
public ResponseEntity<GenericResponseDTO> handleSubscribeEvent(@RequestBody EventModel eventModel)
throws Exception {
logger.info("Received websub event:: transaction id = " + eventModel.getEvent().getTransactionId());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package io.mosip.mimoto.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import io.mosip.mimoto.util.VersionInfo;

@RestController
public class MimotoServiceController {
@Autowired
VersionInfo versionInfo;

/**
* Return build properties with git revision and version information.
*
* @return
*/
@GetMapping("/info")
public ResponseEntity<Object> info() {
return ResponseEntity.ok().body(versionInfo.getVersionInfo());
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.mosip.mimoto.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.core.env.Environment;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
Expand All @@ -27,7 +26,6 @@
import io.mosip.mimoto.util.DateUtils;
import io.mosip.mimoto.util.LoggerUtil;

@SpringBootApplication
@RestController
public class ResidentServiceController {

Expand Down
89 changes: 89 additions & 0 deletions src/main/java/io/mosip/mimoto/util/VersionInfo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package io.mosip.mimoto.util;

import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

import javax.annotation.PostConstruct;

import org.jboss.jandex.Main;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.info.BuildProperties;
import org.springframework.stereotype.Component;

@Component
public class VersionInfo {
@Autowired
private BuildProperties buildProperties;

@Value("${mosipbox.public.url}")
private String mosipHost;

@Value("${mosip.event.hubUrl}")
private String websubUrl;

private Properties gitProperties = new Properties();

public final String[] DEFAULT_GIT_PROPERTIES = {
"git.build.time",
"git.branch",
"git.tags",
"git.commit.id.abbrev",
};

@PostConstruct
public void initialize() {
try {
gitProperties.load(Main.class.getResourceAsStream("/git.properties"));;

} catch (Exception e) {
System.err.println("Error when trying to read git.properties file: " + e);
}
System.out.println("=".repeat(160));
System.out.println(getBuildString());
System.out.println(getServiceString());
System.out.println("=".repeat(160));
}

public Map<String, Object> getVersionInfo() {
Map<String, Object> versionInfo = new HashMap<String, Object>();

Map<String, String> appInfo = new HashMap<String, String>();
appInfo.put("name", buildProperties.getName());
appInfo.put("version", buildProperties.getVersion());
versionInfo.put("application", appInfo);

Map<String, String> buildInfo = new HashMap<String, String>();
for (String prop : DEFAULT_GIT_PROPERTIES) {
buildInfo.put(prop, gitProperties.getProperty(prop));
}
versionInfo.put("build", buildInfo);

Map<String, String> configInfo = new HashMap<String, String>();
configInfo.put("mosip.host", mosipHost);
configInfo.put("websub.url", websubUrl);
versionInfo.put("config", configInfo);

return versionInfo;
}

public String getBuildString() {
return String.format(
"%s build [version=%s, time=%s] | commit: %s @ branch: %s",
buildProperties.getName(),
buildProperties.getVersion(),
buildProperties.getTime(),
gitProperties.getProperty("git.commit.id.abbrev"),
gitProperties.getProperty("git.branch")
);
}

public String getServiceString() {
return String.format(
"MOSIP Host: %s | Websub URL: %s",
mosipHost,
websubUrl
);
}
}