Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java 21 Upgrade #45

Merged
merged 3 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .devcontainer/development/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
FROM openjdk:11-jdk-slim
FROM openjdk:21-jdk-slim

# Set environment variables for Tomcat
ENV CATALINA_HOME /usr/local/tomcat
ENV PATH $CATALINA_HOME/bin:$PATH
ENV CATALINA_OPTS="--add-opens java.base/java.net=ALL-UNNAMED"

# Copy Tomcat installation from the official Tomcat image
COPY --from=tomcat:9.0.97 /usr/local/tomcat $CATALINA_HOME
Expand Down
21 changes: 10 additions & 11 deletions src/main/java/oscar/login/jaas/BaseLoginModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

import java.io.IOException;
import java.security.Principal;
import java.security.acl.Group;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
Expand Down Expand Up @@ -66,11 +65,11 @@ public class BaseLoginModule implements LoginModule {

private OscarPrincipal principal;

private Group rolesGroup;
private OscarGroup rolesGroup;

private Group callerPrincipal;
private OscarGroup callerPrincipal;

private Group authPrincipal;
private OscarGroup authPrincipal;

private boolean authorizationEnabled = false;

Expand Down Expand Up @@ -164,7 +163,7 @@ public boolean login() throws LoginException {
authPrincipal.addMember(getPrincipal());
setAuthPrincipal(authPrincipal);

Group rolesGroup = new OscarGroup("Roles");
OscarGroup rolesGroup = new OscarGroup("Roles");
for (OscarRole role : getRoles(loginName)) {
rolesGroup.addMember(role);
}
Expand Down Expand Up @@ -275,27 +274,27 @@ public void setSharedState(Map<String, ?> sharedState) {
this.sharedState = sharedState;
}

public Group getRolesGroup() {
public OscarGroup getRolesGroup() {
return rolesGroup;
}

public void setRolesGroup(Group rolesGroup) {
public void setRolesGroup(OscarGroup rolesGroup) {
this.rolesGroup = rolesGroup;
}

public Group getCallerPrincipal() {
public OscarGroup getCallerPrincipal() {
return callerPrincipal;
}

public void setCallerPrincipal(Group callerPrincipal) {
public void setCallerPrincipal(OscarGroup callerPrincipal) {
this.callerPrincipal = callerPrincipal;
}

public Group getAuthPrincipal() {
public OscarGroup getAuthPrincipal() {
return authPrincipal;
}

public void setAuthPrincipal(Group authPrincipal) {
public void setAuthPrincipal(OscarGroup authPrincipal) {
this.authPrincipal = authPrincipal;
}

Expand Down
30 changes: 24 additions & 6 deletions src/main/java/oscar/login/jaas/OscarGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,12 @@

import java.io.Serializable;
import java.security.Principal;
import java.security.acl.Group;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.List;

public class OscarGroup implements Group, Serializable {
public class OscarGroup implements Principal, Serializable {

private static final long serialVersionUID = 1L;

Expand All @@ -56,25 +55,44 @@ public void setName(String name) {
this.name = name;
}

@Override
/**
* Adds a member to the group.
*
* @param user the Principal to be added
* @return true whether the member was added
*/
public boolean addMember(Principal user) {
if (!principals.contains(user))
principals.add(user);
return true;
}

@Override
/**
* Removes a member from the group.
*
* @param user the Principal to be removed
* @return true whether the member was removed
*/
public boolean removeMember(Principal user) {
principals.remove(user);
return true;
}

@Override
/**
* Checks if a Principal is a member of the group.
*
* @param member the Principal to be checked
* @return true if the member exists in the group
*/
public boolean isMember(Principal member) {
return principals.contains(member);
}

@Override
/**
* Returns an enumeration of the group's members.
*
* @return an Enumeration of the members
*/
public Enumeration<? extends Principal> members() {
return Collections.enumeration(principals);
}
Expand Down
Loading