From 27f8c5a67622f27d580c2c7c4cc53d7dec77fd01 Mon Sep 17 00:00:00 2001 From: kohsuke Date: Tue, 30 Sep 2008 00:46:55 +0000 Subject: [PATCH] Fixed the serialized form of project-based matrix authorization strategy. git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@12421 71c3de6d-444a-0410-be80-ed276b4c234a --- .../ProjectMatrixAuthorizationStrategy.java | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/core/src/main/java/hudson/security/ProjectMatrixAuthorizationStrategy.java b/core/src/main/java/hudson/security/ProjectMatrixAuthorizationStrategy.java index 4c96dfdf52..5fd3a8a811 100644 --- a/core/src/main/java/hudson/security/ProjectMatrixAuthorizationStrategy.java +++ b/core/src/main/java/hudson/security/ProjectMatrixAuthorizationStrategy.java @@ -3,6 +3,11 @@ package hudson.security; import hudson.model.AbstractProject; import hudson.model.Descriptor; import hudson.model.Jobs; +import hudson.util.RobustReflectionConverter; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.converters.UnmarshallingContext; +import com.thoughtworks.xstream.mapper.Mapper; +import com.thoughtworks.xstream.core.JVM; /** * {@link GlobalMatrixAuthorizationStrategy} plus per-project ACL. @@ -39,6 +44,32 @@ public class ProjectMatrixAuthorizationStrategy extends GlobalMatrixAuthorizatio } }; + public static class ConverterImpl extends GlobalMatrixAuthorizationStrategy.ConverterImpl { + private RobustReflectionConverter ref; + + public ConverterImpl(Mapper m) { + ref = new RobustReflectionConverter(m,new JVM().bestReflectionProvider()); + } + + protected GlobalMatrixAuthorizationStrategy create() { + return new GlobalMatrixAuthorizationStrategy(); + } + + public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) { + String name = reader.peekNextChild(); + if(name!=null && name.equals("permission")) + // the proper serialization form + return super.unmarshal(reader, context); + else + // remain compatible with earlier problem where we used reflection converter + return ref.unmarshal(reader,context); + } + + public boolean canConvert(Class type) { + return type==ProjectMatrixAuthorizationStrategy.class; + } + } + static { LIST.add(DESCRIPTOR); Jobs.PROPERTIES.add(AuthorizationMatrixProperty.DESCRIPTOR); -- GitLab