File tree Expand file tree Collapse file tree 2 files changed +57
-0
lines changed
Expand file tree Collapse file tree 2 files changed +57
-0
lines changed Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments