Class SecurityPolicyExamples
java.lang.Object
net.jrodolfo.java_evolution.java02.security.SecurityPolicyExamples
Demonstrates the Java 2 security-policy model with ordinary permission
objects.
Java 2 generalized security around code sources, protection domains,
permissions, and policy grants. This example models those concepts directly
without installing a SecurityManager or loading a policy file, because
Security Manager based enforcement is deprecated and disabled in modern Java.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks whether the domain implies the granted connect permission.booleanChecks whether the same domain implies a different, ungranted action.Creates a protection domain with one explicit permission grant.Exposes the static permission collection used by the protection domain.Explains the core Java 2 security model in one sentence.Explains the modern boundary of this example.Creates a synthetic code source representing where code came from.
-
Constructor Details
-
SecurityPolicyExamples
public SecurityPolicyExamples()
-
-
Method Details
-
trustedCodeSource
Creates a synthetic code source representing where code came from.- Returns:
- a code source for a trusted application location
- Throws:
MalformedURLException- if the synthetic URI cannot be converted to a URL
-
domainWithConnectPermission
Creates a protection domain with one explicit permission grant.- Returns:
- a protection domain that can connect to one service endpoint
- Throws:
MalformedURLException- if the synthetic code source cannot be created
-
canConnectToApi
Checks whether the domain implies the granted connect permission.- Returns:
truebecause the permission collection grants connect access- Throws:
MalformedURLException- if the synthetic code source cannot be created
-
cannotListenOnApiPort
Checks whether the same domain implies a different, ungranted action.- Returns:
falsebecause listen access was not granted- Throws:
MalformedURLException- if the synthetic code source cannot be created
-
grantedPermissions
Exposes the static permission collection used by the protection domain.- Returns:
- the static permission collection
- Throws:
MalformedURLException- if the synthetic code source cannot be created
-
modelSummary
Explains the core Java 2 security model in one sentence.- Returns:
- a short model summary
-
modernBoundary
Explains the modern boundary of this example.- Returns:
- a short boundary explanation
-