Do you want to know how to develop your skillset to become a Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you our best selling eBooks for FREE!

 

1. JPA Mini Book

2. JVM Troubleshooting Guide

3. JUnit Tutorial for Unit Testing

4. Java Annotations Tutorial

5. Java Interview Questions

 

and many more ....

 

 

Generate Public/Private key pairs for DSA DH RSA algorithm example

With this example we are going to demonstrate how to generate private/public key pairs for the DSA, the DH and the RSA algorithms. In short, to generate key pairs for these three algorithms you should: Create a KeyPairGenerator for the DSA algorithm, using the getInstance(String algorithm) API method and initialize it with a 1024-bit key size. Generate the KeyPair, with ...

Read More »

Generate Keys from DSA parameters example

This is an example of how to generate keys from the DSA Parameters in Java. Using the DSA parameters to generate keys implies that you should: Create five BigInteger Objects, to be used as the DSA Parameters, the prime, the subPrime, the base and the private and public keys. Create a new KeyFactory for the DSA algorithm. Create a DSAPrivateKeySpec, ...

Read More »

Get all permissions granted to a loaded class example

With this example we are going to demonstrate how to get all permissions granted to a loaded Class in Java. In short, to get the permissions granted to a Class that is loaded you should: Get the ProtectionDomain of the Class. Create a new ProtectionDomain, using the getProtectionDomain() API method of the Class. Create a PermissionCollection, by getting the permissions ...

Read More »

Enable the security manager example

This is an example of how to enable the Security Manager in Java. Since no security manager is enabled by default, and all security checks to protected resources and operations are disabled, enabling the security manager implies that you should: Create a new SecurityManager Object. Invoke the setSecurityManager(SecurityManager s) API method of the System, in order to enable the new ...

Read More »

Check if a permission implies another permission example

In this example we shall show you how to check if a permission to a file implies another permission. To check the permissions to a specific file one should perform the following steps: Create a new FilePermission with a given String as path and another given String as actions. Create a second FilePermission with a another String as path and ...

Read More »

Control access to an Object example

With this example we are going to demonstrate how to control access to an Object in Java. In short, to control access to an Object you should: Create a Guard, which is an object that is used to protect access to another object, with the String name of the system property, and a String of comma-separated actions granted on the ...

Read More »

Check read/write permission for a directory example

This is an example of how to check read/write permission for a directory. Checking read/write permission for a directory implies that you should: Create a FilePermission for the pathname of the directory, and a comma-separated list of the actions granted on the directory. Invoke the checkPermission(Permission perm) API method of the AccessController, in order to check whether the access request ...

Read More »

Generate a secure random number example

In this example we shall show you how to generate a secure random number. To generate secure random numbers one should perform the following steps: Create a SecureRandom for the SHA1PRNG algorithm, which is a secure number generator, using the getInstance(String algorithm) API method. Create a new byte array with a specific length (128 in the example). Invoke the nextBytes(byte[] ...

Read More »

Determine if a ResultSet is updatable

With this example we are going to demonstrate how to determine if a ResultSet is updatable. An updatable ResultSet is a table of data representing a database result set, that can be updated by others. In short, to determine if a ResultSet is updatable you should: Load the JDBC Driver, using the forName(String className) API method of the Class. In ...

Read More »