Skip to content

Commit f0b1711

Browse files
committed
config: security file for applicaiton security; infra: handle integration with the ACH network
1 parent 9256907 commit f0b1711

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

src/config/SecurityConfig.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package org.nacha.paymentsystem;
2+
3+
import org.springframework.context.annotation.Configuration;
4+
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
5+
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
6+
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
7+
import org.springframework.security.web.SecurityFilterChain;
8+
9+
@Configuration
10+
public class SecurityConfig {
11+
12+
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
13+
http
14+
.authorizeHttpRequests(authz -> authz
15+
.requestMatchers("/api/payments/**").authenticated()
16+
.anyRequest().permitAll()
17+
)
18+
.formLogin()
19+
.and()
20+
.logout()
21+
.and()
22+
.csrf().disable(); // Enable CSRF protection in production!
23+
return http.build();
24+
}
25+
26+
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
27+
auth.inMemoryAuthentication()
28+
.withUser("user")
29+
.password(new BCryptPasswordEncoder().encode("password"))
30+
.roles("USER");
31+
}
32+
}

src/infra/external/ACHGateway.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package org.nacha.paymentsystem;
2+
3+
import com.company.paymentsystem.util.Logger;
4+
5+
public class ACHGateway {
6+
public boolean sendPayment(String accountNumber, double amount) {
7+
// Encrypt account number for security
8+
String encryptedAccount = encryptData(accountNumber);
9+
10+
// Send payment to ACH
11+
try {
12+
Logger.info("Sending payment to ACH: " + encryptedAccount);
13+
// Simulate sending payment
14+
return true;
15+
} catch (Exception e) {
16+
Logger.error("Failed to send payment", e);
17+
return false;
18+
}
19+
}
20+
21+
private String encryptData(String data) {
22+
// Simulate encryption (use real encryption like AES in production)
23+
return "ENCRYPTED_" + data;
24+
}
25+
}

0 commit comments

Comments
 (0)