-
Notifications
You must be signed in to change notification settings - Fork 460
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4301 from darranl/WFCORE-5087
[WFCORE-5087] Add support for the -secmgr command line argument,
- Loading branch information
Showing
5 changed files
with
118 additions
and
2 deletions.
There are no files selected for viewing
84 changes: 84 additions & 0 deletions
84
bootable-jar/boot/src/main/java/org/wildfly/core/jar/boot/BootablePolicy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source. | ||
* Copyright 2014 Red Hat, Inc., and individual contributors | ||
* as indicated by the @author tags. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/* | ||
* This is a direct copy of org.jboss.modules.ModulesPolicy from jboss-modules as the bootstrap of | ||
* bootable jar is very similar to a jboss-modules bootstrap. | ||
*/ | ||
|
||
package org.wildfly.core.jar.boot; | ||
|
||
import java.security.AllPermission; | ||
import java.security.CodeSource; | ||
import java.security.Permission; | ||
import java.security.PermissionCollection; | ||
import java.security.Permissions; | ||
import java.security.Policy; | ||
import java.security.ProtectionDomain; | ||
import java.security.Provider; | ||
|
||
final class BootablePolicy extends Policy { | ||
|
||
private static final AllPermission ALL_PERMISSION = new AllPermission(); | ||
|
||
static final Permissions DEFAULT_PERMISSION_COLLECTION = getAllPermission(); | ||
|
||
private static final CodeSource ourCodeSource = BootablePolicy.class.getProtectionDomain().getCodeSource(); | ||
|
||
private final Policy policy; | ||
|
||
private static Permissions getAllPermission() { | ||
final Permissions permissions = new Permissions(); | ||
permissions.add(ALL_PERMISSION); | ||
return permissions; | ||
} | ||
|
||
BootablePolicy(final Policy policy) { | ||
this.policy = policy; | ||
} | ||
|
||
public Provider getProvider() { | ||
return policy.getProvider(); | ||
} | ||
|
||
public String getType() { | ||
return policy.getType(); | ||
} | ||
|
||
public Parameters getParameters() { | ||
return policy.getParameters(); | ||
} | ||
|
||
public PermissionCollection getPermissions(final CodeSource codesource) { | ||
return codesource != null && codesource.equals(ourCodeSource) ? getAllPermission() : policy.getPermissions(codesource); | ||
} | ||
|
||
public PermissionCollection getPermissions(final ProtectionDomain domain) { | ||
final CodeSource codeSource = domain.getCodeSource(); | ||
return codeSource != null && codeSource.equals(ourCodeSource) ? getAllPermission() : policy.getPermissions(domain); | ||
} | ||
|
||
public boolean implies(final ProtectionDomain domain, final Permission permission) { | ||
final CodeSource codeSource = domain.getCodeSource(); | ||
return codeSource != null && codeSource.equals(ourCodeSource) || policy.implies(domain, permission); | ||
} | ||
|
||
public void refresh() { | ||
policy.refresh(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters