private void setupNamespace(AddressingProperties maps, Message message) { AssertionInfoMap aim = message.get(AssertionInfoMap.class); if (null == aim) { return; } Collection<AssertionInfo> aic = aim.getAssertionInfo(MetadataConstants.USING_ADDRESSING_2004_QNAME); if (aic != null && !aic.isEmpty()) { maps.exposeAs(Names200408.WSA_NAMESPACE_NAME); } }
/** * Add MAPs which are specific to the requestor or responder role. * * @param maps the MAPs being assembled * @param message the current message * @param isRequestor true iff the current messaging role is that of requestor * @param isFault true if a fault is being mediated */ private void addRoleSpecific( AddressingProperties maps, Message message, boolean isRequestor, boolean isFault) { if (isRequestor) { Exchange exchange = message.getExchange(); // add request-specific MAPs boolean isOneway = exchange.isOneWay(); boolean isOutbound = ContextUtils.isOutbound(message); // To if (maps.getTo() == null) { Conduit conduit = null; if (isOutbound) { conduit = ContextUtils.getConduit(null, message); } String s = (String) message.get(Message.ENDPOINT_ADDRESS); EndpointReferenceType reference = conduit != null ? conduit.getTarget() : ContextUtils.getNoneEndpointReference(); if (conduit != null && !StringUtils.isEmpty(s) && !reference.getAddress().getValue().equals(s)) { EndpointReferenceType ref = new EndpointReferenceType(); AttributedURIType tp = new AttributedURIType(); tp.setValue(s); ref.setAddress(tp); ref.setMetadata(reference.getMetadata()); ref.setReferenceParameters(reference.getReferenceParameters()); ref.getOtherAttributes().putAll(reference.getOtherAttributes()); reference = ref; } maps.setTo(reference); } // ReplyTo, set if null in MAPs or if set to a generic address // (anonymous or none) that may not be appropriate for the // current invocation EndpointReferenceType replyTo = maps.getReplyTo(); if (ContextUtils.isGenericAddress(replyTo)) { replyTo = getReplyTo(message, replyTo); if (replyTo == null || (isOneway && (replyTo == null || replyTo.getAddress() == null || !Names.WSA_NONE_ADDRESS.equals(replyTo.getAddress().getValue())))) { AttributedURIType address = ContextUtils.getAttributedURI( isOneway ? Names.WSA_NONE_ADDRESS : Names.WSA_ANONYMOUS_ADDRESS); replyTo = ContextUtils.WSA_OBJECT_FACTORY.createEndpointReferenceType(); replyTo.setAddress(address); } maps.setReplyTo(replyTo); } // FaultTo if (maps.getFaultTo() == null) { maps.setFaultTo(maps.getReplyTo()); } else if (maps.getFaultTo().getAddress() == null) { maps.setFaultTo(null); } } else { // add response-specific MAPs AddressingProperties inMAPs = getMAPs(message, false, false); maps.exposeAs(inMAPs.getNamespaceURI()); // To taken from ReplyTo or FaultTo in incoming MAPs (depending // on the fault status of the response) if (isFault && inMAPs.getFaultTo() != null) { maps.setTo(inMAPs.getFaultTo()); } else if (maps.getTo() == null && inMAPs.getReplyTo() != null) { maps.setTo(inMAPs.getReplyTo()); } // RelatesTo taken from MessageID in incoming MAPs if (inMAPs.getMessageID() != null && !Boolean.TRUE.equals(message.get(Message.PARTIAL_RESPONSE_MESSAGE))) { String inMessageID = inMAPs.getMessageID().getValue(); maps.setRelatesTo(ContextUtils.getRelatesTo(inMessageID)); } else { maps.setRelatesTo(ContextUtils.getRelatesTo(Names.WSA_UNSPECIFIED_RELATIONSHIP)); } // fallback fault action if (isFault && maps.getAction() == null) { maps.setAction(ContextUtils.getAttributedURI(Names.WSA_DEFAULT_FAULT_ACTION)); } if (isFault && !ContextUtils.isGenericAddress(inMAPs.getFaultTo())) { Message m = message.getExchange().getInFaultMessage(); if (m == null) { m = message; } InternalContextUtils.rebaseResponse(inMAPs.getFaultTo(), inMAPs, m); Destination destination = InternalContextUtils.createDecoupledDestination(m.getExchange(), inMAPs.getFaultTo()); m.getExchange().setDestination(destination); } } }
public SourceSequence getSequence(Identifier inSeqId, Message message, AddressingProperties maps) throws RMException { Source source = getSource(message); SourceSequence seq = source.getCurrent(inSeqId); RMConfiguration config = getEffectiveConfiguration(message); if (null == seq || seq.isExpired()) { // TODO: better error handling EndpointReferenceType to = null; boolean isServer = RMContextUtils.isServerSide(message); EndpointReferenceType acksTo = null; RelatesToType relatesTo = null; if (isServer) { AddressingProperties inMaps = RMContextUtils.retrieveMAPs(message, false, false); inMaps.exposeAs(config.getAddressingNamespace()); acksTo = RMUtils.createReference(inMaps.getTo().getValue()); to = inMaps.getReplyTo(); source.getReliableEndpoint().getServant().setUnattachedIdentifier(inSeqId); relatesTo = (new org.apache.cxf.ws.addressing.ObjectFactory()).createRelatesToType(); Destination destination = getDestination(message); DestinationSequence inSeq = inSeqId == null ? null : destination.getSequence(inSeqId); relatesTo.setValue(inSeq != null ? inSeq.getCorrelationID() : null); } else { to = RMUtils.createReference(maps.getTo().getValue()); acksTo = maps.getReplyTo(); if (RMUtils.getAddressingConstants().getNoneURI().equals(acksTo.getAddress().getValue())) { Endpoint ei = message.getExchange().getEndpoint(); org.apache.cxf.transport.Destination dest = ei == null ? null : ei.getEndpointInfo() .getProperty( MAPAggregator.DECOUPLED_DESTINATION, org.apache.cxf.transport.Destination.class); if (null == dest) { acksTo = RMUtils.createAnonymousReference(); } else { acksTo = dest.getAddress(); } } } if (ContextUtils.isGenericAddress(to)) { org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message( "CREATE_SEQ_ANON_TARGET", LOG, to != null && to.getAddress() != null ? to.getAddress().getValue() : null); LOG.log(Level.INFO, msg.toString()); throw new RMException(msg); } Proxy proxy = source.getReliableEndpoint().getProxy(); ProtocolVariation protocol = config.getProtocolVariation(); Exchange exchange = new ExchangeImpl(); Map<String, Object> context = new HashMap<String, Object>(16); for (String key : message.getContextualPropertyKeys()) { // copy other properties? if (key.startsWith("ws-security")) { context.put(key, message.getContextualProperty(key)); } } CreateSequenceResponseType createResponse = proxy.createSequence(acksTo, relatesTo, isServer, protocol, exchange, context); if (!isServer) { Servant servant = source.getReliableEndpoint().getServant(); servant.createSequenceResponse(createResponse, protocol); // propagate security properties to application endpoint, in case we're using // WS-SecureConversation Exchange appex = message.getExchange(); if (appex.get(SecurityConstants.TOKEN) == null) { appex.put(SecurityConstants.TOKEN, exchange.get(SecurityConstants.TOKEN)); appex.put(SecurityConstants.TOKEN_ID, exchange.get(SecurityConstants.TOKEN_ID)); } } seq = source.awaitCurrent(inSeqId); seq.setTarget(to); } return seq; }