๐ฏ
This file contains hidden or 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
| void accessUsers(){ | |
| Statement statement = connection.createStatement(); | |
| //sql only accepts username input, because the password has been commented out | |
| String username = "admin'; #"; | |
| String password = "123"; | |
| //with String Append | |
| String sql = "SELECT * FROM account WHERE username = '" +username+ | |
| "' AND password = '" +password+ "'"; |
This file contains hidden or 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
| void prepareStatement() throws SQLException { | |
| Connection connection = ConnectionUtil.getDataSource().getConnection(); | |
| //testing inject SQL use characters like '; # | |
| String username = "admin'; #"; | |
| String password = "salah"; | |
| //DON'T USE STRING APPEND! | |
| String sql = "SELECT * FROM admin WHERE username = ? AND password = ?"; |
This file contains hidden or 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
| class AirplaneModeChangeReceiver : BroadcastReceiver() { | |
| override fun onReceive(context: Context?, intent: Intent?) { | |
| val isAirplaneModeOn = Settings.Global.getInt( | |
| context?.contentResolver, | |
| Settings.Global.AIRPLANE_MODE_ON, | |
| 0) != 0 | |
| if (intent?.action == Intent.ACTION_AIRPLANE_MODE_CHANGED && isAirplaneModeOn){ | |
| Toast.makeText(context, "Airplane mode is enabled", Toast.LENGTH_SHORT).show() |
This file contains hidden or 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
| class ActionActivity : AppCompatActivity() { | |
| private lateinit var binding: ActivityActionBinding | |
| private val airplaneModeChangeReceiver = AirplaneModeChangeReceiver() | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| binding = ActivityActionBinding.inflate(layoutInflater) | |
| setContentView(binding.root) |
This file contains hidden or 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
| import kotlinx.serialization.Serializable | |
| @Serializable | |
| data class Cat ( | |
| val name: String, | |
| val description: String, | |
| val image: String | |
| ) |
This file contains hidden or 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
| import com.ichwan.data.Cat | |
| import io.ktor.http.* | |
| import io.ktor.server.application.* | |
| import io.ktor.server.routing.* | |
| private const val BASE_URL = "http://localhost:8100/" | |
| private val cats = listOf( | |
| Cat("Persia", "Kucing persia flatnose", "$BASE_URL/cats/persia.jpg"), | |
| Cat("Himalaya", "Kucing himalaya ekor coklat", "$BASE_URL/cats/himalaya.jpg"), | |
| Cat("British", "Kucing british bulu pendek", "$BASE_URL/cats/british.jpg"), |
This file contains hidden or 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
| <?xml version="1.0" encoding="UTF-8"?> | |
| <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
| <modelVersion>4.0.0</modelVersion> | |
| <groupId>org.example</groupId> | |
| <artifactId>apachemaven</artifactId> | |
| <version>1.0-SNAPSHOT</version> | |
| <packaging>pom</packaging> |
This file contains hidden or 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
| public class Person { | |
| private String id; | |
| private String name; | |
| public Person(String id, String name) { | |
| this.id = id; | |
| this.name = name; | |
| } |
This file contains hidden or 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
| public interface PersonRepository { | |
| Person findById(String id); | |
| void insert(Person person); | |
| } |
This file contains hidden or 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
| public class PersonService { | |
| private PersonRepository repository; | |
| public PersonService(PersonRepository repository) { | |
| this.repository = repository; | |
| } | |
| public Person getById(String id){ | |
| Person person = repository.findById(id); |
OlderNewer