org.jboss.security.SimpleGroup is not working in java 17

655 views
Skip to first unread message

pba...@gmail.com

unread,
Jul 11, 2023, 8:27:15 AM7/11/23
to WildFly
Hi,

In java 11 we are using org.jboss.security.SimpleGroup which is working as expected. What is alternate way to use this in Java 17.

Regards,
Poornima

Diana Krepinska

unread,
Jul 13, 2023, 9:03:22 AM7/13/23
to WildFly
Hello, the package org.jboss.security is from the legacy security which does not work with JDK 17. Migration to elytron subsystem is required to use JDK 17. 

You did not provide any details about why you used a SimpleGroup before, so it is not clear what should be an alternative. You can look at the WF documentation to get started with the migration to elytron https://docs.wildfly.org/28/WildFly_Elytron_Security.html#Migrate_Legacy_Security_to_Elytron_Security

pba...@gmail.com

unread,
Jul 14, 2023, 1:08:58 AM7/14/23
to WildFly
Thank you so much your reply, will check the attahced link

pba...@gmail.com

unread,
Jul 14, 2023, 1:22:27 AM7/14/23
to WildFly
Hi Diana,

We are using this Simple group like this in our code.
Subject subject = getSecuritySubject();
        if ((subject == null) || (subject.getPrincipals() == null)) {
            return null;
        }
        for (Principal principal : subject.getPrincipals()) {
            if (principal.getName().equals(PRINCIPAL_CALLER_PRINCIPAL)) {
                SimpleGroup simpleGroup = (SimpleGroup) principal;
                Enumeration<Principal> members = simpleGroup.members();
                if (!members.hasMoreElements()) {
                    return null;
                }
                Principal caller = members.nextElement();
                String name = caller.getName();
                if (members.hasMoreElements()) {
                    logger.error("CallerPrincipal has more than 1 member");
                    return null;
                }
                return name;
            }
        }


Let me know if you need for info.

Regards,
Poornima

Diana Krepinska

unread,
Jul 18, 2023, 1:33:44 PM7/18/23
to WildFly
Hi Poornima,

the SimpleGroup is a class from the legacy security. Legacy security does not work with JDK17. Do you have elements defined in the security subsystem of your server configuration? If you wish to use JDK 17 you have to migrate that configuration to the elytron subsystem before you can implement any workaround for this piece of code. You can follow the docs link to get started https://docs.wildfly.org/28/WildFly_Elytron_Security.html#Migrate_Legacy_Security_to_Elytron_Security .
Reply all
Reply to author
Forward
0 new messages