You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2009/02/17 21:24:33 UTC
svn commit: r745227 - in /cxf/trunk:
common/common/src/main/java/org/apache/cxf/staxutils/
rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/
rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/
Author: dkulp
Date: Tue Feb 17 20:24:33 2009
New Revision: 745227
URL: http://svn.apache.org/viewvc?rev=745227&view=rev
Log:
First WS-SecureConversation test endpoint works. :-)
Modified:
cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamWriter.java
cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/STSClient.java
cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/WSS4JInInterceptor.java
Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamWriter.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamWriter.java?rev=745227&r1=745226&r2=745227&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamWriter.java (original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamWriter.java Tue Feb 17 20:24:33 2009
@@ -40,6 +40,7 @@
private Document document;
private Element currentNode;
private NamespaceContext context = new W3CNamespaceContext();
+ private boolean nsRepairing;
private Map properties = Collections.EMPTY_MAP;
public W3CDOMStreamWriter() throws ParserConfigurationException {
@@ -61,6 +62,12 @@
((W3CNamespaceContext)context).setElement(e);
}
+ public void setNsRepairing(boolean b) {
+ nsRepairing = b;
+ }
+ public boolean isNsRepairing() {
+ return nsRepairing;
+ }
public void setProperties(Map properties) {
this.properties = properties;
}
@@ -96,6 +103,10 @@
writeStartElement(namespace, local);
} else {
newChild(document.createElementNS(namespace, prefix + ":" + local));
+ if (nsRepairing
+ && !prefix.equals(getNamespaceContext().getPrefix(namespace))) {
+ writeNamespace(prefix, namespace);
+ }
}
}
@@ -138,6 +149,10 @@
Attr a = document.createAttributeNS(namespace, local);
a.setValue(value);
currentNode.setAttributeNodeNS(a);
+ if (nsRepairing
+ && !prefix.equals(getNamespaceContext().getPrefix(namespace))) {
+ writeNamespace(prefix, namespace);
+ }
}
public void writeAttribute(String namespace, String local, String value) throws XMLStreamException {
Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/STSClient.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/STSClient.java?rev=745227&r1=745226&r2=745227&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/STSClient.java (original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/STSClient.java Tue Feb 17 20:24:33 2009
@@ -477,9 +477,9 @@
throw new TrustException(new Message("NO_ID", LOG));
}
- SecurityToken token = new SecurityToken(id, rst, lte);
- token.setAttachedReference(rar);
- token.setUnattachedReference(rur);
+ SecurityToken token = new SecurityToken(id, copyElement(rst), copyElement(lte));
+ token.setAttachedReference(copyElement(rar));
+ token.setUnattachedReference(copyElement(rur));
token.setIssuerAddress(location);
@@ -541,7 +541,19 @@
return token;
}
-
+ private Element copyElement(Element el) {
+ if (el == null) {
+ return null;
+ }
+ try {
+ W3CDOMStreamWriter writer = new W3CDOMStreamWriter();
+ writer.setNsRepairing(true);
+ StaxUtils.copy(el, writer);
+ return writer.getDocument().getDocumentElement();
+ } catch (Exception ex) {
+ return el;
+ }
+ }
private String findID(Element rar, Element rur, Element rst) {
String id = null;
if (rar != null) {
Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/WSS4JInInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/WSS4JInInterceptor.java?rev=745227&r1=745226&r2=745227&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/WSS4JInInterceptor.java (original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/WSS4JInInterceptor.java Tue Feb 17 20:24:33 2009
@@ -360,7 +360,8 @@
WSPasswordCallback pc = (WSPasswordCallback)callbacks[i];
String id = pc.getIdentifier();
- if (pc.getKeyType().equals(SecurityTokenReference.ENC_KEY_SHA1_URI)) {
+
+ if (SecurityTokenReference.ENC_KEY_SHA1_URI.equals(pc.getKeyType())) {
for (SecurityToken token : store.getValidTokens()) {
if (id.equals(token.getSHA1())) {
pc.setKey(token.getSecret());
@@ -375,7 +376,9 @@
}
}
}
- internal.handle(callbacks);
+ if (internal != null) {
+ internal.handle(callbacks);
+ }
}
}
@@ -400,16 +403,26 @@
cbHandler = (CallbackHandler)o;
}
if (cbHandler == null) {
- cbHandler = getPasswordCB(reqData);
+ try {
+ cbHandler = getPasswordCB(reqData);
+ } catch (WSSecurityException sec) {
+ Endpoint ep = ((SoapMessage)reqData.getMsgContext()).getExchange().get(Endpoint.class);
+ if (ep != null && ep.getEndpointInfo() != null) {
+ TokenStore store = (TokenStore)ep.getEndpointInfo()
+ .getProperty(TokenStore.class.getName());
+ if (store != null) {
+ return new TokenStoreCallbackHandler(cbHandler, store);
+ }
+ }
+ throw sec;
+ }
}
}
- if (cbHandler != null) {
- Endpoint ep = ((SoapMessage)reqData.getMsgContext()).getExchange().get(Endpoint.class);
- if (ep != null && ep.getEndpointInfo() != null) {
- TokenStore store = (TokenStore)ep.getEndpointInfo().getProperty(TokenStore.class.getName());
- if (store != null) {
- return new TokenStoreCallbackHandler(cbHandler, store);
- }
+ Endpoint ep = ((SoapMessage)reqData.getMsgContext()).getExchange().get(Endpoint.class);
+ if (ep != null && ep.getEndpointInfo() != null) {
+ TokenStore store = (TokenStore)ep.getEndpointInfo().getProperty(TokenStore.class.getName());
+ if (store != null) {
+ return new TokenStoreCallbackHandler(cbHandler, store);
}
}
return cbHandler;