This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.sma.security.config; | |
@Configuration | |
@EnableWebSecurity | |
@EnableGlobalMethodSecurity(prePostEnabled = true, | |
securedEnabled = true) | |
public class WebSecurityConfig extends WebSecurityConfigurerAdapter { | |
@Autowired | |
private JwtAuthenticationEntryPoint jwtAuthenticationEntryPoint; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.sma.security.config; | |
@Component | |
public class JwtRequestFilter extends OncePerRequestFilter { | |
public static final String AUTHORIZATION = "Authorization"; | |
public static final String BEARER = "Bearer "; | |
@Autowired | |
private JwtTokenService jwtTokenService; | |
@Override |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.sma.security.config; | |
import io.jsonwebtoken.Claims; | |
import io.jsonwebtoken.Jwts; | |
import io.jsonwebtoken.SignatureAlgorithm; | |
@Component | |
public class JwtTokenService { | |
public static final long JWT_TOKEN_VALIDITY = 5 * 60 * 60; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.sma.security.service; | |
@Service | |
public class JwtUserDetailsService implements UserDetailsService { | |
@Autowired | |
private UserRepository userRepository; | |
@Autowired |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.sma.security.controller; | |
@RestController | |
@CrossOrigin | |
public class JwtTokenController { | |
@Autowired | |
private AuthenticationManager authenticationManager; | |
@Autowired | |
private JwtTokenService jwtTokenUtil; | |
@Autowired |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.sma.backend.multidb.config; | |
import org.springframework.beans.factory.annotation.Qualifier; | |
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties; | |
import org.springframework.boot.context.properties.ConfigurationProperties; | |
import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder; | |
import org.springframework.context.annotation.Bean; | |
import org.springframework.context.annotation.Configuration; | |
import org.springframework.data.jpa.repository.config.EnableJpaRepositories; | |
import org.springframework.orm.jpa.JpaTransactionManager; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.sma.backend.multidb.config; | |
@Configuration | |
@EnableTransactionManagement | |
@EnableJpaRepositories(entityManagerFactoryRef = "mysqlEntityManagerFactory", transactionManagerRef = "mysqlTransactionManager", basePackages = {"com.sma.backend.multidb.database.mysql.repository"}) | |
public class MySqlConfig { | |
@Primary | |
@Bean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.sma.backend.multidb.controller; | |
import com.sma.backend.multidb.database.mysql.domain.CategoryEntity; | |
import com.sma.backend.multidb.database.mysql.repository.CategoryRepository; | |
import com.sma.backend.multidb.database.sqlserver.domain.CountryEntity; | |
import com.sma.backend.multidb.database.sqlserver.repository.CountryRepository; | |
import lombok.extern.slf4j.Slf4j; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.http.ResponseEntity; | |
import org.springframework.web.bind.annotation.RequestBody; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.sma.security.utils; | |
import lombok.extern.slf4j.Slf4j; | |
import javax.crypto.Cipher; | |
import javax.crypto.NoSuchPaddingException; | |
import javax.crypto.SecretKey; | |
import javax.crypto.SecretKeyFactory; | |
import javax.crypto.spec.PBEKeySpec; | |
import javax.crypto.spec.PBEParameterSpec; | |
import java.security.InvalidAlgorithmParameterException; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Configuration | |
@EnableTransactionManagement | |
@EnableJpaRepositories(entityManagerFactoryRef = "oracleEntityManagerFactory", transactionManagerRef = "oracleTransactionManager", basePackages = { "com.sma.oracle.repository" }) | |
public class OracleDatabaseConfiguration { | |
@Primary | |
@Bean | |
@ConfigurationProperties(prefix = "oracle.datasource") | |
public DataSourceProperties oracleDataSourceProperties(@Qualifier("oracleDataSourceProperties() { | |
return new DataSourceProperties(); | |
} |
OlderNewer