Skip to content

Commit

Permalink
Merge pull request #127 from JanardhanBS-SyncByte/develop-java21
Browse files Browse the repository at this point in the history
[MOSIP-33145]
  • Loading branch information
ckm007 committed May 24, 2024
2 parents b5f063f + bcf5c1f commit 25b8f6f
Show file tree
Hide file tree
Showing 9 changed files with 348 additions and 348 deletions.
1 change: 0 additions & 1 deletion biosdk-services/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,6 @@
</includeOnlyProperties>
<commitIdGenerationMode>full</commitIdGenerationMode>
<dotGitDirectory>${project.basedir}/.git</dotGitDirectory>
<!-- <format>json</format> -->
</configuration>
</plugin>
</plugins>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package io.mosip.biosdk.services.config;

import io.mosip.kernel.biometrics.spi.IBioApiV2;
import static io.mosip.biosdk.services.constants.AppConstants.LOGGER_IDTYPE;
import static io.mosip.biosdk.services.constants.AppConstants.LOGGER_SESSIONID;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -10,6 +15,9 @@
import org.springframework.context.annotation.Lazy;
import org.springframework.core.env.Environment;

import io.mosip.biosdk.services.constants.ErrorMessages;
import io.mosip.biosdk.services.exceptions.BioSDKException;
import io.mosip.kernel.biometrics.spi.IBioApiV2;
import jakarta.annotation.PostConstruct;

@Configuration
Expand All @@ -19,32 +27,31 @@ public class BioSdkLibConfig {
@Autowired
private Environment env;

public BioSdkLibConfig() {
}

@PostConstruct
public void validateBioSdkLib() throws ClassNotFoundException {
String sdkClass = this.env.getProperty("biosdk_bioapi_impl");
logger.info("Biosdk class: " + sdkClass);
logger.info(LOGGER_SESSIONID, LOGGER_IDTYPE, "validateBioSdkLib::Biosdk class: ", sdkClass);
if (StringUtils.isNotBlank(sdkClass)) {
logger.debug("validating Bio SDK Class is present or not");
logger.debug(LOGGER_SESSIONID, LOGGER_IDTYPE, "validating Bio SDK Class is present or not");
Class.forName(sdkClass);
}

logger.debug("validateBioSdkLib: Bio SDK Class is not provided");
logger.debug(LOGGER_SESSIONID, LOGGER_IDTYPE, "validateBioSdkLib: Bio SDK Class is not provided");
}

@Bean
@Lazy
public IBioApiV2 iBioApi() throws ClassNotFoundException, InstantiationException, IllegalAccessException {
public IBioApiV2 iBioApi() throws ClassNotFoundException, InstantiationException, IllegalAccessException, NoSuchMethodException, SecurityException, IllegalArgumentException, InvocationTargetException {
String sdkClass = this.env.getProperty("biosdk_bioapi_impl");
logger.info("Biosdk class: " + sdkClass);
logger.info(LOGGER_SESSIONID, LOGGER_IDTYPE, "iBioApi::Biosdk class:", sdkClass);
if (StringUtils.isNotBlank(sdkClass)) {
logger.debug("instance of Bio SDK is created");
return (IBioApiV2)Class.forName(sdkClass).newInstance();
logger.debug(LOGGER_SESSIONID, LOGGER_IDTYPE, "instance of Bio SDK is created");
Constructor<?> constructor = Class.forName(sdkClass).getDeclaredConstructor();
return (IBioApiV2) constructor.newInstance();
} else {
logger.debug("no Bio SDK is provided");
throw new RuntimeException("No Bio SDK is provided");
logger.debug(LOGGER_SESSIONID, LOGGER_IDTYPE, "no Bio SDK is provided");
throw new BioSDKException(ErrorMessages.NO_BIOSDK_PROVIDER_FOUND.toString(),
ErrorMessages.NO_BIOSDK_PROVIDER_FOUND.getMessage());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.firewall.DefaultHttpFirewall;
Expand All @@ -19,8 +20,8 @@ public HttpFirewall defaultHttpFirewall() {

@Bean
public SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Exception {
httpSecurity.httpBasic(httpEntry -> httpEntry.disable());
httpSecurity.csrf(httpEntry -> httpEntry.disable());
httpSecurity.httpBasic(AbstractHttpConfigurer::disable);
httpSecurity.csrf(AbstractHttpConfigurer::disable);
httpSecurity.authorizeHttpRequests(http -> http.anyRequest().permitAll());

return httpSecurity.build();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,26 @@
package io.mosip.biosdk.services.constants;

public enum ResponseStatus {

SUCCESS(200, "OK"),
INVALID_INPUT(401, "Invalid Input Parameter - %s"),
MISSING_INPUT(402, "Missing Input Parameter - %s"),
QUALITY_CHECK_FAILED(403, "Quality check of Biometric data failed"),
POOR_DATA_QUALITY(406, "Data provided is of poor quality"),
UNKNOWN_ERROR(500, "UNKNOWN_ERROR");

ResponseStatus(int statusCode, String statusMessage) {
this.setStatusCode(statusCode);
this.setStatusMessage(statusMessage);
this.statusCode = statusCode;
this.statusMessage = statusMessage;
}

private int statusCode;
private String statusMessage;

public int getStatusCode() {
return statusCode;
}
public void setStatusCode(int statusCode) {
this.statusCode = statusCode;
}

public String getStatusMessage() {
return statusMessage;
}

public void setStatusMessage(String statusMessage) {
this.statusMessage = statusMessage;
}


}
}
Loading

0 comments on commit 25b8f6f

Please sign in to comment.