-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed JmacHttpsTest - created XmlPrincipalName with more tolerant equals
- Note that the equals method is not symmetric here - Exousia uses Set.contains -> equals to check the authorization. - I had to improve logs and code on several places to find out what is happening Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
- Loading branch information
Showing
11 changed files
with
248 additions
and
254 deletions.
There are no files selected for viewing
75 changes: 75 additions & 0 deletions
75
...dol/src/main/java/com/sun/enterprise/deployment/node/runtime/common/XmlPrincipalName.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,75 @@ | ||
/* | ||
* Copyright (c) 2024 Contributors to the Eclipse Foundation. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0, which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the | ||
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License, | ||
* version 2 with the GNU Classpath Exception, which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
*/ | ||
|
||
package com.sun.enterprise.deployment.node.runtime.common; | ||
|
||
import java.io.Serializable; | ||
import java.security.Principal; | ||
import java.util.Objects; | ||
|
||
import org.glassfish.security.common.UserPrincipal; | ||
|
||
/** | ||
* {@link Principal} loaded from XML descriptor. | ||
* When the equals method is used, it compares just principal names and that the other object | ||
* is an {@link Principal} instance too. | ||
*/ | ||
// Must be UserPrincipal, because RoleMapper.internalAssignRole knows just that and Group. | ||
public class XmlPrincipalName implements UserPrincipal, Serializable { | ||
|
||
private static final long serialVersionUID = -640182254691955451L; | ||
|
||
private final String name; | ||
|
||
/** | ||
* @param name must not be null. | ||
*/ | ||
public XmlPrincipalName(String name) { | ||
this.name = Objects.requireNonNull(name, "XML principal-name element must not be null."); | ||
} | ||
|
||
|
||
@Override | ||
public String getName() { | ||
return name; | ||
} | ||
|
||
|
||
@Override | ||
public int hashCode() { | ||
return name.hashCode(); | ||
} | ||
|
||
|
||
/** | ||
* We match user principals just by name. | ||
* This is used in Jakarta Security to resolve authorisation. | ||
*/ | ||
@Override | ||
public boolean equals(Object o) { | ||
if (o instanceof Principal) { | ||
Principal other = (Principal) o; | ||
return getName().equals(other.getName()); | ||
} | ||
return false; | ||
} | ||
|
||
|
||
@Override | ||
public String toString() { | ||
return getClass().getSimpleName() + "[" + getName() + "]"; | ||
} | ||
} |
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
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
Oops, something went wrong.