Posts

Unveiling the Divine: Exploring the Mystique of Ganesh Chaturthi

Image
Ganesh Chaturthi, also known as Vinayaka Chaturthi, is a Hindu festival that celebrates the birth of Lord Ganesha, the elephant-headed god of wisdom and prosperity. It typically falls in the Hindu calendar month of Bhadrapada, which usually corresponds to August or September in the Gregorian calendar. Ganesh Chaturthi is one of the most widely celebrated festivals in India, especially in the states of Maharashtra, Gujarat, Karnataka, and Andhra Pradesh. Origin and History: Ganesh Chaturthi has its roots in ancient Hindu scriptures and mythology. Lord Ganesha is believed to be the son of Lord Shiva and Goddess Parvati. According to Hindu mythology, Lord Ganesha was created by Goddess Parvati and was given the responsibility of guarding her while she bathed. When Lord Shiva returned and was denied entry by Ganesha, a battle ensued, resulting in Lord Ganesha's head being severed. Later, he was brought back to life with an elephant head. The modern, public celebration of Ganesh Chaturt...

Migrating from Traditional DAO to Spring Data REST with JPA

Image
Spring Data Rest is a spring boot project but it's like a more advanced and less coding application. There are three new concepts in Spring Data Rest -   Configuration  It adds 's' automatically to the entity. You can also give path for your URL  Add @RepositoryRestResource(path="members") annotation at top of Repository interface. Pagination  # change default page size  spring.data.rest.default-page-size=3  Sorting  http://localhost:8080/magic-api/members?sort=age ---default in ascending  http://localhost:8080/magic-api/members?sort=age ---in descending Steps to develop CRUD application-   Go to https://start.spring.io/ and kick start your project. Add necessary dependencies like Spring Data JPA, Spring Web, Spring Boot DevTools, MySql Driver, spring-boot-starter-data-rest . Select as maven and enter.   Import as maven project and check pom for dependencies we added.  Create entity class in entity package and write ...

What to change for JDBC connection in Spring Security

Image
  What to change for JDBC connection in Spring Security? Add annotation @PropertySource("classpath:persistance-mysql.properties") in AppConfig   setup variables to hold properties @Autowired private Environment env;   setup a logger for diagnostics private Logger logger = Logger.getLogger(getClass().getName());   define a bean for security datasource  @Bean  public DataSource securityDataSource() {    //create connection pool  ComboPooledDataSource securityDataSource = new ComboPooledDataSource();    //set jdbc driver class  try {  securityDataSource.setDriverClass(env.getProperty("jdbc.driver"));  }catch(PropertyVetoException exc) {  throw new RuntimeException(exc);  }    //log connection properties  //to make sure data we are reading is correct  logger.info(">>> jdbc.url=" +env.getProperty("jdbc.url"));  logger.info(">>> jdbc.user=" +env.getProperty...

Springing into Security: Best Practices for a Secure Application

Image
Spring Security is a spring framework for security. It is implemented using servlet filters in the background.  There are two ways to secure spring webapps-  Declarative Security  Programmatic Security  In Declarative Security we define application security constraints in configuration I.e., all java config (@Configuration, no XML) or spring XML config. It provides separation of concerns between application code and security.     In programmatic Security spring security provides an api for custom application coding and it provides greater customization for specific application requirements.    CSRF (Cross-site-request-forgery) protection Spring security protects against CSRF(Cross-site-request-forgery). It is a security attack where maybe an evil website tricks you into executing an action on a web application while you are logged in.  For instance, you are logged in your bank portal so you can be tricked into transferring money to other...