feat(jdk8): move files to new folder to avoid resources compiled.
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api.policy;
|
||||
|
||||
import com.sun.xml.internal.ws.policy.EffectiveAlternativeSelector;
|
||||
import com.sun.xml.internal.ws.policy.EffectivePolicyModifier;
|
||||
import com.sun.xml.internal.ws.policy.PolicyException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Fabian Ritzmann
|
||||
*/
|
||||
public class AlternativeSelector extends EffectiveAlternativeSelector {
|
||||
|
||||
public static void doSelection(final EffectivePolicyModifier modifier) throws PolicyException {
|
||||
final ValidationProcessor validationProcessor = ValidationProcessor.getInstance();
|
||||
selectAlternatives(modifier, validationProcessor);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api.policy;
|
||||
|
||||
import com.sun.xml.internal.ws.policy.Policy;
|
||||
import com.sun.xml.internal.ws.policy.sourcemodel.PolicyModelGenerator;
|
||||
import com.sun.xml.internal.ws.policy.sourcemodel.PolicySourceModel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Fabian Ritzmann
|
||||
*/
|
||||
public abstract class ModelGenerator extends PolicyModelGenerator {
|
||||
|
||||
private static final SourceModelCreator CREATOR = new SourceModelCreator();
|
||||
|
||||
/**
|
||||
* This private constructor avoids direct instantiation from outside the class.
|
||||
*/
|
||||
private ModelGenerator() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Factory method that returns a ModelGenerator instance.
|
||||
*
|
||||
* @return A ModelGenerator instance.
|
||||
*/
|
||||
public static PolicyModelGenerator getGenerator() {
|
||||
return PolicyModelGenerator.getCompactGenerator(CREATOR);
|
||||
}
|
||||
|
||||
|
||||
protected static class SourceModelCreator extends PolicySourceModelCreator {
|
||||
|
||||
@Override
|
||||
protected PolicySourceModel create(Policy policy) {
|
||||
return SourceModel.createPolicySourceModel(policy.getNamespaceVersion(),
|
||||
policy.getId(), policy.getName());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api.policy;
|
||||
|
||||
import com.sun.xml.internal.ws.config.management.policy.ManagementAssertionCreator;
|
||||
import com.sun.xml.internal.ws.policy.PolicyException;
|
||||
import com.sun.xml.internal.ws.policy.privateutil.PolicyLogger;
|
||||
import com.sun.xml.internal.ws.policy.sourcemodel.PolicyModelTranslator;
|
||||
import com.sun.xml.internal.ws.policy.spi.PolicyAssertionCreator;
|
||||
import com.sun.xml.internal.ws.resources.ManagementMessages;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* This class provides a method for translating a PolicySourceModel structure to a
|
||||
* normalized Policy expression. The resulting Policy is disconnected from its model,
|
||||
* thus any additional changes in the model will have no effect on the Policy expression.
|
||||
*
|
||||
* @author Fabian Ritzmann
|
||||
*/
|
||||
public class ModelTranslator extends PolicyModelTranslator {
|
||||
|
||||
private static final PolicyLogger LOGGER = PolicyLogger.getLogger(ModelTranslator.class);
|
||||
|
||||
private static final PolicyAssertionCreator[] JAXWS_ASSERTION_CREATORS = {
|
||||
new ManagementAssertionCreator()
|
||||
};
|
||||
|
||||
private static final ModelTranslator translator;
|
||||
private static final PolicyException creationException;
|
||||
|
||||
static {
|
||||
ModelTranslator tempTranslator = null;
|
||||
PolicyException tempException = null;
|
||||
try {
|
||||
tempTranslator = new ModelTranslator();
|
||||
} catch (PolicyException e) {
|
||||
tempException = e;
|
||||
LOGGER.warning(ManagementMessages.WSM_1007_FAILED_MODEL_TRANSLATOR_INSTANTIATION(), e);
|
||||
} finally {
|
||||
translator = tempTranslator;
|
||||
creationException = tempException;
|
||||
}
|
||||
}
|
||||
|
||||
private ModelTranslator() throws PolicyException {
|
||||
super(Arrays.asList(JAXWS_ASSERTION_CREATORS));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method returns thread-safe policy model translator instance.
|
||||
*
|
||||
* @return A policy model translator instance.
|
||||
* @throws PolicyException If instantiating a PolicyAssertionCreator failed.
|
||||
*/
|
||||
public static ModelTranslator getTranslator() throws PolicyException {
|
||||
if (creationException != null) {
|
||||
throw LOGGER.logSevereException(creationException);
|
||||
}
|
||||
else {
|
||||
return translator;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api.policy;
|
||||
|
||||
import com.sun.xml.internal.ws.policy.sourcemodel.PolicyModelGenerator;
|
||||
import com.sun.xml.internal.ws.policy.sourcemodel.PolicySourceModel;
|
||||
import com.sun.xml.internal.ws.policy.sourcemodel.XmlPolicyModelUnmarshaller;
|
||||
import com.sun.xml.internal.ws.policy.sourcemodel.wspolicy.NamespaceVersion;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Fabian Ritzmann
|
||||
*/
|
||||
public class ModelUnmarshaller extends XmlPolicyModelUnmarshaller {
|
||||
|
||||
private static final ModelUnmarshaller INSTANCE = new ModelUnmarshaller();
|
||||
|
||||
/**
|
||||
* This private constructor avoids direct instantiation from outside the class.
|
||||
*/
|
||||
private ModelUnmarshaller() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Factory method that returns a {@link ModelUnmarshaller} instance.
|
||||
*
|
||||
* @return {@link PolicyModelGenerator} instance
|
||||
*/
|
||||
public static ModelUnmarshaller getUnmarshaller() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PolicySourceModel createSourceModel(NamespaceVersion nsVersion, String id, String name) {
|
||||
return SourceModel.createSourceModel(nsVersion, id, name);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api.policy;
|
||||
|
||||
import com.sun.xml.internal.ws.policy.PolicyMap;
|
||||
import com.sun.xml.internal.ws.policy.PolicyMapMutator;
|
||||
import com.sun.xml.internal.ws.api.server.Container;
|
||||
import com.sun.istack.internal.Nullable;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import javax.xml.ws.WebServiceException;
|
||||
|
||||
/**
|
||||
* PolicyResolver will be used to resolve the PolicyMap created by configuration understood by JAX-WS.
|
||||
*
|
||||
* Extensions of this can return effective PolicyMap after merge policies from other configurations.
|
||||
* @author Rama Pulavarthi
|
||||
*/
|
||||
public interface PolicyResolver {
|
||||
/**
|
||||
* Creates a PolicyResolver
|
||||
*
|
||||
* @param context
|
||||
* ServerContext that captures information useful for resolving Policy on server-side
|
||||
*
|
||||
* @return
|
||||
* A PolicyMap with single policy alternative that gets created after consulting various configuration models.
|
||||
*
|
||||
* @throws WebServiceException
|
||||
* If resolution failed
|
||||
*/
|
||||
PolicyMap resolve(ServerContext context) throws WebServiceException;
|
||||
|
||||
/**
|
||||
* Creates a PolicyResolver
|
||||
*
|
||||
* @param context
|
||||
* ServerContext that captures information useful for resolving Policy on client-side
|
||||
*
|
||||
* @return
|
||||
* A PolicyMap with single policy alternative that gets created after consulting various configuration models.
|
||||
*
|
||||
* @throws WebServiceException
|
||||
* If resolution failed
|
||||
*/
|
||||
PolicyMap resolve(ClientContext context) throws WebServiceException;
|
||||
|
||||
public class ServerContext {
|
||||
private final PolicyMap policyMap;
|
||||
private final Class endpointClass;
|
||||
private final Container container;
|
||||
private final boolean hasWsdl;
|
||||
private final Collection<PolicyMapMutator> mutators;
|
||||
|
||||
/**
|
||||
* The abstraction of PolicyMap is not finalized, and will change in few months. It is highly discouraged to use
|
||||
* PolicyMap until it is finalized.
|
||||
*
|
||||
* In presence of WSDL, JAX-WS by default creates PolicyMap from Policy Attachemnts in WSDL.
|
||||
* In absense of WSDL, JAX-WS creates PolicyMap from WebServiceFeatures configured on the endpoint implementation
|
||||
*
|
||||
* @param policyMap
|
||||
* PolicyMap created from PolicyAttachments in WSDL or Feature annotations on endpoint implementation class.
|
||||
* @param container
|
||||
* @param endpointClass
|
||||
* @param mutators
|
||||
* List of PolicyMapMutators that are run eventually when a PolicyMap is created
|
||||
*/
|
||||
public ServerContext(@Nullable PolicyMap policyMap, Container container,
|
||||
Class endpointClass, final PolicyMapMutator... mutators) {
|
||||
this.policyMap = policyMap;
|
||||
this.endpointClass = endpointClass;
|
||||
this.container = container;
|
||||
this.hasWsdl = true;
|
||||
this.mutators = Arrays.asList(mutators);
|
||||
}
|
||||
|
||||
/**
|
||||
* The abstraction of PolicyMap is not finalized, and will change in few months. It is highly discouraged to use
|
||||
* PolicyMap until it is finalized.
|
||||
*
|
||||
* In presence of WSDL, JAX-WS by default creates PolicyMap from Policy Attachemnts in WSDL.
|
||||
* In absense of WSDL, JAX-WS creates PolicyMap from WebServiceFeatures configured on the endpoint implementation
|
||||
*
|
||||
* @param policyMap
|
||||
* PolicyMap created from PolicyAttachments in WSDL or Feature annotations on endpoint implementation class.
|
||||
* @param container
|
||||
* @param endpointClass
|
||||
* @param hasWsdl Set to true, if this service is bundled with WSDL, false otherwise
|
||||
* @param mutators
|
||||
* List of PolicyMapMutators that are run eventually when a PolicyMap is created
|
||||
*/
|
||||
public ServerContext(@Nullable PolicyMap policyMap, Container container,
|
||||
Class endpointClass, boolean hasWsdl, final PolicyMapMutator... mutators) {
|
||||
this.policyMap = policyMap;
|
||||
this.endpointClass = endpointClass;
|
||||
this.container = container;
|
||||
this.hasWsdl = hasWsdl;
|
||||
this.mutators = Arrays.asList(mutators);
|
||||
}
|
||||
|
||||
public @Nullable PolicyMap getPolicyMap() {
|
||||
return policyMap;
|
||||
}
|
||||
|
||||
public @Nullable Class getEndpointClass() {
|
||||
return endpointClass;
|
||||
}
|
||||
|
||||
public Container getContainer() {
|
||||
return container;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true, if this service is bundled with WSDL, false otherwise
|
||||
* @return
|
||||
*/
|
||||
public boolean hasWsdl() {
|
||||
return hasWsdl;
|
||||
}
|
||||
|
||||
public Collection<PolicyMapMutator> getMutators() {
|
||||
return mutators;
|
||||
}
|
||||
}
|
||||
|
||||
public class ClientContext {
|
||||
private PolicyMap policyMap;
|
||||
private Container container;
|
||||
|
||||
/**
|
||||
* The abstraction of PolicyMap is not finalized, and will change in few months. It is highly discouraged to use
|
||||
* PolicyMap until it is finalized.
|
||||
*
|
||||
* In presence of WSDL, JAX-WS by default creates PolicyMap from Policy Attachemnts in WSDL.
|
||||
*
|
||||
* @param policyMap PolicyMap created from PolicyAttachemnts in WSDL
|
||||
* @param container
|
||||
*/
|
||||
public ClientContext(@Nullable PolicyMap policyMap, Container container) {
|
||||
this.policyMap = policyMap;
|
||||
this.container = container;
|
||||
}
|
||||
|
||||
public @Nullable PolicyMap getPolicyMap() {
|
||||
return policyMap;
|
||||
}
|
||||
|
||||
public Container getContainer() {
|
||||
return container;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api.policy;
|
||||
|
||||
import com.sun.xml.internal.ws.util.ServiceFinder;
|
||||
import com.sun.xml.internal.ws.policy.jaxws.DefaultPolicyResolver;
|
||||
|
||||
/**
|
||||
* PolicyResolverFactory provides a way to override Effective Policy Resolution for a Service or Client.
|
||||
* JAX-WS provides DEFAULT_POLICY_RESOLVER implementation that
|
||||
* on server-side validates that Policy has single alternative in the scope of each subject
|
||||
* on client-side updates with the effective policy by doing alternative selection.
|
||||
*
|
||||
* Extensions can override this to consult other forms of configuration to give the effective PolicyMap.
|
||||
*
|
||||
* @author Rama Pulavarthi
|
||||
*/
|
||||
public abstract class PolicyResolverFactory {
|
||||
|
||||
public abstract PolicyResolver doCreate();
|
||||
|
||||
public static PolicyResolver create(){
|
||||
for (PolicyResolverFactory factory : ServiceFinder.find(PolicyResolverFactory.class)) {
|
||||
PolicyResolver policyResolver = factory.doCreate();
|
||||
if (policyResolver != null) {
|
||||
return policyResolver;
|
||||
}
|
||||
}
|
||||
// return default policy resolver.
|
||||
return DEFAULT_POLICY_RESOLVER;
|
||||
}
|
||||
|
||||
/**
|
||||
* JAX-WS provided DEFAULT_POLICY_RESOLVER implementation that
|
||||
* on server-side validates that Policy has single alternative in the scope of each subject
|
||||
* on client-side updates with the effective policy by doing alternative selection.
|
||||
*/
|
||||
public static final PolicyResolver DEFAULT_POLICY_RESOLVER = new DefaultPolicyResolver();
|
||||
|
||||
|
||||
}
|
||||
100
jdkSrc/jdk8/com/sun/xml/internal/ws/api/policy/SourceModel.java
Normal file
100
jdkSrc/jdk8/com/sun/xml/internal/ws/api/policy/SourceModel.java
Normal file
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api.policy;
|
||||
|
||||
import com.sun.xml.internal.ws.addressing.policy.AddressingPrefixMapper;
|
||||
import com.sun.xml.internal.ws.config.management.policy.ManagementPrefixMapper;
|
||||
import com.sun.xml.internal.ws.encoding.policy.EncodingPrefixMapper;
|
||||
import com.sun.xml.internal.ws.policy.sourcemodel.PolicySourceModel;
|
||||
import com.sun.xml.internal.ws.policy.sourcemodel.wspolicy.NamespaceVersion;
|
||||
import com.sun.xml.internal.ws.policy.spi.PrefixMapper;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* This class is a root of unmarshalled policy source structure. Each instance of
|
||||
* the class contains factory method to create new com.sun.xml.internal.ws.policy.sourcemodel.ModelNode
|
||||
* instances associated with the actual model instance.
|
||||
*
|
||||
* @author Fabian Ritzmann
|
||||
*/
|
||||
public class SourceModel extends PolicySourceModel {
|
||||
|
||||
private static final PrefixMapper[] JAXWS_PREFIX_MAPPERS = {
|
||||
new AddressingPrefixMapper(),
|
||||
new EncodingPrefixMapper(),
|
||||
new ManagementPrefixMapper()
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Private constructor that creates a new policy source model instance without any
|
||||
* id or name identifier. The namespace-to-prefix map is initialized with mapping
|
||||
* of policy namespace to the default value set by
|
||||
* {@link PolicyConstants#POLICY_NAMESPACE_PREFIX POLICY_NAMESPACE_PREFIX constant}.
|
||||
*
|
||||
* @param nsVersion The WS-Policy version.
|
||||
*/
|
||||
private SourceModel(NamespaceVersion nsVersion) {
|
||||
this(nsVersion, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Private constructor that creates a new policy source model instance with given
|
||||
* id or name identifier and a set of PrefixMappers.
|
||||
*
|
||||
* @param nsVersion The WS-Policy version.
|
||||
* @param policyId Relative policy reference within an XML document. May be {@code null}.
|
||||
* @param policyName Absolute IRI of policy expression. May be {@code null}.
|
||||
*/
|
||||
private SourceModel(NamespaceVersion nsVersion, String policyId, String policyName) {
|
||||
super(nsVersion, policyId, policyName, Arrays.asList(JAXWS_PREFIX_MAPPERS));
|
||||
}
|
||||
|
||||
/**
|
||||
* Factory method that creates new policy source model instance.
|
||||
*
|
||||
* @param nsVersion The policy version
|
||||
* @return Newly created policy source model instance.
|
||||
*/
|
||||
public static PolicySourceModel createSourceModel(final NamespaceVersion nsVersion) {
|
||||
return new SourceModel(nsVersion);
|
||||
}
|
||||
|
||||
/**
|
||||
* Factory method that creates new policy source model instance and initializes it according to parameters provided.
|
||||
*
|
||||
* @param nsVersion The policy version
|
||||
* @param policyId local policy identifier - relative URI. May be {@code null}.
|
||||
* @param policyName global policy identifier - absolute policy expression URI. May be {@code null}.
|
||||
* @return Newly created policy source model instance with its name and id properly set.
|
||||
*/
|
||||
public static PolicySourceModel createSourceModel(final NamespaceVersion nsVersion,
|
||||
final String policyId, final String policyName) {
|
||||
return new SourceModel(nsVersion, policyId, policyName);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api.policy;
|
||||
|
||||
import com.sun.xml.internal.ws.addressing.policy.AddressingPolicyValidator;
|
||||
import com.sun.xml.internal.ws.config.management.policy.ManagementPolicyValidator;
|
||||
import com.sun.xml.internal.ws.encoding.policy.EncodingPolicyValidator;
|
||||
import com.sun.xml.internal.ws.policy.AssertionValidationProcessor;
|
||||
import com.sun.xml.internal.ws.policy.PolicyException;
|
||||
import com.sun.xml.internal.ws.policy.spi.PolicyAssertionValidator;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Provides methods for assertion validation.
|
||||
*
|
||||
* @author Fabian Ritzmann
|
||||
*/
|
||||
public class ValidationProcessor extends AssertionValidationProcessor {
|
||||
|
||||
private static final PolicyAssertionValidator[] JAXWS_ASSERTION_VALIDATORS = {
|
||||
new AddressingPolicyValidator(),
|
||||
new EncodingPolicyValidator(),
|
||||
new ManagementPolicyValidator()
|
||||
};
|
||||
|
||||
/**
|
||||
* This constructor instantiates the object with a set of dynamically
|
||||
* discovered PolicyAssertionValidators.
|
||||
*
|
||||
* @throws PolicyException Thrown if the set of dynamically discovered
|
||||
* PolicyAssertionValidators is empty.
|
||||
*/
|
||||
private ValidationProcessor() throws PolicyException {
|
||||
super(Arrays.asList(JAXWS_ASSERTION_VALIDATORS));
|
||||
}
|
||||
|
||||
/**
|
||||
* Factory method that returns singleton instance of the class.
|
||||
*
|
||||
* @return singleton An instance of the class.
|
||||
* @throws PolicyException If instantiation failed.
|
||||
*/
|
||||
public static ValidationProcessor getInstance() throws PolicyException {
|
||||
return new ValidationProcessor();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,199 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api.policy.subject;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import com.sun.istack.internal.logging.Logger;
|
||||
import com.sun.xml.internal.ws.resources.BindingApiMessages;
|
||||
|
||||
/**
|
||||
* Experimental: This class identifies WSDL scopes. That allows to attach and
|
||||
* retrieve elements to and from WSDL scopes.
|
||||
*
|
||||
* @author Fabian Ritzmann
|
||||
*/
|
||||
public class BindingSubject {
|
||||
|
||||
/**
|
||||
* For message subjects, this needs to be set to one of the values INPUT, OUTPUT
|
||||
* or FAULT. Any other subject has the message type NO_MESSAGE.
|
||||
*/
|
||||
private enum WsdlMessageType {
|
||||
NO_MESSAGE,
|
||||
INPUT,
|
||||
OUTPUT,
|
||||
FAULT
|
||||
}
|
||||
|
||||
/**
|
||||
* Identifies the scope to which this subject belongs. See WS-PolicyAttachment
|
||||
* for an explanation on WSDL scopes.
|
||||
*
|
||||
* The SERVICE scope is not actually used and only listed here for completeness
|
||||
* sake.
|
||||
*/
|
||||
private enum WsdlNameScope {
|
||||
SERVICE,
|
||||
ENDPOINT,
|
||||
OPERATION,
|
||||
MESSAGE
|
||||
}
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(BindingSubject.class);
|
||||
|
||||
private final QName name;
|
||||
private final WsdlMessageType messageType;
|
||||
private final WsdlNameScope nameScope;
|
||||
private final BindingSubject parent;
|
||||
|
||||
BindingSubject(final QName name, final WsdlNameScope scope, final BindingSubject parent) {
|
||||
this(name, WsdlMessageType.NO_MESSAGE, scope, parent);
|
||||
}
|
||||
|
||||
BindingSubject(final QName name, final WsdlMessageType messageType, final WsdlNameScope scope, final BindingSubject parent) {
|
||||
this.name = name;
|
||||
this.messageType = messageType;
|
||||
this.nameScope = scope;
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
public static BindingSubject createBindingSubject(QName bindingName) {
|
||||
return new BindingSubject(bindingName, WsdlNameScope.ENDPOINT, null);
|
||||
}
|
||||
|
||||
public static BindingSubject createOperationSubject(QName bindingName, QName operationName) {
|
||||
final BindingSubject bindingSubject = createBindingSubject(bindingName);
|
||||
return new BindingSubject(operationName, WsdlNameScope.OPERATION, bindingSubject);
|
||||
}
|
||||
|
||||
public static BindingSubject createInputMessageSubject(QName bindingName, QName operationName, QName messageName) {
|
||||
final BindingSubject operationSubject = createOperationSubject(bindingName, operationName);
|
||||
return new BindingSubject(messageName, WsdlMessageType.INPUT, WsdlNameScope.MESSAGE, operationSubject);
|
||||
}
|
||||
|
||||
public static BindingSubject createOutputMessageSubject(QName bindingName, QName operationName, QName messageName) {
|
||||
final BindingSubject operationSubject = createOperationSubject(bindingName, operationName);
|
||||
return new BindingSubject(messageName, WsdlMessageType.OUTPUT, WsdlNameScope.MESSAGE, operationSubject);
|
||||
}
|
||||
|
||||
public static BindingSubject createFaultMessageSubject(QName bindingName, QName operationName, QName messageName) {
|
||||
if (messageName == null) {
|
||||
throw LOGGER.logSevereException(new IllegalArgumentException(BindingApiMessages.BINDING_API_NO_FAULT_MESSAGE_NAME()));
|
||||
}
|
||||
final BindingSubject operationSubject = createOperationSubject(bindingName, operationName);
|
||||
return new BindingSubject(messageName, WsdlMessageType.FAULT, WsdlNameScope.MESSAGE, operationSubject);
|
||||
}
|
||||
|
||||
public QName getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public BindingSubject getParent() {
|
||||
return this.parent;
|
||||
}
|
||||
|
||||
public boolean isBindingSubject() {
|
||||
if (this.nameScope == WsdlNameScope.ENDPOINT) {
|
||||
return this.parent == null;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isOperationSubject() {
|
||||
if (this.nameScope == WsdlNameScope.OPERATION) {
|
||||
if (this.parent != null) {
|
||||
return this.parent.isBindingSubject();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isMessageSubject() {
|
||||
if (this.nameScope == WsdlNameScope.MESSAGE) {
|
||||
if (this.parent != null) {
|
||||
return this.parent.isOperationSubject();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isInputMessageSubject() {
|
||||
return isMessageSubject() && (this.messageType == WsdlMessageType.INPUT);
|
||||
}
|
||||
|
||||
public boolean isOutputMessageSubject() {
|
||||
return isMessageSubject() && (this.messageType == WsdlMessageType.OUTPUT);
|
||||
}
|
||||
|
||||
public boolean isFaultMessageSubject() {
|
||||
return isMessageSubject() && (this.messageType == WsdlMessageType.FAULT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object that) {
|
||||
if (this == that) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (that == null || !(that instanceof BindingSubject)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final BindingSubject thatSubject = (BindingSubject) that;
|
||||
boolean isEqual = true;
|
||||
|
||||
isEqual = isEqual && ((this.name == null) ? thatSubject.name == null : this.name.equals(thatSubject.name));
|
||||
isEqual = isEqual && this.messageType.equals(thatSubject.messageType);
|
||||
isEqual = isEqual && this.nameScope.equals(thatSubject.nameScope);
|
||||
isEqual = isEqual && ((this.parent == null) ? thatSubject.parent == null : this.parent.equals(thatSubject.parent));
|
||||
|
||||
return isEqual;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = 23;
|
||||
|
||||
result = 29 * result + ((this.name == null) ? 0 : this.name.hashCode());
|
||||
result = 29 * result + this.messageType.hashCode();
|
||||
result = 29 * result + this.nameScope.hashCode();
|
||||
result = 29 * result + ((this.parent == null) ? 0 : this.parent.hashCode());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder result = new StringBuilder("BindingSubject[");
|
||||
result.append(this.name).append(", ").append(this.messageType);
|
||||
result.append(", ").append(this.nameScope).append(", ").append(this.parent);
|
||||
return result.append("]").toString();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user