Skip to main content

Posts

Showing posts with the label javaee

Use Client Certificate Authentication with Java and RestTemplate

As a follow up of the  http://gochev.blogspot.com/2019/04/convert-pfx-certificate-to-jks-p12-crt.html  we now have a keystore and a truststore (if anyone needs) and we will use this keystore to send client side authentication using Spring's RestTemplate . First copy your keystore.jks and truststore.jks in your classpath, no one wants absolute paths right ?:) Again a reminder  The difference between truststore and keystore if you are not aware is(quote from the   JSSE ref guide ) :   TrustManager: Determines whether the remote authentication credentials (and thus the connection) should be trusted. KeyManager: Determines which authentication credentials to send to the remote host. The magic happens in the creation of SSLContext. Keep in mind the Spring Boot have a nice RestTemplateBuilder but I will not gonna use it, because someone of you might have an older version or like me, might just use a plain old amazing Spring. If you just want to use the ke...

Introduction to Spring MVC (In Bulgarian)

This is video from the presentation I did for Software University  at Sofia, Bulgaria. Camera : Screen capture : All demos can be downloaded from here https://github.com/gochev/examples/tree/master/SoftUni%20Spring%20MVC%20June%202015 If you missed the event .. don't miss the next one. In Bulgarian Java User Group we do events like this one every month. Information about past and future events can be found here http://java-bg.org/events/

ORM в Java: Hibernate и JPA

A talk about Java and ORM I made at Software University in Bulgaria few months ago. It shows Hibernate (old school stuff) and JPA to as ORM. The talk is in Bulgarian Examples on github can be found here : Hibernate example JPA example

RAD with Spring @SoftUni Conf, March, 2015

This is a video of the presentaiton about Rapid Application Development with Spring that I made at SoftUni conf. The video is in Bulgarian :( ... again :( Example can be found here : Example on github

Software University : Fast REST API with Spring

This is video from the presentation I did for Software University   conf  at Sofia, Bulgaria. And here is the presentation (slideshare) only. All demos can be downloaded from here https://github.com/gochev/examples/tree/master/SoftUni%20Rest%20Spring If you missed the event .. don't miss the next one. In Bulgarian Java User Group we do events like this one every month. Information about past and future events can be found here http://java-bg.org/events/

JavaEE 5 (JSF + JPA + EJB3) using Eclipse

Today I will show you how to create Enterprise Application using Java EE 5 and GlassFish. I will use - Eclipse 3.5 + WTP - GlassFish v. 2.1 - JSF Mojarra implementation. - EJB 3.0. - JPA Toplink essentials implementation. - MySQL No NetBeans or JDeveloper magic involved :) The prerequirement is: Add datasource in glassfish. Read this how you can make this here: http://gochev.blogspot.com/2009/10/creating-datasource-in-glassfish-v-21.html 1) First you need to add glassfish in your eclipse. - Go to Servers View - Right Click, New - Choose GlassFish v 2.1 if you dont have glassfish click on Download additional adapters link choose glassfish wait and restart eclipse. Than try again. 2) Create the database CREATE TABLE ` lesson ` . ` USERS ` ( ` id ` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, ` username ` VARCHAR ( 45 ) NOT NULL , ` password ` VARCHAR ( 45 ) NOT NULL , ` name ` VARCHAR ( 45 ) NOT NULL , PRIMARY KEY ( ` id ` ) ) ENGINE = InnoDB...

Creating DataSource in GlassFish v. 2.1

I will show you how to create a DataSource in GlassFish version 2.1 because there were a lot of properties and I had a lot of problems when I've try to register datasource in glassfish for the first time. 1) You have to download JDBC driver for your database. For example I will use MySQL and I will use Connector/J driver that you can download from mysql official web site. 2) Place the JDBC driver in for example D:\glassfishv21\domains\domain1\lib\ext for example my driver is mysql-connector-java-5.0.4.jar 3) Start the domain for example domain1 (asadmin start-domain domain1) 4) go to http://localhost:4848 and login as admin. By default the username is 'admin' and the password is 'adminadmin' 5) go to Resources/JDBC/Connection Pools -First we will create a connection pool. Click the 'NEW' button -Than you must type: - Name: of the connection pool for example MySQL Lessson - Resource Type: javax.sql.ConnectionPoolDataSource - Database Vendor:...

CalcCaptcha

This is the source code for a simple captcha that looks like this : The servlet is easy customizable so you can easy edit it or write your own. The Captcha is based on the 100 lines JSP captcha explained here : http://www.jroller.com/mlconnor/entry/simple_captcha_jsp package com . joke . web . servetls ; import org.apache.commons.logging.Log ; import org.apache.commons.logging.LogFactory ; import com.joke.service.Constants ; import java.awt.Color ; import java.awt.Font ; import java.awt.FontMetrics ; import java.awt.Graphics2D ; import java.awt.RenderingHints ; import java.awt.geom.AffineTransform ; import java.awt.image.BufferedImage ; import java.io.IOException ; import java.util.Iterator ; import javax.imageio.IIOImage ; import javax.imageio.ImageIO ; import javax.imageio.ImageWriteParam ; import javax.imageio.ImageWriter ; import javax.servlet.ServletException ; import javax.servlet.http.HttpServlet ; import javax.servlet.http.HttpServletRequest ; import java...