Skip to content

Commit

Permalink
Merge pull request #6320 from soul2zimate/WFCORE-7134-main
Browse files Browse the repository at this point in the history
[WFCORE-7134] Remove ModuleIdentifier use in the elytron subsystem
  • Loading branch information
yersan authored Jan 20, 2025
2 parents 8dad205 + 88f67ae commit 1c1ee1f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
*/
package org.wildfly.extension.elytron;

import org.jboss.as.controller.ModuleIdentifierUtil;
import org.jboss.as.controller.SimpleAttributeDefinition;
import org.jboss.as.controller.SimpleAttributeDefinitionBuilder;
import org.jboss.as.controller.StringListAttributeDefinition;
import org.jboss.dmr.ModelType;
import org.jboss.modules.Module;
import org.jboss.modules.ModuleIdentifier;
import org.jboss.modules.ModuleLoadException;

/**
Expand Down Expand Up @@ -43,8 +43,7 @@ class ClassLoadingAttributeDefinitions {
static ClassLoader resolveClassLoader(String module) throws ModuleLoadException {
Module current = Module.getCallerModule();
if (module != null && current != null) {
ModuleIdentifier mi = ModuleIdentifier.fromString(module);
current = current.getModule(mi);
current = current.getModule(ModuleIdentifierUtil.canonicalModuleIdentifier(module));
}

return current != null ? current.getClassLoader() : ClassLoadingAttributeDefinitions.class.getClassLoader();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import org.jboss.as.controller.AbstractAddStepHandler;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.ModuleIdentifierUtil;
import org.jboss.as.controller.ObjectTypeAttributeDefinition;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
Expand All @@ -40,7 +41,6 @@
import org.jboss.dmr.ModelType;
import org.jboss.dmr.Property;
import org.jboss.modules.Module;
import org.jboss.modules.ModuleIdentifier;
import org.jboss.modules.ModuleLoadException;
import org.jboss.msc.service.ServiceBuilder;
import org.jboss.msc.service.ServiceController;
Expand Down Expand Up @@ -160,9 +160,8 @@ private static TrivialService.ValueSupplier<DirContextSupplier> obtainDirContext
if(moduleName != null && !"".equals(moduleName)){
try {
Module cm = Module.getCallerModule();
ModuleIdentifier mi = ModuleIdentifier.create(moduleName);
//module = Module.getCallerModule().getModule(ModuleIdentifier.create(moduleName));
module = cm.getModule(mi);
module = cm.getModule(ModuleIdentifierUtil.canonicalModuleIdentifier(moduleName));
} catch (ModuleLoadException e) {
throw ElytronSubsystemMessages.ROOT_LOGGER.unableToLoadModule(moduleName, e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.jboss.as.controller.AttributeParser;
import org.jboss.as.controller.AttributeParsers;
import org.jboss.as.controller.ModelVersion;
import org.jboss.as.controller.ModuleIdentifierUtil;
import org.jboss.as.controller.ObjectListAttributeDefinition;
import org.jboss.as.controller.ObjectTypeAttributeDefinition;
import org.jboss.as.controller.OperationContext;
Expand All @@ -41,7 +42,6 @@
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.ModelType;
import org.jboss.modules.Module;
import org.jboss.modules.ModuleIdentifier;
import org.jboss.modules.ModuleLoadException;
import org.jboss.msc.service.ServiceBuilder;
import org.jboss.msc.service.ServiceName;
Expand Down Expand Up @@ -404,9 +404,8 @@ static Permissions createPermissions(List<Permission> permissionsList) throws St
private static java.security.Permission createPermission(Permission permission) throws StartException {
Module currentModule = Module.getCallerModule();
if (permission.getModule() != null && currentModule != null) {
ModuleIdentifier mi = ModuleIdentifier.fromString(permission.getModule());
try {
currentModule = currentModule.getModule(mi);
currentModule = currentModule.getModule(permission.getModule());
} catch (ModuleLoadException e) {
// If we cannot load it, it can never be checked.
throw ElytronSubsystemMessages.ROOT_LOGGER.invalidPermissionModule(permission.getModule(), e);
Expand All @@ -432,7 +431,7 @@ static class Permission {

Permission(final String className, final String module, final String targetName, final String action) {
this.className = className;
this.module = module;
this.module = module != null ? ModuleIdentifierUtil.canonicalModuleIdentifier(module) : module;
this.targetName = targetName;
this.action = action;
}
Expand Down

0 comments on commit 1c1ee1f

Please sign in to comment.