Home » security » Page 4

Tag Archives: security

Generate Keys from DSA parameters example

Bipartite Graph

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

Bipartite Graph

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

Bipartite Graph

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

Bipartite Graph

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

Bipartite Graph

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

Bipartite Graph

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

Bipartite Graph

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 »