Skip to content

Commit

Permalink
chore: proper implementation for auditor access
Browse files Browse the repository at this point in the history
  • Loading branch information
Koufan-De-King committed Oct 4, 2024
1 parent e0e6964 commit 48fbf31
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 30 deletions.
Original file line number Diff line number Diff line change
@@ -1,42 +1,17 @@
package de.adorsys.ledgers.baam.db.domain;

import jakarta.persistence.*;
import java.util.logging.Logger;
import jakarta.persistence.Entity;
import jakarta.persistence.Table;

@Entity
@Table(name = "auditor_access")
public class AuditorAccess extends BankAccountAccess {
private static final Logger logger = Logger.getLogger(AuditorAccess.class.getName());

// Constructor sets default values
public AuditorAccess() {
super();
this.setStatus(AccessStatus.ACTIVE); // By default, AuditorAccess is active
this.setWeight(1.0); // Weight is always 1 for AuditorAccess
logger.info("AuditorAccess created with default active status and weight of 1");
this.setWeight(1.0); // Weight is always 1 for Auditor Access
}

public boolean allowsAction(String action) {
// Only allow read actions such as viewing transactions and balances
return switch (action) {
case "VIEW_ACCOUNT_BALANCES", "VIEW_TRANSACTION_HISTORY", "VIEW_ACCESS_LOGS" -> true;
default -> false; // No modifications are allowed
};
}

// Overriding status management to ensure that AuditorAccess can be restricted or suspended
public void suspendAccess() {
this.setStatus(AccessStatus.SUSPENDED);
logger.info("AuditorAccess has been suspended.");
}

public void activateAccess() {
this.setStatus(AccessStatus.ACTIVE);
logger.info("AuditorAccess has been reactivated.");
}

public void restrictAccess() {
this.setStatus(AccessStatus.RESTRICTED);
logger.info("AuditorAccess has been restricted.");
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@

@Repository
public interface AuditorAccessRepository extends JpaRepository<AuditorAccess, String> {
// Additional query methods can be added here if necessary

}

0 comments on commit 48fbf31

Please sign in to comment.