本文整理汇总了Java中com.sun.xml.internal.ws.resources.PolicyMessages类的典型用法代码示例。如果您正苦于以下问题:Java PolicyMessages类的具体用法?Java PolicyMessages怎么用?Java PolicyMessages使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PolicyMessages类属于com.sun.xml.internal.ws.resources包,在下文中一共展示了PolicyMessages类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPolicies
import com.sun.xml.internal.ws.resources.PolicyMessages; //导入依赖的package包/类
final Collection<Policy> getPolicies() throws PolicyException {
if (null == policyURIs) {
throw LOGGER.logSevereException(new PolicyException(PolicyMessages.WSP_1004_POLICY_URIS_CAN_NOT_BE_NULL()));
}
if (null == policyStore) {
throw LOGGER.logSevereException(new PolicyException(PolicyMessages.WSP_1010_NO_POLICIES_DEFINED()));
}
final Collection<Policy> result = new ArrayList<Policy>(policyURIs.size());
for (String policyURI : policyURIs) {
final PolicySourceModel sourceModel = policyStore.get(policyURI);
if (sourceModel == null) {
throw LOGGER.logSevereException(new PolicyException(PolicyMessages.WSP_1005_POLICY_REFERENCE_DOES_NOT_EXIST(policyURI)));
} else {
result.add(ModelTranslator.getTranslator().translate(sourceModel));
}
}
return result;
}
示例2: readPolicyReferenceElement
import com.sun.xml.internal.ws.resources.PolicyMessages; //导入依赖的package包/类
/**
* Reads policy reference element <wsp:PolicyReference/> and returns referenced policy URI as String
*
* @param reader The XMLStreamReader should be in START_ELEMENT state and point to the PolicyReference element.
* @return The URI contained in the PolicyReference
*/
public String readPolicyReferenceElement(final XMLStreamReader reader) {
try {
if (NamespaceVersion.resolveAsToken(reader.getName()) == XmlToken.PolicyReference) { // "PolicyReference" element interests me
for (int i = 0; i < reader.getAttributeCount(); i++) {
if (XmlToken.resolveToken(reader.getAttributeName(i).getLocalPart()) == XmlToken.Uri) {
final String uriValue = reader.getAttributeValue(i);
reader.next();
return uriValue;
}
}
}
reader.next();
return null;
} catch(XMLStreamException e) {
throw LOGGER.logSevereException(new WebServiceException(PolicyMessages.WSP_1001_XML_EXCEPTION_WHEN_PROCESSING_POLICY_REFERENCE(), e));
}
}
示例3: validateServerPolicyMap
import com.sun.xml.internal.ws.resources.PolicyMessages; //导入依赖的package包/类
/**
* Checks if the PolicyMap has only single alternative in the scope.
*
* @param policyMap
* PolicyMap that needs to be validated.
*/
private void validateServerPolicyMap(PolicyMap policyMap) {
try {
final ValidationProcessor validationProcessor = ValidationProcessor.getInstance();
for (Policy policy : policyMap) {
// TODO: here is a good place to check if the actual policy has only one alternative...
for (AssertionSet assertionSet : policy) {
for (PolicyAssertion assertion : assertionSet) {
Fitness validationResult = validationProcessor.validateServerSide(assertion);
if (validationResult != Fitness.SUPPORTED) {
throw new PolicyException(PolicyMessages.WSP_1015_SERVER_SIDE_ASSERTION_VALIDATION_FAILED(
assertion.getName(),
validationResult));
}
}
}
}
} catch (PolicyException e) {
throw new WebServiceException(e);
}
}
示例4: writePolicyOrReferenceIt
import com.sun.xml.internal.ws.resources.PolicyMessages; //导入依赖的package包/类
/**
* Adds a PolicyReference element that points to the policy of the element,
* if the policy does not have any id or name. Writes policy inside the element otherwise.
*
* @param subject
* PolicySubject to be referenced or marshalled
* @param writer
* A TXW on to which we shall add the PolicyReference
*/
private void writePolicyOrReferenceIt(final PolicySubject subject, final TypedXmlWriter writer) {
final Policy policy;
try {
policy = subject.getEffectivePolicy(merger);
} catch (PolicyException e) {
throw LOGGER.logSevereException(new WebServiceException(PolicyMessages.WSP_1011_FAILED_TO_RETRIEVE_EFFECTIVE_POLICY_FOR_SUBJECT(subject.toString()), e));
}
if (policy != null) {
if (null == policy.getIdOrName()) {
final PolicyModelGenerator generator = ModelGenerator.getGenerator();
try {
final PolicySourceModel policyInfoset = generator.translate(policy);
marshaller.marshal(policyInfoset, writer);
} catch (PolicyException pe) {
throw LOGGER.logSevereException(new WebServiceException(PolicyMessages.WSP_1002_UNABLE_TO_MARSHALL_POLICY_OR_POLICY_REFERENCE(), pe));
}
} else {
final TypedXmlWriter policyReference = writer._element(policy.getNamespaceVersion().asQName(XmlToken.PolicyReference), TypedXmlWriter.class);
policyReference._attribute(XmlToken.Uri.toString(), '#' + policy.getIdOrName());
}
}
}
示例5: populate
import com.sun.xml.internal.ws.resources.PolicyMessages; //导入依赖的package包/类
final void populate(final PolicyMapExtender policyMapExtender) throws PolicyException {
if (null == policyMapExtender) {
throw LOGGER.logSevereException(new PolicyException(PolicyMessages.WSP_1006_POLICY_MAP_EXTENDER_CAN_NOT_BE_NULL()));
}
doPopulate(policyMapExtender);
}
示例6: start
import com.sun.xml.internal.ws.resources.PolicyMessages; //导入依赖的package包/类
@Override
public void start(final WSDLGenExtnContext context) {
LOGGER.entering();
try {
this.seiModel = context.getModel();
final PolicyMapConfigurator[] policyMapConfigurators = loadConfigurators();
final PolicyMapExtender[] extenders = new PolicyMapExtender[policyMapConfigurators.length];
for (int i = 0; i < policyMapConfigurators.length; i++) {
extenders[i] = PolicyMapExtender.createPolicyMapExtender();
}
// Read policy config file
policyMap = PolicyResolverFactory.create().resolve(
new PolicyResolver.ServerContext(policyMap, context.getContainer(), context.getEndpointClass(), false, extenders));
if (policyMap == null) {
LOGGER.fine(PolicyMessages.WSP_1019_CREATE_EMPTY_POLICY_MAP());
policyMap = PolicyMap.createPolicyMap(Arrays.asList(extenders));
}
final WSBinding binding = context.getBinding();
try {
final Collection<PolicySubject> policySubjects = new LinkedList<PolicySubject>();
for (int i = 0; i < policyMapConfigurators.length; i++) {
policySubjects.addAll(policyMapConfigurators[i].update(policyMap, seiModel, binding));
extenders[i].disconnect();
}
PolicyMapUtil.insertPolicies(policyMap, policySubjects, this.seiModel.getServiceQName(), this.seiModel.getPortName());
} catch (PolicyException e) {
throw LOGGER.logSevereException(new WebServiceException(PolicyMessages.WSP_1017_MAP_UPDATE_FAILED(), e));
}
final TypedXmlWriter root = context.getRoot();
root._namespace(NamespaceVersion.v1_2.toString(), NamespaceVersion.v1_2.getDefaultNamespacePrefix());
root._namespace(NamespaceVersion.v1_5.toString(), NamespaceVersion.v1_5.getDefaultNamespacePrefix());
root._namespace(PolicyConstants.WSU_NAMESPACE_URI, PolicyConstants.WSU_NAMESPACE_PREFIX);
} finally {
LOGGER.exiting();
}
}