Home » Core Java » security (page 3)

security

AWTPermission example

This is an example of how to create an AWTPermission. AWTPermissions are permissions granted for the AWT Package of Java. In the AWTPermission API there is a list of all the possible AWTPermission target names, and for each one, there is a description of what the permission allows and a discussion of the risks of granting code the permission. In ...

Read More »

AccessController example

In this example we shall show you how to create and check an access permission to a file, using the AccessController Class. To create a new permission to a file and check the access permission of a file, one should perform the following steps: Create a new FilePermission with the specified path of the file and action mode of the ...

Read More »

Signing a Java Object example

With this example we are going to demonstrate how to sign a Java Object. In particular, we will use the Digital Signature Algorithm (DSA) to create a 1024-bit key pair and then sign a Serializable Object, using the key pair Signature. In short, to sign an Object in Java you should: Create a KeyPairGenerator for the DSA algorithm and initialize ...

Read More »

Get DSA parameters of a key pair example

This is an example of how to get DSA parameters of a key pair. In short, to get the DSA parameters of a key pair you should: Generate a 1024-bit Digital Signature Algorithm (DSA) key pair. Create a KeyPairGenerator for the DSA algorithm and initialize it with 1024-bit key size. Generate the KeyPair. Get the private and public key from ...

Read More »

Get bytes of a key pair example

In this example we shall show you how to get the bytes of a key pair in Java. To get the bytes of a key pair one should perform the following steps: Create a KeyPairGenerator for the DSA algorithm and initialize it with a 1024-bit key size. Generate the KeyPair, with the genKeyPair() API method of the KeyPairGenerator. Get the ...

Read 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 »