Powered by Blogger.

Wednesday 27 December 2023

Multiples DATABASE Connection and Data shifting Using Spring Boots API

No comments :
Multiple DataBase Connection and Data shifting using Spring boot API configuration Example.
Step-by-step Write Java files.
1. application.properties File for Add multiple DataBase Connection. 
2. DBConfigDBNAME.JAVA Files for multiple DataBase Connection. 
3. Job Scheduler.java file for Auto shift programm. 
4. Entity Beans, Repository, Services Implementations for Binding and shifting Data.
  1. Create Spring Boot Java (Microservices)
      Create Spring Boot Java (Microservices).
  1. Project Name: DataShiftingConfigSpringBoots
  2. Group: DataShifting-a143mk
  3. Artifactid: DataShifting-a143mk
  4. Description: DataBase Connection and Data shifting using Spring boot API.
  5. Package: DataShiftinga143mk
Select the technologies and library(Maven Dependency ) to be.
  1. spring-boot-configuration-processor
  2. ojdbc8

while creating the project pom.xml file and some maven dependency, main class is automatically created when web add any dependency like.

pom.xml


1. Configure application.properties


Create DataBase Configuration java Files :
DBConfigDATABASE1.java


DBConfigDATABASE2.java


DBConfigDATABASE3.java

Create Scheduler ClassCreate Scheduler for Auto run Program and import some Packages Scheduler.java as below:

Have you seen the previous post? You all know how to learn and create Entity Bean, Repository, Service Implementation in the project. If you don't know about it then go to the previous post and learn it.

Tuesday 19 September 2023

How to PACKAGE Spring Boot application to JAR and WAR

No comments :
Maven is a popular build tool, that takes your project’s Java source code, compiles it, tests it and converts it into an executable Java program: either a .jar or a .war file.  
Package Spring Boot application to JAR OR WAR file:
The default packaging type of a Spring Boot project is jar if the attribute is not present in the pom.xml file. It’s better to check your project’s pom.xml file to make sure that the packaging type is jar or War:

If you use an IDE such as Eclipse or Spring Tool Suite, right-click on the project, then select Run As > Maven Configuration Like:
  • CLEAN
  • BUILD
  • INSTALL
  • PACKAGE.................etc.







Monday 26 June 2023

LDAP Authentication with Spring Boots

3 comments :
LDAP is a lightweight version of the Directory Access Protocol (DAP).LDAP’s primary function is enabling users to find data about organizations, persons, and more. It accomplishes this goal by storing data in the LDAP directory and authenticating users to access the directory. It also provides the communication language that applications require to send and receive information from directory services.
Step-by-step authentication process with Some Ldap properties.
The client (an LDAP-ready system or application) sends a request to access information stored within an LDAP database. The client provides their LDAP server user credentials (username and password). The LDAP server cross-checks the user’s submitted credentials against the core user identity data stored in its LDAP database. If the provided credentials match the stored core user identity, the client can access the requested information. Incorrect credentials will lead to denied access to the LDAP database.
Some Ldap properties.

ldap.enable=true

Enable / disable LDAP support.

ldap.ldapUrl=ldap://HostIP:389

The URL/IP to your LDAP server, including port

ldap.ldapSystemDN=cn=Administrator,dc=olattest,dc=org

System user: used for getting all users and connection testing

ldap.ldapSystemPW=mySuperPassword

The LDAP password of the system user

ldap.ldapBases= ou=person,dc=olattest,dc=org

List of bases where to find users. To use multiple bases you must edit the config file manually

ldap.sslEnabled = false

Enable SSL connection

ldap.trustStoreLocation=/usr/lib/j2sdk1.5-sun/jre/lib/security/cacerts

Location of the Java trust store

ldap.trustStorePwd=changeit

The Java trust store password

ldap.trustStoreType=JKS

The Java trust store type

ldap.cacheLDAPPwdAsOLATPwdOnLogin=true

When users log in via LDAP, the system can keep a copy of the password as encrypted hash in the database. This makes OLAT more independent from an offline LDAP server and users can use their LDAP password to use the WebDAV functionality. When setting to true (recommended), make sure you configured password.change.allowed=false

ldap.convertExistingLocalUsersToLDAPUsers=true

When the system detects an LDAP user that does already exist in OLAT but is not marked as LDAP user, the OLAT user can be converted to an LDAP managed user. When enabling this feature you should make sure that you don't have a user 'administrator' in your ldapBases (not a problem but not recommended)

ldap.deleteRemovedLDAPUsersOnSync=false

Users that have been created vial LDAP sync but now can't be found on the LDAP anymore can be deleted automatically. If unsure, set to false and delete those users manually in the LDAP administration panel.

ldap.deleteRemovedLDAPUsersPercentage=50

Sanity check when deleteRemovedLDAPUsersOnSync is set to 'true': if more than the defined percentages of user accounts are not found on the LDAP server and thus recognized as to be deleted, the LDAP sync will not happen and require a manual triggering of the delete job from the admin interface. This should prevent accidential deletion of OLAT user because of temporary LDAP problems or user relocation on the LDAP side. Value= 0 (never delete) to 100 (always delete).

ldap.ldapSyncOnStartup=true

Should users be created and synchronized automatically on startup? If you set this and the cron configuration to false, the users will be generated on-the-fly when they log in the first time.

ldap.ldapSyncCronSync=true

Should users be created and synchronized periodically, not just during startup? If you set this and the startup configuration to false, the users will be generated on-the-fly when they log in the first time.

ldap.ldapSyncCronSyncExpression=0 0 * * * ?

Set the rule how often the LDAP synchronization should take place. Default is every hour. For the cron syntax see quartz cron syntax documentation

ldap.ldapUserObjectClass=person

Configuration for syncing user attributes during login or cron and batch sync. The user object class to use.

ldap.ldapUserCreatedTimestampAttribute=createdTimestamp

The LDAP attribute that tells the creation date of the LDAP user. In active Directory this is typically "whenCreated", in OpenLDAP "createdTimestamp". If not available, use the same as for the last modified date.

ldap.ldapUserLastModifiedTimestampAttribute=modifyTimestamp

The LDAP attribute that tells the creation date of the LDAP user. In active Directory this is typically "whenChanged", in OpenLDAP "modifiedTimestamp"

ldap.attributename.useridentifyer=uid

Mapping of the LDAP user identifyer to an OLAT user. In Active Directory this is typically "sAMAccountName", in OpenLDAP "uid".

ldap.attributename.email=mail

Mapping of the mandatory OLAT user properties. In this example the LDAP attribute "mail" will be mapped to the OLAT user property "email"

ldap.attributename.firstName=givenName

Mapping of the mandatory OLAT user properties. In this example the LDAP attribute "givenName" will be mapped to the OLAT user property "firstname"

ldap.attributename.lastName=sn

Mapping of the mandatory OLAT user properties. In this example the LDAP attribute "sn" will be mapped to the OLAT user property "lastName"

olatprovider.enable=false

Disable the normal OLAT login screen. When you set ldap.cacheLDAPPwdAsOLATPwdOnLogin=true, a fallback to the normal OLAT login is made in case the LDAP server can not be reached. You can set this variable also to true to have the OLAT and the LDAP login screen available

default.auth.provider=LDAP

Use the LDAP login screen as the default login screen.

  1. Create Spring Boot Java (Microservices) Project Example
      Create Spring Boot Java (Microservices).
  1. Project Name: LdapAuthenticationConfigSpringBoots.
  2. Group:Ldap-Auth-a143mk.
  3. Artifactid:Ldap-Auth-a143mk.
  4. Description:Learn-Configure LDAP Authentication.
  5. Package:LDAPAutha143mk.



Select the technologies and library(Maven Dependency ) to be.
  1. Spring Web
  2. Spring ldap
  3. ldapsdk
  4. ldap security

while creating the project pom.xml file and some maven dependency, main class is automatically created when web add any dependency like.

pom.xml



Configure application.properties


Create ldap-data.ldif :
Directory Server uses LDAP Data Interchange Format is a standard text format for representing LDAP objects and LDAP updates (add, modify, delete, modify DN) in a textual form.

WebSecurityConfig ClassCreate new package, named LDAPAutha143mk.config. In this package, create Configuration class name is WebSecurityConfig.java as below:

Create Controllers
Create new package named LDAPAutha143mk.controller. In this package, create new java class named LoginWelcomeController.java


Run Project
 

Wednesday 17 May 2023

Learn I- Report configuration with Spring boot/Microservices using Java

1 comment :
iReport
iReport is a powerful graphical design tool for report designers and power users to define reports for execution using the JasperReports engine. Whether you are using the JasperReports library by itself as a critical component of your application or you are using it as a component of the JasperReports Server application, iReport can help you design reports to meet the most complex reporting demands. iReport is built on the NetBeans platform and is available as a standalone application or as a Netbeans plug-in.
Requirements For current Download JasperReports iReport Tools , Ckeck It is recommended that you run iReport with JDK v1.5,v1.6 or v1.7. Note that for Windows Vista users, it is recommended that you run JDK v1.7.
JasperReports Create very sophisticated layouts containing charts, images, subreports, crosstabs and much more. Access your data through JDBC, TableModels, JavaBeans, XML, Hibernate, CSV, and custom sources. Then publish your reports as PDF, RTF, XML, XLS, CSV, HTML, XHTML, text, DOCX, or OpenOffice. Through this post, we will tell you how to configure iReport in Mavan base java application(Microservices) project. follows step by step:

  1. Create Spring Boot Java (Microservices)
  2. Create/Design report.jrxml
Create Spring Boot Java (Microservices).
  1. Project Name: I-ReportConfigurationApp
  2. Group:I-Report-a143mk
  3. Artifactid:I-Report-a143mk
  4. Description:Learn I- Report configuration with Microservices Application
  5. Package:I-Report-a143mk




Select the technologies and library(Maven Dependency ) to be.
  1. Spring Web
  2. Spring JPA
  3. Jasperreports
  4. javax.persistence
  5. Tomcat
  6. javax.servlet
  7. mysql
  8. jstl

while creating the project pom.xml file and some maven dependency, main class is automatically created when web add any dependency like.

pom.xml


For step by step development working watch the video and learn yourself. Download wampServer2.0i and install then run it.



1. Create Database: Database Name is hostel.
2. Create Table: Table Name is product.




Configure application.properties


Report:
In src/main/resources/reports/report.jrxml folder, create new folder named reports. In this folder, create new Jasper Report named report.jrxml as below:
 


Code:



Entities Class
Create new package, named IReporta143mk.entities. In this package, create entities class name is Product.java as below:



Create ProductRepository Interface
Create new package named IReporta143mk.repositories. In this package create the ProductRepository interface implements from CrudRepository interface of Spring Data JPA that provides CRUD Operations for an entity.


Create ProductService Interface
Create new package named IReporta143mk.services. In this package create the ProductService interface and ProductServiceImpl as below:
First one is ProductService.java


Second one is ProductServiceImpl.java



Create Controllers
Create new package named IReporta143mk.controllers. In this package, create new java class named ProductController.java


Create jsp page
Create new folder name is jsp. In thes folder /src/main/webapp/WEB-INF/jsp/index.jsp

Structure of Spring Boot Project:


Out Put:




Tuesday 3 January 2023

Single Sign-On (SSO) Using SMTP Authentication With Spring Boot Microservices

2 comments :
Single sign-on is an authentication scheme that allows a user to log in with a single ID to any of several related, independent, software systems or web applications. In this Video user will login through Outlook and Google Mail for which we will develop Spring Boot Microservices Project here and will also use some Spring Boot Jar files javax.mail.jar and SendMailA143mkSSO.jar
Process of Single sign-On (SSO) Authentication:




Download both the jar file and implement some methods / functions have been used, the names of the methods are as follows:

Create Class object SendMailA143mk getsess=new SendMailA143mk();
  1. LoginMailAuthHost_PortA143mk();
  2. OutLookMailAuthA143mk();
  3. GmailMailAuthA143mk();
There are some parameters in five methods, which we initialize by creating and object like this.

String toAuthmail="EmailMail@mailDomen.com";
String toAuthmailPassword="mailPassword"; 
String host="smtp.office365.com"; 
String port="587"; 

How to create a project to follow us. Project Name is: EmailAuthenticationA143mk




while creating the project pom.xml file and some maven dependency, main class is automatically created when web add any dependency like.

pom.xml


For step by step development working watch the video and learn yourself.


Some Helping Note: Some code and video are shown in this post, how we can use it in our application, the developer and jar file used in this is verified by mail id and password and after mail id is successful is returned, you can then write custom user roles and method entities in the block. and you can write error body in second part of it.

Wednesday 13 July 2022

Social Client Login with OAuth2 Spring Boot Application

2 comments :
First of all you have to take auth2 access to the social web site, we see it in the video, then we will create a services and test it and see some services we learned in the previous post, we will give their link below which includes Eureka (client-1, client-2)ApiGetway, services.



Add client and secret Id in ApiGetway application.properties  file:

spring.security.oauth2.client.registration.Oauth2_Security.client-id = Write your Client ID spring.security.oauth2.client.registration.Oauth2_Security.client-secret = Write your Secret ID

Add use Dependency in ApiGetway pom.xml  file:

Add New Package in ApiGetway-> com.javatechie.spring.zulu.api.cofig and create SecurityConfiguration.java file.


See the video step by step to run/learn past post video and current configuration post.




How to Develop Some Other Rest API How to Develop Eureka Server and Eureka Client Configuration How to Develop GateWayAPI How to get Google Token

Wednesday 6 July 2022

OAuth2 Security with Spring Boot

1 comment :
Introduction
OAuth2 is a token-based security authentication and authorization framework that breaks security down into four components. These four components are 
  1.  A protected resource—This is the resource (in our case, a microservice) you want to protect and ensure that only authenticated users who have the proper authorization can access 
  2.  A resource owner—A resource owner defines what applications can call their service, which users are allowed to access the service, and what they can do with the service. Each application registered by the resource owner will be given an application name that identifies the application along with an application secret key. The combination of the application name and the secret key are part of the credentials that are passed when authenticating an OAuth2 token. 
  3.  An application—This is the application that’s going to call the service on a behalf of a user. After all, users rarely invoke a service directly. Instead, they rely on an application to do the work for them. 
  4.  OAuth2 authentication server—The OAuth2 authentication server is the intermediary between the application and the services being consumed. The OAuth2 server allows the user to authenticate themselves without having to pass their user credentials down to every service the application is going to call on behalf of the user. 


OAuth2 is a token-based security framework. A user authenticates against the OAuth2 server by providing their credentials along with the application that they’re using to access the resource. If the user’s credentials are valid, the OAuth2 server provides a token that can be presented every time a service being used by the user’s application tries to access a protected resource (the microservice). The OAuth2 specification has four types of grants: 
  •  Password 
  • Client credential 
  • Authorization code 
  • Implicit

To set up an OAuth2 authentication server, you need the following Spring Cloud dependencies in the authentication-service/pom.xml file


For Example: You have to Create Project Node Name is: "a143mk-Oauth2-Security" on STS4 Tools.

 

Pom.xml file.

Create AuthServer.java class for use Authorization Server Configuration.



The first thing to note in this listing is the @EnableAuthorizationServer annotation. This annotation tells Spring Cloud that this service will be used as an OAuth2 service and to add several REST-based endpoints that will be used in the OAuth2 authentication and authorization processes.

Like other pieces of the Spring Security framework, to set up users (and their roles), start by extending the WebSecurityConfigurerAdapter class and mark it with the @Configuration annotation.
As such, you need to provide the OAuth2 server a mechanism to authenticate users and return the user information about the authenticating user. This is done by defining two beans in your Spring WebSecurityConfigurerAdapter implementation: authenticationManagerBean() and userDetailsServiceBean(). These two beans are exposed by using the default authentication authenticationManagerBean() and userDetailsServiceBean() methods from the parent WebSecurityConfigurerAdapter class.
you have to Create ConfigWeb.java class.

Run As-> Spring Boot App for Output:


For step by step development working watch the video and learn yourself.