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

MIR-1416 pin glassfish jaxb-runtime to MIRAccessKeyPairTransformer #1095

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
5 changes: 5 additions & 0 deletions mir-module/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,11 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.hibernate.orm</groupId>
<artifactId>hibernate-hikaricp</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,19 @@
package org.mycore.mir.authorization.accesskeys;

import java.io.IOException;
import java.util.Map;

import org.jdom2.Document;
import org.jdom2.Element;
import org.jdom2.transform.JDOMSource;
import org.mycore.common.MCRException;
import org.mycore.common.config.MCRConfiguration2;
import org.mycore.common.content.MCRJAXBContent;
import org.mycore.datamodel.metadata.MCRObjectID;
import org.mycore.mir.authorization.accesskeys.backend.MIRAccessKeyPair;

import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.JAXBContextFactory;
import jakarta.xml.bind.JAXBException;
import jakarta.xml.bind.Unmarshaller;

Expand All @@ -54,8 +57,13 @@ private MIRAccessKeyPairTransformer() {

private static JAXBContext initContext() {
try {
return JAXBContext.newInstance(MIRAccessKeyPair.class.getPackage().getName(),
MIRAccessKeyPair.class.getClassLoader());
String factoryProperty = "MIR.AccessKey.JAXBContextFactory";
JAXBContextFactory jaxbContextFactory =
MCRConfiguration2.<JAXBContextFactory>getInstanceOf(factoryProperty)
.orElseThrow(() -> MCRConfiguration2.createConfigurationException(factoryProperty));
JAXBContext jaxbContext = jaxbContextFactory.createContext(MIRAccessKeyPair.class.getPackage().getName(),
MIRAccessKeyPair.class.getClassLoader(), Map.of());
return jaxbContext;
} catch (final JAXBException e) {
throw new MCRException("Could not instantiate JAXBContext.", e);
}
Expand Down Expand Up @@ -121,8 +129,9 @@ public static MIRAccessKeyPair buildAccessKeyPair(final MCRObjectID mcrObjectId,
}
try {
final Unmarshaller unmarshaller = JAXB_CONTEXT.createUnmarshaller();
return MIRAccessKeyPair.fromServiceFlags(mcrObjectId,
(MIRAccessKeyPair.ServiceFlags) unmarshaller.unmarshal(new JDOMSource(element)));
MIRAccessKeyPair.ServiceFlags serviceFlags =
unmarshaller.unmarshal(new JDOMSource(element.clone()), MIRAccessKeyPair.ServiceFlags.class).getValue();
return MIRAccessKeyPair.fromServiceFlags(mcrObjectId, serviceFlags);
} catch (final JAXBException e) {
throw new MCRException("Exception while transforming Element to MIRAccessKeyPair.", e);
}
Expand Down
1 change: 1 addition & 0 deletions mir-module/src/main/resources/config/mir/mycore.properties
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ MCR.Access.AddDerivateDefaultRule=false
MCR.Access.AddObjectDefaultRule=false
MCR.ACL.AccessKey.Strategy.AllowedObjectTypes=mods
MCR.ACL.AccessKey.Strategy.AllowedSessionPermissionTypes=
MIR.AccessKey.JAXBContextFactory=org.glassfish.jaxb.runtime.v2.JAXBContextFactory

##############################################################################
# Configure new fact based ACL Checking #
Expand Down
Loading