public void execute(WSHandler handler, SecurityActionToken actionToken, RequestData reqData) throws WSSecurityException { // // add the Timestamp to the SOAP Envelope // WSSecTimestamp timeStampBuilder = new WSSecTimestamp(reqData.getSecHeader()); timeStampBuilder.setIdAllocator(reqData.getWssConfig().getIdAllocator()); timeStampBuilder.setPrecisionInMilliSeconds(reqData.isPrecisionInMilliSeconds()); timeStampBuilder.setTimeToLive(reqData.getTimeStampTTL()); timeStampBuilder.setWsTimeSource(reqData.getWssConfig().getCurrentTime()); timeStampBuilder.setWsDocInfo(reqData.getWsDocInfo()); timeStampBuilder.setExpandXopInclude(reqData.isExpandXopInclude()); timeStampBuilder.build(); } }
protected WSSecTimestamp createTimestamp() { if (binding.isIncludeTimestamp()) { Object o = message.getContextualProperty(SecurityConstants.TIMESTAMP_TTL); int ttl = 300; //default is 300 seconds if (o instanceof Number) { ttl = ((Number)o).intValue(); } else if (o instanceof String) { ttl = Integer.parseInt((String)o); } if (ttl <= 0) { ttl = 300; } timestampEl = new WSSecTimestamp(secHeader); timestampEl.setIdAllocator(wssConfig.getIdAllocator()); timestampEl.setWsTimeSource(wssConfig.getCurrentTime()); timestampEl.setTimeToLive(ttl); timestampEl.prepare(); String namespace = binding.getName().getNamespaceURI(); PolicyUtils.assertPolicy(aim, new QName(namespace, SPConstants.INCLUDE_TIMESTAMP)); } return timestampEl; }
/** * Adds a new <code>Timestamp</code> to a soap envelope. * * A complete <code>Timestamp</code> is constructed and added to the * <code>wsse:Security</code> header. * * @return Document with Timestamp added * @throws Exception */ public Document build() { LOG.debug("Begin add timestamp..."); prepare(); prependToHeader(); return getDocument(); }
/** * Creates a Timestamp element. * * The method prepares and initializes a WSSec Timestamp structure after the * relevant information was set. Before calling <code>prepare()</code> the * parameter such as <code>timeToLive</code> can be set if the default * value is not suitable. */ public void prepare() { ts = new Timestamp(precisionInMilliSeconds, getDocument(), wsTimeSource, timeToLive); String tsId = getIdAllocator().createId("TS-", ts); ts.setID(tsId); }
protected void reshuffleTimestamp() { // Make sure that the Timestamp is in first place, if that is what the policy requires if (binding.getLayout() != null && timestampEl != null) { if (binding.getLayout().getLayoutType() == LayoutType.LaxTsFirst && secHeader.getSecurityHeaderElement().getFirstChild() != timestampEl.getElement()) { Node firstChild = secHeader.getSecurityHeaderElement().getFirstChild(); while (firstChild != null && firstChild.getNodeType() != Node.ELEMENT_NODE) { firstChild = firstChild.getNextSibling(); } if (firstChild != null && firstChild != timestampEl.getElement()) { secHeader.getSecurityHeaderElement().insertBefore(timestampEl.getElement(), firstChild); } } else if (binding.getLayout().getLayoutType() == LayoutType.LaxTsLast && secHeader.getSecurityHeaderElement().getLastChild() != timestampEl.getElement()) { secHeader.getSecurityHeaderElement().appendChild(timestampEl.getElement()); } } }
/** * Prepends the Timestamp element to the elements already in the Security * header. * * The method can be called any time after <code>prepare()</code>. This * allows to insert the Timestamp element at any position in the Security * header. */ public void prependToHeader() { Element securityHeaderElement = getSecurityHeader().getSecurityHeaderElement(); WSSecurityUtil.prependChildElement(securityHeaderElement, ts.getElement()); }
protected void reshuffleTimestamp() { // Make sure that the Timestamp is in first place, if that is what the policy requires if (binding.getLayout() != null && timestampEl != null) { if (binding.getLayout().getLayoutType() == LayoutType.LaxTsFirst && secHeader.getSecurityHeaderElement().getFirstChild() != timestampEl.getElement()) { Node firstChild = secHeader.getSecurityHeaderElement().getFirstChild(); while (firstChild != null && firstChild.getNodeType() != Node.ELEMENT_NODE) { firstChild = firstChild.getNextSibling(); } if (firstChild != null && firstChild != timestampEl.getElement()) { secHeader.getSecurityHeaderElement().insertBefore(timestampEl.getElement(), firstChild); } } else if (binding.getLayout().getLayoutType() == LayoutType.LaxTsLast && secHeader.getSecurityHeaderElement().getLastChild() != timestampEl.getElement()) { secHeader.getSecurityHeaderElement().appendChild(timestampEl.getElement()); } } }
protected WSSecTimestamp createTimestamp() { if (binding.isIncludeTimestamp()) { Object o = message.getContextualProperty(SecurityConstants.TIMESTAMP_TTL); int ttl = 300; //default is 300 seconds if (o instanceof Number) { ttl = ((Number)o).intValue(); } else if (o instanceof String) { ttl = Integer.parseInt((String)o); } if (ttl <= 0) { ttl = 300; } timestampEl = new WSSecTimestamp(secHeader); timestampEl.setIdAllocator(wssConfig.getIdAllocator()); timestampEl.setWsTimeSource(wssConfig.getCurrentTime()); timestampEl.setTimeToLive(ttl); timestampEl.prepare(); String namespace = binding.getName().getNamespaceURI(); PolicyUtils.assertPolicy(aim, new QName(namespace, SPConstants.INCLUDE_TIMESTAMP)); } return timestampEl; }
WSEncryptionPart timestampPart = new WSEncryptionPart("Timestamp", WSS4JConstants.WSU_NS, "Element"); String id = addWsuIdToElement(timestampEl.getElement()); timestampPart.setId(id); timestampPart.setElement(timestampEl.getElement());
WSEncryptionPart timestampPart = new WSEncryptionPart("Timestamp", WSS4JConstants.WSU_NS, "Element"); String id = addWsuIdToElement(timestampEl.getElement()); timestampPart.setId(id); timestampPart.setElement(timestampEl.getElement());
new QName(binding.getLayout().getName().getNamespaceURI(), SPConstants.LAYOUT_LAX_TIMESTAMP_LAST)); Element el = timestamp.getElement(); secHeader.getSecurityHeaderElement().appendChild(el); if (bottomUpElement == null) { ai.setNotAsserted(SPConstants.LAYOUT_LAX_TIMESTAMP_FIRST + " requires a timestamp"); } else { addTopDownElement(timestampEl.getElement()); ai.setAsserted(true); assertPolicy( ai.setAsserted(true); addTopDownElement(timestampEl.getElement()); } else if (ai != null) { ai.setAsserted(true); new QName(binding.getLayout().getName().getNamespaceURI(), SPConstants.LAYOUT_STRICT)); } else if (timestampEl != null) { addTopDownElement(timestampEl.getElement());
new QName(binding.getLayout().getName().getNamespaceURI(), SPConstants.LAYOUT_LAX_TIMESTAMP_LAST)); Element el = timestamp.getElement(); secHeader.getSecurityHeaderElement().appendChild(el); if (bottomUpElement == null) { ai.setNotAsserted(SPConstants.LAYOUT_LAX_TIMESTAMP_FIRST + " requires a timestamp"); } else { addTopDownElement(timestampEl.getElement()); ai.setAsserted(true); assertPolicy( ai.setAsserted(true); addTopDownElement(timestampEl.getElement()); } else if (ai != null) { ai.setAsserted(true); new QName(binding.getLayout().getName().getNamespaceURI(), SPConstants.LAYOUT_STRICT)); } else if (timestampEl != null) { addTopDownElement(timestampEl.getElement());
if (timestampEl != null) { WSEncryptionPart timestampPart = convertToEncryptionPart(timestampEl.getElement()); sigParts.add(timestampPart);
if (timestampEl != null) { WSEncryptionPart timestampPart = convertToEncryptionPart(timestampEl.getElement()); sigParts.add(timestampPart);
if (timestampEl != null) { WSEncryptionPart timestampPart = convertToEncryptionPart(timestampEl.getElement()); sigParts.add(timestampPart);
WSEncryptionPart timestampPart = convertToEncryptionPart(timestampEl.getElement()); sigs.add(timestampPart);
WSEncryptionPart timestampPart = convertToEncryptionPart(timestampEl.getElement()); sigs.add(timestampPart);
if (timestampEl != null) { WSEncryptionPart timestampPart = convertToEncryptionPart(timestampEl.getElement()); sigParts.add(timestampPart);
if (timestampEl != null) { WSEncryptionPart timestampPart = convertToEncryptionPart(timestampEl.getElement()); sigs.add(timestampPart);
if (timestampEl != null) { WSEncryptionPart timestampPart = convertToEncryptionPart(timestampEl.getElement()); sigs.add(timestampPart);