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
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,8 @@ public class ErrorConstants {
public static final String INVALID_CERTIFICATE = "invalid_certificate";
public static final String VERIFICATION_METHOD_GENERATION_FAILED = "verification_method_generation_failed";
public static final String MISSING_APPLICATION_OR_REFERENCE_ID = "missing_application_or_reference_id";
public static final String STATUS_LIST_NOT_FOUND = "status_list_not_found_for_the_given_id";
public static final String STATUS_RETRIEVAL_ERROR = "error_parsing_status_list_credential_document";
public static final String INDEX_OUT_OF_BOUNDS = "requested_index_is_out_of_bounds_for_status_list_capacity";
public static final String INVALID_FRAGMENT = "invalid_fragment_format_must_be_a_valid_number";
}
19 changes: 19 additions & 0 deletions certify-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,25 @@
<artifactId>hypersistence-utils-hibernate-63</artifactId>
<version>3.9.9</version>
</dependency>
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>net.javacrumbs.shedlock</groupId>
<artifactId>shedlock-spring</artifactId>
<version>6.8.0</version>
</dependency>
<dependency>
<groupId>net.javacrumbs.shedlock</groupId>
<artifactId>shedlock-provider-jdbc-template</artifactId>
<version>6.8.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.mosip.certify/mock-certify-plugin -->
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package io.mosip.certify.config;

import net.javacrumbs.shedlock.core.LockProvider;
import net.javacrumbs.shedlock.provider.jdbctemplate.JdbcTemplateLockProvider;
import net.javacrumbs.shedlock.spring.annotation.EnableSchedulerLock;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.SchedulingConfigurer;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;

import javax.sql.DataSource;
import java.util.concurrent.Executors;

/**
* Configuration for batch job scheduling
*/
@Configuration
@EnableScheduling
@EnableSchedulerLock(defaultLockAtMostFor = "10m")
public class BatchJobConfig implements SchedulingConfigurer {

@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
taskRegistrar.setScheduler(Executors.newScheduledThreadPool(2));
}

@Bean
public LockProvider lockProvider(DataSource dataSource) {
return new JdbcTemplateLockProvider(
JdbcTemplateLockProvider.Configuration.builder()
.withJdbcTemplate(new JdbcTemplate(dataSource))
.usingDbTime()
.build()
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package io.mosip.certify.config;

import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

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

@Configuration
@ConfigurationProperties(prefix = "mosip.certify")
@Getter
@Setter
public class IndexedAttributesConfig {
/**
* Holds the mappings from a desired attribute name (key) to the
* JSONPath expression (value) used to extract it from the source data.
*/
private Map<String, String> indexedMappings = new HashMap<>();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*More actions
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
package io.mosip.certify.controller;

import io.mosip.certify.core.dto.VCError;
import io.mosip.certify.core.exception.CertifyException;
import io.mosip.certify.services.StatusListCredentialService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import java.util.Locale;
import java.util.Map;

@Slf4j
@RestController
@RequestMapping("/status-list")
public class StatusListCredentialController {

@Autowired
private StatusListCredentialService statusListCredentialService;

@Autowired
MessageSource messageSource;

/**
* Get Status List Credential by ID with optional fragment support
* Handles URLs like: /{id} or /{id}#{fragment}
*
* @param id The status list credential ID
// * @param fragment Optional fragment identifier (for specific index references)
* @return Status List VC JSON document
* @throws CertifyException
*/
@GetMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
public String getStatusListById(@PathVariable("id") String id) throws CertifyException {

log.info("Retrieving status list credential with ID: {}", id);
return statusListCredentialService.getStatusListCredential(id);
}

@ResponseBody
@ExceptionHandler(CertifyException.class)
@ResponseStatus(HttpStatus.NOT_FOUND)
public VCError statusListNotFoundExceptionHandler(CertifyException ex) {
VCError vcError = new VCError();
vcError.setError(ex.getErrorCode());
vcError.setError_description(messageSource.getMessage(ex.getErrorCode(), null, ex.getErrorCode(), Locale.getDefault()));
return vcError;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package io.mosip.certify.entity;

import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

@Entity
@Table(name = "credential_status_transaction")
@Data
@NoArgsConstructor
@AllArgsConstructor
public class CredentialStatusTransaction {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "transaction_log_id")
private Long transactionLogId;

@Column(name = "credential_id", length = 255, nullable = false)
private String credentialId;

@Column(name = "status_purpose", length = 100)
private String statusPurpose;

@Column(name = "status_value")
private Boolean statusValue;

@Column(name = "status_list_credential_id", length = 255)
private String statusListCredentialId;

@Column(name = "status_list_index")
private Long statusListIndex;

@Column(name = "cr_dtimes", nullable = false, updatable = false)
private LocalDateTime createdDtimes;

@Column(name = "upd_dtimes")
private LocalDateTime updatedDtimes;

@PrePersist
protected void onCreate() {
createdDtimes = LocalDateTime.now();
}

@PreUpdate
protected void onUpdate() {
updatedDtimes = LocalDateTime.now();
}
}
58 changes: 58 additions & 0 deletions certify-service/src/main/java/io/mosip/certify/entity/Ledger.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package io.mosip.certify.entity;

import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.JdbcTypeCode;
import org.hibernate.type.SqlTypes;

import java.time.LocalDateTime;
import java.time.OffsetDateTime;
import java.util.List;
import java.util.Map;

@Entity
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Ledger {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(name = "credential_id", length = 255, nullable = false, unique = true)
private String credentialId;

@Column(name = "issuer_id", length = 255, nullable = false)
private String issuerId;

@Column(name = "issue_date", nullable = false)
private OffsetDateTime issueDate;

@Column(name = "expiration_date")
private OffsetDateTime expirationDate;

@Column(name = "credential_type", length = 100, nullable = false)
private String credentialType;

@Column(name = "indexed_attributes")
@JdbcTypeCode(SqlTypes.JSON)
private Map<String, Object> indexedAttributes;

@Column(name = "credential_status_details", nullable = false)
@JdbcTypeCode(SqlTypes.JSON)
private List<Map<String, Object>> credentialStatusDetails;

@Column(name = "cr_dtimes", nullable = false, updatable = false)
private LocalDateTime createdDtimes;

@PrePersist
protected void onCreate() {
createdDtimes = LocalDateTime.now();
if (credentialStatusDetails == null) {
credentialStatusDetails = List.of();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package io.mosip.certify.entity;

import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

@Entity
@Table(name = "status_list_available_indices",
uniqueConstraints = {
@UniqueConstraint(name = "uq_list_id_and_index",
columnNames = {"status_list_credential_id", "list_index"})
},
indexes = {
@Index(name = "idx_sla_available_indices",
columnList = "status_list_credential_id, is_assigned, list_index")
}
)
@Data
@NoArgsConstructor
@AllArgsConstructor
public class StatusListAvailableIndices {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(name = "status_list_credential_id", length = 255, nullable = false)
private String statusListCredentialId;

@Column(name = "list_index", nullable = false)
private Long listIndex;

@Column(name = "is_assigned", nullable = false)
private Boolean isAssigned = false;

@Column(name = "cr_dtimes", nullable = false, updatable = false)
private LocalDateTime createdDtimes;

@Column(name = "upd_dtimes")
private LocalDateTime updatedDtimes;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "status_list_credential_id",
foreignKey = @ForeignKey(name = "fk_status_list_credential"),
insertable = false, updatable = false)
private StatusListCredential statusListCredential;

@PrePersist
protected void onCreate() {
createdDtimes = LocalDateTime.now();
if (isAssigned == null) {
isAssigned = false;
}
}

@PreUpdate
protected void onUpdate() {
updatedDtimes = LocalDateTime.now();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package io.mosip.certify.entity;

import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.JdbcType;
import org.hibernate.dialect.PostgreSQLEnumJdbcType;

import java.time.LocalDateTime;

@Entity
@Table(name = "status_list_credential", indexes = {
@Index(name = "idx_slc_status_purpose", columnList = "status_purpose")
})
@Data
@NoArgsConstructor
@AllArgsConstructor
public class StatusListCredential {

@Id
@Column()
private String id;

@Column(name = "vc_document", columnDefinition = "TEXT", nullable = false)
private String vcDocument;


@Column(name = "credential_type", length = 100, nullable = false)
private String credentialType;

@Column(name = "status_purpose", length = 100)
private String statusPurpose;

@Column(name = "capacity")
private Long capacity;

@Column(name = "credential_status")
@Enumerated(EnumType.STRING)
@JdbcType(PostgreSQLEnumJdbcType.class)
private CredentialStatus credentialStatus;

@Column(name = "cr_dtimes", nullable = false, updatable = false)
private LocalDateTime createdDtimes;

@Column(name = "upd_dtimes")
private LocalDateTime updatedDtimes;

public enum CredentialStatus {
AVAILABLE,
FULL;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package io.mosip.certify.exception;

public class RevocationException extends RuntimeException {
public RevocationException(String message) {
super(message);
}
}
Loading
Loading