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 2008/07/09 22:11:48 UTC
svn commit: r675332 [6/6] - in /cxf/trunk:
common/common/src/main/java/org/apache/cxf/helpers/
rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/
rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/builders/
rt/ws/security/src/m...
Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/SymmetricBinding.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/SymmetricBinding.java?rev=675332&r1=674910&r2=675332&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/SymmetricBinding.java (original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/SymmetricBinding.java Wed Jul 9 13:11:45 2008
@@ -1,20 +1,22 @@
-/*
- * Copyright 2004,2005 The Apache Software Foundation.
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-
-package org.apache.ws.secpolicy.model;
+package org.apache.cxf.ws.security.policy.model;
import java.util.Iterator;
import java.util.List;
@@ -23,26 +25,24 @@
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
+import org.apache.cxf.ws.security.policy.SPConstants;
import org.apache.neethi.All;
import org.apache.neethi.ExactlyOne;
import org.apache.neethi.Policy;
import org.apache.neethi.PolicyComponent;
-import org.apache.ws.secpolicy.SP11Constants;
-import org.apache.ws.secpolicy.SP12Constants;
-import org.apache.ws.secpolicy.SPConstants;
public class SymmetricBinding extends SymmetricAsymmetricBindingBase {
private EncryptionToken encryptionToken;
-
+
private SignatureToken signatureToken;
-
+
private ProtectionToken protectionToken;
-
- public SymmetricBinding(int version) {
+
+ public SymmetricBinding(SPConstants version) {
super(version);
}
-
+
/**
* @return Returns the encryptionToken.
*/
@@ -53,10 +53,10 @@
/**
* @param encryptionToken The encryptionToken to set.
*/
- public void setEncryptionToken(EncryptionToken encryptionToken) {
- if(this.protectionToken != null) {
-// throw new WSSPolicyException("Cannot use an EncryptionToken in a " +
-// "SymmetricBinding when there is a ProtectionToken");
+ public void setEncryptionToken(EncryptionToken encryptionToken) {
+ if (this.protectionToken != null) {
+ // throw new WSSPolicyException("Cannot use an EncryptionToken in a " +
+ // "SymmetricBinding when there is a ProtectionToken");
}
this.encryptionToken = encryptionToken;
}
@@ -71,11 +71,11 @@
/**
* @param protectionToken The protectionToken to set.
*/
- public void setProtectionToken(ProtectionToken protectionToken) {
- if(this.encryptionToken != null || this.signatureToken != null) {
-// throw new WSSPolicyException("Cannot use a ProtectionToken in a " +
-// "SymmetricBinding when there is a SignatureToken or an" +
-// "EncryptionToken");
+ public void setProtectionToken(ProtectionToken protectionToken) {
+ if (this.encryptionToken != null || this.signatureToken != null) {
+ // throw new WSSPolicyException("Cannot use a ProtectionToken in a " +
+ // "SymmetricBinding when there is a SignatureToken or an" +
+ // "EncryptionToken");
}
this.protectionToken = protectionToken;
}
@@ -91,43 +91,38 @@
* @param signatureToken The signatureToken to set.
*/
public void setSignatureToken(SignatureToken signatureToken) {
- if(this.protectionToken != null) {
-// throw new WSSPolicyException("Cannot use a SignatureToken in a " +
-// "SymmetricBinding when there is a ProtectionToken");
+ if (this.protectionToken != null) {
+ // throw new WSSPolicyException("Cannot use a SignatureToken in a " +
+ // "SymmetricBinding when there is a ProtectionToken");
}
this.signatureToken = signatureToken;
}
-
+
public QName getName() {
- if ( version == SPConstants.SP_V12) {
- return SP12Constants.SYMMETRIC_BINDING;
- } else {
- return SP11Constants.SYMMETRIC_BINDING;
- }
-
+ return constants.getSymmetricBinding();
}
public PolicyComponent normalize() {
if (isNormalized()) {
return this;
}
-
+
AlgorithmSuite algorithmSuite = getAlgorithmSuite();
List configurations = algorithmSuite.getConfigurations();
-
+
Policy policy = new Policy();
ExactlyOne exactlyOne = new ExactlyOne();
-
+
All wrapper;
SymmetricBinding symmetricBinding;
-
+
for (Iterator iterator = configurations.iterator(); iterator.hasNext();) {
wrapper = new All();
- symmetricBinding = new SymmetricBinding(this.version);
-
- algorithmSuite = (AlgorithmSuite) iterator.next();
+ symmetricBinding = new SymmetricBinding(constants);
+
+ algorithmSuite = (AlgorithmSuite)iterator.next();
symmetricBinding.setAlgorithmSuite(algorithmSuite);
-
+
symmetricBinding.setEncryptionToken(getEncryptionToken());
symmetricBinding.setEntireHeadersAndBodySignatures(isEntireHeadersAndBodySignatures());
symmetricBinding.setIncludeTimestamp(isIncludeTimestamp());
@@ -139,24 +134,24 @@
symmetricBinding.setSignedEndorsingSupportingTokens(getSignedEndorsingSupportingTokens());
symmetricBinding.setSignedSupportingToken(getSignedSupportingToken());
symmetricBinding.setTokenProtection(isTokenProtection());
-
+
symmetricBinding.setNormalized(true);
wrapper.addPolicyComponent(symmetricBinding);
exactlyOne.addPolicyComponent(wrapper);
}
-
+
policy.addPolicyComponent(exactlyOne);
return policy;
}
public void serialize(XMLStreamWriter writer) throws XMLStreamException {
-
+
String localname = getName().getLocalPart();
String namespaceURI = getName().getNamespaceURI();
-
+
String prefix;
String writerPrefix = writer.getPrefix(namespaceURI);
-
+
if (writerPrefix == null) {
prefix = getName().getPrefix();
writer.setPrefix(prefix, namespaceURI);
@@ -166,76 +161,76 @@
// <sp:SymmetricBinding>
writer.writeStartElement(prefix, localname, namespaceURI);
-
+
// xmlns:sp=".."
writer.writeNamespace(prefix, namespaceURI);
-
+
String policyLocalName = SPConstants.POLICY.getLocalPart();
String policyNamespaceURI = SPConstants.POLICY.getNamespaceURI();
-
+
String wspPrefix;
-
+
String wspWriterPrefix = writer.getPrefix(policyNamespaceURI);
if (wspWriterPrefix == null) {
wspPrefix = SPConstants.POLICY.getPrefix();
writer.setPrefix(wspPrefix, policyNamespaceURI);
-
+
} else {
- wspPrefix = wspWriterPrefix;
+ wspPrefix = wspWriterPrefix;
}
// <wsp:Policy>
writer.writeStartElement(wspPrefix, policyLocalName, policyNamespaceURI);
-
+
if (encryptionToken != null) {
encryptionToken.serialize(writer);
-
- } else if ( protectionToken != null) {
+
+ } else if (protectionToken != null) {
protectionToken.serialize(writer);
-
+
} else {
throw new RuntimeException("Either EncryptionToken or ProtectionToken must be set");
}
-
+
AlgorithmSuite algorithmSuite = getAlgorithmSuite();
-
+
if (algorithmSuite == null) {
throw new RuntimeException("AlgorithmSuite must be set");
}
// <sp:AlgorithmSuite />
algorithmSuite.serialize(writer);
-
+
Layout layout = getLayout();
if (layout != null) {
// <sp:Layout />
layout.serialize(writer);
}
-
+
if (isIncludeTimestamp()) {
// <sp:IncludeTimestamp />
writer.writeStartElement(prefix, SPConstants.INCLUDE_TIMESTAMP, namespaceURI);
writer.writeEndElement();
}
-
+
if (SPConstants.ENCRYPT_BEFORE_SIGNING.equals(getProtectionOrder())) {
// <sp:EncryptBeforeSigning />
writer.writeStartElement(prefix, SPConstants.ENCRYPT_BEFORE_SIGNING, namespaceURI);
writer.writeEndElement();
}
-
+
if (isSignatureProtection()) {
// <sp:EncryptSignature />
- writer.writeStartElement(prefix, SPConstants.ENCRYPT_SIGNATURE , namespaceURI);
+ writer.writeStartElement(prefix, SPConstants.ENCRYPT_SIGNATURE, namespaceURI);
writer.writeEndElement();
}
-
- if(isEntireHeadersAndBodySignatures()) {
+
+ if (isEntireHeadersAndBodySignatures()) {
writer.writeEmptyElement(prefix, SPConstants.ONLY_SIGN_ENTIRE_HEADERS_AND_BODY, namespaceURI);
}
// </wsp:Policy>
writer.writeEndElement();
-
+
// </sp:SymmetricBinding>
writer.writeEndElement();
-
+
}
}
Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/Token.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/Token.java?rev=675332&r1=674910&r2=675332&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/Token.java (original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/Token.java Wed Jul 9 13:11:45 2008
@@ -1,62 +1,69 @@
-/*
- * Copyright 2004,2005 The Apache Software Foundation.
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
+package org.apache.cxf.ws.security.policy.model;
-package org.apache.ws.secpolicy.model;
-
-import org.apache.ws.secpolicy.SPConstants;
+import org.apache.cxf.ws.security.policy.SPConstants;
+import org.apache.cxf.ws.security.policy.SPConstants.IncludeTokenType;
public abstract class Token extends AbstractSecurityAssertion {
/**
* Inclusion property of a TokenAssertion
*/
- private int inclusion = SPConstants.INCLUDE_TOEKN_ALWAYS;
-
+ private IncludeTokenType inclusion = IncludeTokenType.INCLUDE_TOKEN_ALWAYS;
+
/**
* Whether to derive keys or not
*/
private boolean derivedKeys;
-
+
private boolean impliedDerivedKeys;
-
+
private boolean explicitDerivedKeys;
+
+ public Token(SPConstants version) {
+ super(version);
+ }
/**
* @return Returns the inclusion.
*/
- public int getInclusion() {
+ public IncludeTokenType getInclusion() {
return inclusion;
}
/**
* @param inclusion The inclusion to set.
*/
- public void setInclusion(int inclusion) {
- if(SPConstants.INCLUDE_TOEKN_ALWAYS == inclusion ||
- SPConstants.INCLUDE_TOEKN_ALWAYS_TO_RECIPIENT == inclusion ||
- SPConstants.INCLUDE_TOEKN_ALWAYS_TO_INITIATOR == inclusion ||
- SPConstants.INCLUDE_TOKEN_NEVER == inclusion ||
- SPConstants.INCLUDE_TOKEN_ONCE == inclusion ) {
+ public void setInclusion(IncludeTokenType inclusion) {
+ if (IncludeTokenType.INCLUDE_TOKEN_ALWAYS == inclusion
+ || IncludeTokenType.INCLUDE_TOKEN_ALWAYS_TO_RECIPIENT == inclusion
+ || IncludeTokenType.INCLUDE_TOKEN_ALWAYS_TO_INITIATOR == inclusion
+ || IncludeTokenType.INCLUDE_TOKEN_NEVER == inclusion
+ || IncludeTokenType.INCLUDE_TOKEN_ONCE == inclusion) {
this.inclusion = inclusion;
} else {
- //TODO replace this with a proper (WSSPolicyException) exception
+ // TODO replace this with a proper (WSSPolicyException) exception
throw new RuntimeException("Incorrect inclusion value: " + inclusion);
}
}
-
+
/**
* @return Returns the derivedKeys.
*/
@@ -69,23 +76,22 @@
*/
public void setDerivedKeys(boolean derivedKeys) {
this.derivedKeys = derivedKeys;
- }
-
-
+ }
+
public boolean isExplicitDerivedKeys() {
return explicitDerivedKeys;
}
-
+
public void setExplicitDerivedKeys(boolean explicitDerivedKeys) {
this.explicitDerivedKeys = explicitDerivedKeys;
}
-
+
public boolean isImpliedDerivedKeys() {
return impliedDerivedKeys;
}
-
+
public void setImpliedDerivedKeys(boolean impliedDerivedKeys) {
this.impliedDerivedKeys = impliedDerivedKeys;
}
-
-}
\ No newline at end of file
+
+}
Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/TokenWrapper.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/TokenWrapper.java?rev=675332&r1=674910&r2=675332&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/TokenWrapper.java (original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/TokenWrapper.java Wed Jul 9 13:11:45 2008
@@ -1,22 +1,24 @@
-/*
- * Copyright 2004,2005 The Apache Software Foundation.
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-
-package org.apache.ws.secpolicy.model;
+package org.apache.cxf.ws.security.policy.model;
public interface TokenWrapper {
- public void setToken(Token tok);
+ void setToken(Token tok);
}
Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/TransportBinding.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/TransportBinding.java?rev=675332&r1=674910&r2=675332&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/TransportBinding.java (original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/TransportBinding.java Wed Jul 9 13:11:45 2008
@@ -1,20 +1,22 @@
-/*
- * Copyright 2004,2005 The Apache Software Foundation.
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-
-package org.apache.ws.secpolicy.model;
+package org.apache.cxf.ws.security.policy.model;
import java.util.ArrayList;
import java.util.Iterator;
@@ -24,23 +26,22 @@
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
+import org.apache.cxf.ws.security.policy.SPConstants;
import org.apache.neethi.All;
import org.apache.neethi.ExactlyOne;
import org.apache.neethi.Policy;
import org.apache.neethi.PolicyComponent;
-import org.apache.ws.secpolicy.SP11Constants;
-import org.apache.ws.secpolicy.SPConstants;
-import org.apache.ws.secpolicy.SP12Constants;
public class TransportBinding extends Binding {
private TransportToken transportToken;
- private List transportBindings;
+ private List<TransportBinding> transportBindings;
- public TransportBinding(int version) {
+ public TransportBinding(SPConstants version) {
super(version);
}
+
/**
* @return Returns the transportToken.
*/
@@ -49,8 +50,7 @@
}
/**
- * @param transportToken
- * The transportToken to set.
+ * @param transportToken The transportToken to set.
*/
public void setTransportToken(TransportToken transportToken) {
this.transportToken = transportToken;
@@ -62,24 +62,20 @@
public TransportBinding getDefaultConfiguration() {
if (transportBindings != null) {
- return (TransportBinding) transportBindings.get(0);
+ return (TransportBinding)transportBindings.get(0);
}
return null;
}
public void addConfiguration(TransportBinding transportBinding) {
if (transportBindings == null) {
- transportBindings = new ArrayList();
+ transportBindings = new ArrayList<TransportBinding>();
}
transportBindings.add(transportBinding);
}
public QName getName() {
- if (version == SPConstants.SP_V12) {
- return SP12Constants.TRANSPORT_BINDING;
- } else {
- return SP11Constants.TRANSPORT_BINDING;
- }
+ return constants.getTransportBinding();
}
public PolicyComponent normalize() {
@@ -103,16 +99,14 @@
for (Iterator iterator = configurations.iterator(); iterator.hasNext();) {
wrapper = new All();
- transportBinding = new TransportBinding(this.getVersion());
+ transportBinding = new TransportBinding(constants);
- algorithmSuite = (AlgorithmSuite) iterator.next();
+ algorithmSuite = (AlgorithmSuite)iterator.next();
transportBinding.setAlgorithmSuite(algorithmSuite);
transportBinding.setIncludeTimestamp(isIncludeTimestamp());
transportBinding.setLayout(getLayout());
- transportBinding
- .setSignedEndorsingSupportingTokens(getSignedEndorsingSupportingTokens());
- transportBinding
- .setSignedSupportingToken(getSignedSupportingToken());
+ transportBinding.setSignedEndorsingSupportingTokens(getSignedEndorsingSupportingTokens());
+ transportBinding.setSignedSupportingToken(getSignedSupportingToken());
transportBinding.setTransportToken(getTransportToken());
wrapper.addPolicyComponent(transportBinding);
@@ -137,16 +131,16 @@
// <sp:TransportBinding>
writer.writeStartElement(prefix, localName, namespaceURI);
writer.writeNamespace(prefix, namespaceURI);
-
+
String pPrefix = writer.getPrefix(SPConstants.POLICY.getNamespaceURI());
if (pPrefix == null) {
pPrefix = SPConstants.POLICY.getPrefix();
writer.setPrefix(pPrefix, SPConstants.POLICY.getNamespaceURI());
}
-
+
// <wsp:Policy>
- writer.writeStartElement(pPrefix, SPConstants.POLICY.getLocalPart(), SPConstants.POLICY.getNamespaceURI());
-
+ writer.writeStartElement(pPrefix, SPConstants.POLICY.getLocalPart(), SPConstants.POLICY
+ .getNamespaceURI());
if (transportToken == null) {
// TODO more meaningful exception
@@ -179,7 +173,7 @@
writer.writeEndElement();
// </sp:IncludeTimestamp>
}
-
+
// </wsp:Policy>
writer.writeEndElement();
Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/TransportToken.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/TransportToken.java?rev=675332&r1=674910&r2=675332&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/TransportToken.java (original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/TransportToken.java Wed Jul 9 13:11:45 2008
@@ -1,52 +1,47 @@
-/*
- * Copyright 2004,2005 The Apache Software Foundation.
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-
-package org.apache.ws.secpolicy.model;
-
-import org.apache.neethi.PolicyComponent;
-import org.apache.ws.secpolicy.SP11Constants;
-import org.apache.ws.secpolicy.SP12Constants;
-import org.apache.ws.secpolicy.SPConstants;
+package org.apache.cxf.ws.security.policy.model;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
+import org.apache.cxf.ws.security.policy.SPConstants;
+import org.apache.neethi.PolicyComponent;
public class TransportToken extends AbstractSecurityAssertion implements TokenWrapper {
private Token transportToken;
-
- public TransportToken(int version){
- setVersion(version);
+
+ public TransportToken(SPConstants version) {
+ super(version);
}
-
+
/**
* @return Returns the transportToken.
*/
public Token getTransportToken() {
return transportToken;
}
-
+
public QName getName() {
- if ( version == SPConstants.SP_V12) {
- return SP12Constants.TRANSPORT_TOKEN;
- } else {
- return SP11Constants.TRANSPORT_TOKEN;
- }
+ return constants.getTransportToken();
}
public boolean isOptional() {
@@ -62,49 +57,51 @@
}
public void serialize(XMLStreamWriter writer) throws XMLStreamException {
-
+
String localName = getName().getLocalPart();
String namespaceURI = getName().getNamespaceURI();
-
+
String prefix = writer.getPrefix(namespaceURI);
-
+
if (prefix == null) {
prefix = getName().getPrefix();
writer.setPrefix(prefix, namespaceURI);
}
-
+
// <sp:TransportToken>
-
+
writer.writeStartElement(prefix, localName, namespaceURI);
-
+
String wspPrefix = writer.getPrefix(SPConstants.POLICY.getNamespaceURI());
if (wspPrefix == null) {
wspPrefix = SPConstants.POLICY.getPrefix();
writer.setPrefix(wspPrefix, SPConstants.POLICY.getNamespaceURI());
}
-
+
// <wsp:Policy>
- writer.writeStartElement(SPConstants.POLICY.getPrefix(), SPConstants.POLICY.getLocalPart(), SPConstants.POLICY.getNamespaceURI());
-
+ writer.writeStartElement(SPConstants.POLICY.getPrefix(), SPConstants.POLICY.getLocalPart(),
+ SPConstants.POLICY.getNamespaceURI());
+
// serialization of the token ..
if (transportToken != null) {
transportToken.serialize(writer);
}
-
+
// </wsp:Policy>
writer.writeEndElement();
-
-
+
writer.writeEndElement();
// </sp:TransportToken>
}
- /* (non-Javadoc)
- * @see org.apache.ws.secpolicy.model.TokenWrapper#setToken(org.apache.ws.secpolicy.model.Token)
+ /*
+ * (non-Javadoc)
+ * @see
+ * org.apache.cxf.ws.security.policy.model.TokenWrapper#setToken(org.apache.cxf.ws.security.policy.model
+ * .Token)
*/
public void setToken(Token tok) {
this.transportToken = tok;
}
-
-
+
}
Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/Trust10.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/Trust10.java?rev=675332&r1=674910&r2=675332&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/Trust10.java (original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/Trust10.java Wed Jul 9 13:11:45 2008
@@ -1,29 +1,30 @@
-/*
- * Copyright 2004,2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-
-package org.apache.ws.secpolicy.model;
+package org.apache.cxf.ws.security.policy.model;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
+import org.apache.cxf.ws.security.policy.SP11Constants;
+import org.apache.cxf.ws.security.policy.SPConstants;
import org.apache.neethi.PolicyComponent;
-import org.apache.ws.secpolicy.SP11Constants;
-import org.apache.ws.secpolicy.SPConstants;
-import org.apache.ws.secpolicy.SP12Constants;
/**
* Model bean to capture Trust10 assertion info
@@ -35,11 +36,11 @@
private boolean requireClientEntropy;
private boolean requireServerEntropy;
private boolean mustSupportIssuedTokens;
-
- public Trust10(int version){
- setVersion(version);
+
+ public Trust10(SPConstants version) {
+ super(version);
}
-
+
/**
* @return Returns the mustSupportClientChallenge.
*/
@@ -110,14 +111,16 @@
this.requireServerEntropy = requireServerEntropy;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
* @see org.apache.neethi.Assertion#getName()
*/
public QName getName() {
- return SP11Constants.TRUST_10;
+ return SP11Constants.TRUST_10;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
* @see org.apache.neethi.Assertion#isOptional()
*/
public boolean isOptional() {
@@ -130,71 +133,67 @@
}
public void serialize(XMLStreamWriter writer) throws XMLStreamException {
-
+
String localname = getName().getLocalPart();
String namespaceURI = getName().getNamespaceURI();
-
+
String prefix = writer.getPrefix(namespaceURI);
if (prefix == null) {
prefix = getName().getPrefix();
writer.setPrefix(prefix, namespaceURI);
}
-
+
// <sp:Trust10>
writer.writeStartElement(prefix, localname, namespaceURI);
// xmlns:sp=".."
writer.writeNamespace(prefix, namespaceURI);
-
+
String wspPrefix = writer.getPrefix(SPConstants.POLICY.getNamespaceURI());
if (wspPrefix == null) {
wspPrefix = SPConstants.POLICY.getPrefix();
writer.setPrefix(wspPrefix, SPConstants.POLICY.getNamespaceURI());
}
-
+
// <wsp:Policy>
- writer.writeStartElement(SPConstants.POLICY.getPrefix(), SPConstants.POLICY.getLocalPart(), SPConstants.POLICY.getNamespaceURI());
-
+ writer.writeStartElement(SPConstants.POLICY.getPrefix(), SPConstants.POLICY.getLocalPart(),
+ SPConstants.POLICY.getNamespaceURI());
+
if (isMustSupportClientChallenge()) {
// <sp:MustSupportClientChallenge />
writer.writeStartElement(prefix, SPConstants.MUST_SUPPORT_CLIENT_CHALLENGE, namespaceURI);
writer.writeEndElement();
}
-
+
if (isMustSupportServerChallenge()) {
// <sp:MustSupportServerChallenge />
writer.writeStartElement(prefix, SPConstants.MUST_SUPPORT_SERVER_CHALLENGE, namespaceURI);
writer.writeEndElement();
}
-
+
if (isRequireClientEntropy()) {
// <sp:RequireClientEntropy />
writer.writeStartElement(prefix, SPConstants.REQUIRE_CLIENT_ENTROPY, namespaceURI);
writer.writeEndElement();
}
-
-
+
if (isRequireServerEntropy()) {
// <sp:RequireServerEntropy />
writer.writeStartElement(prefix, SPConstants.REQUIRE_SERVER_ENTROPY, namespaceURI);
writer.writeEndElement();
}
-
+
if (isMustSupportIssuedTokens()) {
// <sp:MustSupportIssuedTokens />
writer.writeStartElement(prefix, SPConstants.MUST_SUPPORT_ISSUED_TOKENS, namespaceURI);
writer.writeEndElement();
}
-
+
// </wsp:Policy>
writer.writeEndElement();
-
-
+
// </sp:Trust10>
writer.writeEndElement();
-
-
-
-
+
}
public short getType() {
Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/Trust13.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/Trust13.java?rev=675332&r1=674910&r2=675332&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/Trust13.java (original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/Trust13.java Wed Jul 9 13:11:45 2008
@@ -1,29 +1,30 @@
-/*
- * Copyright 2004,2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-
-package org.apache.ws.secpolicy.model;
+package org.apache.cxf.ws.security.policy.model;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
+import org.apache.cxf.ws.security.policy.SP12Constants;
+import org.apache.cxf.ws.security.policy.SPConstants;
import org.apache.neethi.PolicyComponent;
-import org.apache.ws.secpolicy.SP11Constants;
-import org.apache.ws.secpolicy.SPConstants;
-import org.apache.ws.secpolicy.SP12Constants;
/**
* Model bean to capture Trust10 assertion info
@@ -37,11 +38,11 @@
private boolean mustSupportIssuedTokens;
private boolean requireRequestSecurityTokenCollection;
private boolean requireAppliesTo;
-
- public Trust13(int version){
- setVersion(version);
+
+ public Trust13(SPConstants version) {
+ super(version);
}
-
+
/**
* @return Returns the mustSupportClientChallenge.
*/
@@ -111,7 +112,7 @@
public void setRequireServerEntropy(boolean requireServerEntropy) {
this.requireServerEntropy = requireServerEntropy;
}
-
+
/**
* @return Returns the requireRequestSecurityTokenCollection.
*/
@@ -125,7 +126,7 @@
public void setRequireRequestSecurityTokenCollection(boolean requireRequestSecurityTokenCollection) {
this.requireRequestSecurityTokenCollection = requireRequestSecurityTokenCollection;
}
-
+
/**
* @return Returns the requireAppliesTo.
*/
@@ -140,14 +141,16 @@
this.requireAppliesTo = requireAppliesTo;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
* @see org.apache.neethi.Assertion#getName()
*/
public QName getName() {
- return SP12Constants.TRUST_13;
+ return SP12Constants.TRUST_13;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
* @see org.apache.neethi.Assertion#isOptional()
*/
public boolean isOptional() {
@@ -160,84 +163,81 @@
}
public void serialize(XMLStreamWriter writer) throws XMLStreamException {
-
+
String localname = getName().getLocalPart();
String namespaceURI = getName().getNamespaceURI();
-
+
String prefix = writer.getPrefix(namespaceURI);
if (prefix == null) {
prefix = getName().getPrefix();
writer.setPrefix(prefix, namespaceURI);
}
-
+
// <sp:Trust13>
writer.writeStartElement(prefix, localname, namespaceURI);
// xmlns:sp=".."
writer.writeNamespace(prefix, namespaceURI);
-
+
String wspPrefix = writer.getPrefix(SPConstants.POLICY.getNamespaceURI());
-
+
if (wspPrefix == null) {
wspPrefix = SPConstants.POLICY.getPrefix();
writer.setPrefix(wspPrefix, SPConstants.POLICY.getNamespaceURI());
}
-
+
// <wsp:Policy>
- writer.writeStartElement(SPConstants.POLICY.getPrefix(), SPConstants.POLICY.getLocalPart(), SPConstants.POLICY.getNamespaceURI());
-
+ writer.writeStartElement(SPConstants.POLICY.getPrefix(), SPConstants.POLICY.getLocalPart(),
+ SPConstants.POLICY.getNamespaceURI());
+
if (isMustSupportClientChallenge()) {
// <sp:MustSupportClientChallenge />
writer.writeStartElement(prefix, SPConstants.MUST_SUPPORT_CLIENT_CHALLENGE, namespaceURI);
writer.writeEndElement();
}
-
+
if (isMustSupportServerChallenge()) {
// <sp:MustSupportServerChallenge />
writer.writeStartElement(prefix, SPConstants.MUST_SUPPORT_SERVER_CHALLENGE, namespaceURI);
writer.writeEndElement();
}
-
+
if (isRequireClientEntropy()) {
// <sp:RequireClientEntropy />
writer.writeStartElement(prefix, SPConstants.REQUIRE_CLIENT_ENTROPY, namespaceURI);
writer.writeEndElement();
}
-
-
+
if (isRequireServerEntropy()) {
// <sp:RequireServerEntropy />
writer.writeStartElement(prefix, SPConstants.REQUIRE_SERVER_ENTROPY, namespaceURI);
writer.writeEndElement();
}
-
+
if (isMustSupportIssuedTokens()) {
// <sp:MustSupportIssuedTokens />
writer.writeStartElement(prefix, SPConstants.MUST_SUPPORT_ISSUED_TOKENS, namespaceURI);
writer.writeEndElement();
}
-
+
if (isRequireRequestSecurityTokenCollection()) {
// <sp:RequireRequestSecurityTokenCollection />
- writer.writeStartElement(prefix, SPConstants.REQUIRE_REQUEST_SECURITY_TOKEN_COLLECTION, namespaceURI);
+ writer.writeStartElement(prefix, SPConstants.REQUIRE_REQUEST_SECURITY_TOKEN_COLLECTION,
+ namespaceURI);
writer.writeEndElement();
}
-
+
if (isRequireAppliesTo()) {
// <sp:RequireAppliesTo />
writer.writeStartElement(prefix, SPConstants.REQUIRE_APPLIES_TO, namespaceURI);
writer.writeEndElement();
}
-
+
// </wsp:Policy>
writer.writeEndElement();
-
-
+
// </sp:Trust13>
writer.writeEndElement();
-
-
-
-
+
}
public short getType() {
Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/UsernameToken.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/UsernameToken.java?rev=675332&r1=674910&r2=675332&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/UsernameToken.java (original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/UsernameToken.java Wed Jul 9 13:11:45 2008
@@ -1,42 +1,42 @@
-/*
- * Copyright 2004,2005 The Apache Software Foundation.
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-
-package org.apache.ws.secpolicy.model;
+package org.apache.cxf.ws.security.policy.model;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
+import org.apache.cxf.ws.security.policy.SPConstants;
import org.apache.neethi.PolicyComponent;
-import org.apache.ws.secpolicy.SP11Constants;
-import org.apache.ws.secpolicy.SPConstants;
-import org.apache.ws.secpolicy.SP12Constants;
public class UsernameToken extends Token {
- private boolean useUTProfile10 = false;
+ private boolean useUTProfile10;
+
+ private boolean useUTProfile11;
- private boolean useUTProfile11 = false;
-
private boolean noPassword;
-
+
private boolean hashPassword;
-
- public UsernameToken(int version){
- setVersion(version);
+
+ public UsernameToken(SPConstants version) {
+ super(version);
}
/**
@@ -47,25 +47,24 @@
}
/**
- * @param useUTProfile11
- * The useUTProfile11 to set.
+ * @param useUTProfile11 The useUTProfile11 to set.
*/
public void setUseUTProfile11(boolean useUTProfile11) {
this.useUTProfile11 = useUTProfile11;
}
-
+
public boolean isNoPassword() {
return noPassword;
}
-
+
public void setNoPassword(boolean noPassword) {
this.noPassword = noPassword;
}
-
+
public boolean isHashPassword() {
return hashPassword;
}
-
+
public void setHashPassword(boolean hashPassword) {
this.hashPassword = hashPassword;
}
@@ -79,11 +78,7 @@
}
public QName getName() {
- if (version == SPConstants.SP_V12) {
- return SP12Constants.USERNAME_TOKEN;
- } else {
- return SP11Constants.USERNAME_TOKEN;
- }
+ return constants.getUserNameToken();
}
public PolicyComponent normalize() {
@@ -106,59 +101,53 @@
writer.writeNamespace(prefix, namespaceURI);
String inclusion;
-
- if (version == SPConstants.SP_V12) {
- inclusion = SP12Constants.getAttributeValueFromInclusion(getInclusion());
- } else {
- inclusion = SP11Constants.getAttributeValueFromInclusion(getInclusion());
- }
+
+ inclusion = constants.getAttributeValueFromInclusion(getInclusion());
if (inclusion != null) {
writer.writeAttribute(prefix, namespaceURI, SPConstants.ATTR_INCLUDE_TOKEN, inclusion);
}
if (isUseUTProfile10() || isUseUTProfile11()) {
- String pPrefix = writer.getPrefix(SPConstants.POLICY
- .getNamespaceURI());
+ String pPrefix = writer.getPrefix(SPConstants.POLICY.getNamespaceURI());
if (pPrefix == null) {
- writer.setPrefix(SPConstants.POLICY.getPrefix(), SPConstants.POLICY
- .getNamespaceURI());
+ writer.setPrefix(SPConstants.POLICY.getPrefix(), SPConstants.POLICY.getNamespaceURI());
}
// <wsp:Policy>
- writer.writeStartElement(prefix, SPConstants.POLICY.getLocalPart(),
- SPConstants.POLICY.getNamespaceURI());
+ writer.writeStartElement(prefix, SPConstants.POLICY.getLocalPart(), SPConstants.POLICY
+ .getNamespaceURI());
// CHECKME
if (isUseUTProfile10()) {
// <sp:WssUsernameToken10 />
- writer.writeStartElement(prefix, SPConstants.USERNAME_TOKEN10 , namespaceURI);
+ writer.writeStartElement(prefix, SPConstants.USERNAME_TOKEN10, namespaceURI);
} else {
// <sp:WssUsernameToken11 />
- writer.writeStartElement(prefix, SPConstants.USERNAME_TOKEN11 , namespaceURI);
+ writer.writeStartElement(prefix, SPConstants.USERNAME_TOKEN11, namespaceURI);
}
-
- if (version == SPConstants.SP_V12) {
-
+
+ if (constants.getVersion() == SPConstants.Version.SP_V12) {
+
if (isNoPassword()) {
writer.writeStartElement(prefix, SPConstants.NO_PASSWORD, namespaceURI);
- writer.writeEndElement();
- } else if (isHashPassword()){
+ writer.writeEndElement();
+ } else if (isHashPassword()) {
writer.writeStartElement(prefix, SPConstants.HASH_PASSWORD, namespaceURI);
- writer.writeEndElement();
+ writer.writeEndElement();
}
-
+
if (isDerivedKeys()) {
writer.writeStartElement(prefix, SPConstants.REQUIRE_DERIVED_KEYS, namespaceURI);
- writer.writeEndElement();
+ writer.writeEndElement();
} else if (isExplicitDerivedKeys()) {
writer.writeStartElement(prefix, SPConstants.REQUIRE_EXPLICIT_DERIVED_KEYS, namespaceURI);
- writer.writeEndElement();
+ writer.writeEndElement();
} else if (isImpliedDerivedKeys()) {
writer.writeStartElement(prefix, SPConstants.REQUIRE_IMPLIED_DERIVED_KEYS, namespaceURI);
- writer.writeEndElement();
+ writer.writeEndElement();
}
-
+
}
writer.writeEndElement();
Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/Wss10.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/Wss10.java?rev=675332&r1=674910&r2=675332&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/Wss10.java (original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/Wss10.java Wed Jul 9 13:11:45 2008
@@ -1,102 +1,105 @@
-/*
- * Copyright 2004,2005 The Apache Software Foundation.
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-
-package org.apache.ws.secpolicy.model;
+package org.apache.cxf.ws.security.policy.model;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
+import org.apache.cxf.ws.security.policy.SPConstants;
import org.apache.neethi.PolicyComponent;
-import org.apache.ws.secpolicy.SP11Constants;
-import org.apache.ws.secpolicy.SP12Constants;
-import org.apache.ws.secpolicy.SPConstants;
public class Wss10 extends AbstractSecurityAssertion {
-
+
private boolean mustSupportRefKeyIdentifier;
- private boolean MustSupportRefIssuerSerial;
- private boolean MustSupportRefExternalURI;
- private boolean MustSupportRefEmbeddedToken;
-
- public Wss10(int version) {
- setVersion(version);
+ private boolean mustSupportRefIssuerSerial;
+ private boolean mustSupportRefExternalURI;
+ private boolean mustSupportRefEmbeddedToken;
+
+ public Wss10(SPConstants version) {
+ super(version);
}
-
+
/**
* @return Returns the mustSupportRefEmbeddedToken.
*/
public boolean isMustSupportRefEmbeddedToken() {
- return MustSupportRefEmbeddedToken;
+ return mustSupportRefEmbeddedToken;
}
+
/**
* @param mustSupportRefEmbeddedToken The mustSupportRefEmbeddedToken to set.
*/
public void setMustSupportRefEmbeddedToken(boolean mustSupportRefEmbeddedToken) {
- MustSupportRefEmbeddedToken = mustSupportRefEmbeddedToken;
+ this.mustSupportRefEmbeddedToken = mustSupportRefEmbeddedToken;
}
+
/**
* @return Returns the mustSupportRefExternalURI.
*/
public boolean isMustSupportRefExternalURI() {
- return MustSupportRefExternalURI;
+ return mustSupportRefExternalURI;
}
+
/**
* @param mustSupportRefExternalURI The mustSupportRefExternalURI to set.
*/
public void setMustSupportRefExternalURI(boolean mustSupportRefExternalURI) {
- MustSupportRefExternalURI = mustSupportRefExternalURI;
+ this.mustSupportRefExternalURI = mustSupportRefExternalURI;
}
+
/**
* @return Returns the mustSupportRefIssuerSerial.
*/
public boolean isMustSupportRefIssuerSerial() {
- return MustSupportRefIssuerSerial;
+ return mustSupportRefIssuerSerial;
}
+
/**
* @param mustSupportRefIssuerSerial The mustSupportRefIssuerSerial to set.
*/
public void setMustSupportRefIssuerSerial(boolean mustSupportRefIssuerSerial) {
- MustSupportRefIssuerSerial = mustSupportRefIssuerSerial;
+ this.mustSupportRefIssuerSerial = mustSupportRefIssuerSerial;
}
+
/**
* @return Returns the mustSupportRefKeyIdentifier.
*/
public boolean isMustSupportRefKeyIdentifier() {
return mustSupportRefKeyIdentifier;
}
+
/**
* @param mustSupportRefKeyIdentifier The mustSupportRefKeyIdentifier to set.
*/
public void setMustSupportRefKeyIdentifier(boolean mustSupportRefKeyIdentifier) {
this.mustSupportRefKeyIdentifier = mustSupportRefKeyIdentifier;
}
-
+
public QName getName() {
- if ( version == SPConstants.SP_V12 ) {
- return SP12Constants.WSS10;
- } else {
- return SP11Constants.WSS10;
- }
+ return constants.getWSS10();
}
-
+
public PolicyComponent normalize() {
return this;
}
-
+
public void serialize(XMLStreamWriter writer) throws XMLStreamException {
String localname = getName().getLocalPart();
String namespaceURI = getName().getNamespaceURI();
@@ -109,47 +112,47 @@
// <sp:Wss10>
writer.writeStartElement(prefix, localname, namespaceURI);
-
+
// xmlns:sp=".."
writer.writeNamespace(prefix, namespaceURI);
-
+
String pPrefix = writer.getPrefix(SPConstants.POLICY.getNamespaceURI());
if (pPrefix == null) {
writer.setPrefix(SPConstants.POLICY.getPrefix(), SPConstants.POLICY.getNamespaceURI());
}
-
+
// <wsp:Policy>
- writer.writeStartElement(prefix, SPConstants.POLICY.getLocalPart(), SPConstants.POLICY.getNamespaceURI());
-
+ writer.writeStartElement(prefix, SPConstants.POLICY.getLocalPart(), SPConstants.POLICY
+ .getNamespaceURI());
+
if (isMustSupportRefKeyIdentifier()) {
// <sp:MustSupportRefKeyIdentifier />
writer.writeStartElement(prefix, SPConstants.MUST_SUPPORT_REF_KEY_IDENTIFIER, namespaceURI);
writer.writeEndElement();
}
-
+
if (isMustSupportRefIssuerSerial()) {
// <sp:MustSupportRefIssuerSerial />
writer.writeStartElement(prefix, SPConstants.MUST_SUPPORT_REF_ISSUER_SERIAL, namespaceURI);
writer.writeEndElement();
}
-
+
if (isMustSupportRefExternalURI()) {
// <sp:MustSupportRefExternalURI />
writer.writeStartElement(prefix, SPConstants.MUST_SUPPORT_REF_EXTERNAL_URI, namespaceURI);
writer.writeEndElement();
}
-
+
if (isMustSupportRefEmbeddedToken()) {
// <sp:MustSupportRefEmbeddedToken />
writer.writeStartElement(prefix, SPConstants.MUST_SUPPORT_REF_EMBEDDED_TOKEN, namespaceURI);
writer.writeEndElement();
-
}
-
+
// </wsp:Policy>
writer.writeEndElement();
-
+
// </sp:Wss10>
writer.writeEndElement();
Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/Wss11.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/Wss11.java?rev=675332&r1=674910&r2=675332&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/Wss11.java (original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/Wss11.java Wed Jul 9 13:11:45 2008
@@ -1,84 +1,85 @@
-/*
- * Copyright 2004,2005 The Apache Software Foundation.
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-
-package org.apache.ws.secpolicy.model;
+package org.apache.cxf.ws.security.policy.model;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
-import org.apache.ws.secpolicy.SP11Constants;
-import org.apache.ws.secpolicy.SP12Constants;
-import org.apache.ws.secpolicy.SPConstants;
+import org.apache.cxf.ws.security.policy.SPConstants;
public class Wss11 extends Wss10 {
-
- private boolean MustSupportRefThumbprint;
- private boolean MustSupportRefEncryptedKey;
- private boolean RequireSignatureConfirmation;
-
- public Wss11(int version) {
+
+ private boolean mustSupportRefThumbprint;
+ private boolean mustSupportRefEncryptedKey;
+ private boolean requireSignatureConfirmation;
+
+ public Wss11(SPConstants version) {
super(version);
}
-
+
/**
* @return Returns the mustSupportRefEncryptedKey.
*/
public boolean isMustSupportRefEncryptedKey() {
- return MustSupportRefEncryptedKey;
+ return mustSupportRefEncryptedKey;
}
+
/**
* @param mustSupportRefEncryptedKey The mustSupportRefEncryptedKey to set.
*/
public void setMustSupportRefEncryptedKey(boolean mustSupportRefEncryptedKey) {
- MustSupportRefEncryptedKey = mustSupportRefEncryptedKey;
+ this.mustSupportRefEncryptedKey = mustSupportRefEncryptedKey;
}
+
/**
* @return Returns the mustSupportRefThumbprint.
*/
public boolean isMustSupportRefThumbprint() {
- return MustSupportRefThumbprint;
+ return mustSupportRefThumbprint;
}
+
/**
* @param mustSupportRefThumbprint The mustSupportRefThumbprint to set.
*/
public void setMustSupportRefThumbprint(boolean mustSupportRefThumbprint) {
- MustSupportRefThumbprint = mustSupportRefThumbprint;
+ this.mustSupportRefThumbprint = mustSupportRefThumbprint;
}
+
/**
* @return Returns the requireSignatureConfirmation.
*/
public boolean isRequireSignatureConfirmation() {
- return RequireSignatureConfirmation;
+ return requireSignatureConfirmation;
}
+
/**
* @param requireSignatureConfirmation The requireSignatureConfirmation to set.
*/
public void setRequireSignatureConfirmation(boolean requireSignatureConfirmation) {
- RequireSignatureConfirmation = requireSignatureConfirmation;
+ this.requireSignatureConfirmation = requireSignatureConfirmation;
}
-
+
public QName getName() {
- if ( version == SPConstants.SP_V12 ) {
- return SP12Constants.WSS11;
- } else {
- return SP11Constants.WSS11;
- }
+ return constants.getWSS11();
}
-
+
public void serialize(XMLStreamWriter writer) throws XMLStreamException {
String localname = getName().getLocalPart();
String namespaceURI = getName().getNamespaceURI();
@@ -91,63 +92,64 @@
// <sp:Wss11>
writer.writeStartElement(prefix, localname, namespaceURI);
-
+
// xmlns:sp=".."
writer.writeNamespace(prefix, namespaceURI);
-
+
String pPrefix = writer.getPrefix(SPConstants.POLICY.getNamespaceURI());
if (pPrefix == null) {
writer.setPrefix(SPConstants.POLICY.getPrefix(), SPConstants.POLICY.getNamespaceURI());
}
-
+
// <wsp:Policy>
- writer.writeStartElement(prefix, SPConstants.POLICY.getLocalPart(), SPConstants.POLICY.getNamespaceURI());
-
+ writer.writeStartElement(prefix, SPConstants.POLICY.getLocalPart(), SPConstants.POLICY
+ .getNamespaceURI());
+
// <sp:MustSupportRefKeyIndentifier />
if (isMustSupportRefKeyIdentifier()) {
- writer.writeStartElement(prefix, SPConstants.MUST_SUPPORT_REF_KEY_IDENTIFIER , namespaceURI);
+ writer.writeStartElement(prefix, SPConstants.MUST_SUPPORT_REF_KEY_IDENTIFIER, namespaceURI);
writer.writeEndElement();
}
-
+
if (isMustSupportRefIssuerSerial()) {
// <sp:MustSupportRefIssuerSerial />
- writer.writeStartElement(prefix, SPConstants.MUST_SUPPORT_REF_ISSUER_SERIAL , namespaceURI);
+ writer.writeStartElement(prefix, SPConstants.MUST_SUPPORT_REF_ISSUER_SERIAL, namespaceURI);
writer.writeEndElement();
}
-
+
if (isMustSupportRefExternalURI()) {
// <sp:MustSupportRefExternalURI />
- writer.writeStartElement(prefix, SPConstants.MUST_SUPPORT_REF_EXTERNAL_URI , namespaceURI);
+ writer.writeStartElement(prefix, SPConstants.MUST_SUPPORT_REF_EXTERNAL_URI, namespaceURI);
writer.writeEndElement();
}
-
+
if (isMustSupportRefEmbeddedToken()) {
// <sp:MustSupportRefEmbeddedToken />
- writer.writeStartElement(prefix, SPConstants.MUST_SUPPORT_REF_EMBEDDED_TOKEN , namespaceURI);
+ writer.writeStartElement(prefix, SPConstants.MUST_SUPPORT_REF_EMBEDDED_TOKEN, namespaceURI);
writer.writeEndElement();
}
-
+
if (isMustSupportRefThumbprint()) {
// <sp:MustSupportRefThumbprint />
- writer.writeStartElement(prefix, SPConstants.MUST_SUPPORT_REF_THUMBPRINT , namespaceURI);
+ writer.writeStartElement(prefix, SPConstants.MUST_SUPPORT_REF_THUMBPRINT, namespaceURI);
writer.writeEndElement();
}
-
+
if (isMustSupportRefEncryptedKey()) {
// <sp:MustSupportRefEncryptedKey />
- writer.writeStartElement(prefix, SPConstants.MUST_SUPPORT_REF_ENCRYPTED_KEY , namespaceURI);
+ writer.writeStartElement(prefix, SPConstants.MUST_SUPPORT_REF_ENCRYPTED_KEY, namespaceURI);
writer.writeEndElement();
}
-
+
if (isRequireSignatureConfirmation()) {
// <sp:RequireSignatureConfirmation />
- writer.writeStartElement(prefix, SPConstants.REQUIRE_SIGNATURE_CONFIRMATION , namespaceURI);
+ writer.writeStartElement(prefix, SPConstants.REQUIRE_SIGNATURE_CONFIRMATION, namespaceURI);
writer.writeEndElement();
}
-
+
// </wsp:Policy>
writer.writeEndElement();
-
+
// </sp:Wss11>
writer.writeEndElement();
}
Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/X509Token.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/X509Token.java?rev=675332&r1=674910&r2=675332&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/X509Token.java (original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/X509Token.java Wed Jul 9 13:11:45 2008
@@ -1,47 +1,47 @@
-/*
- * Copyright 2004,2005 The Apache Software Foundation.
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-
-package org.apache.ws.secpolicy.model;
+package org.apache.cxf.ws.security.policy.model;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
+import org.apache.cxf.ws.security.policy.SPConstants;
import org.apache.neethi.PolicyComponent;
-import org.apache.ws.secpolicy.Constants;
-import org.apache.ws.secpolicy.SP11Constants;
-import org.apache.ws.secpolicy.SP12Constants;
-import org.apache.ws.secpolicy.SPConstants;
public class X509Token extends Token {
-
- private boolean requireKeyIdentifierReference;
- private boolean requireIssuerSerialReference;
+ private boolean requireKeyIdentifierReference;
+
+ private boolean requireIssuerSerialReference;
+
private boolean requireEmbeddedTokenReference;
-
+
private boolean requireThumbprintReference;
-
- private String tokenVersionAndType = Constants.WSS_X509_V3_TOKEN10;
-
- public X509Token(int version) {
- setVersion(version);
+
+ private String tokenVersionAndType = SPConstants.WSS_X509_V3_TOKEN10;
+
+ public X509Token(SPConstants version) {
+ super(version);
}
-
+
/**
* @return Returns the requireEmbeddedTokenReference.
*/
@@ -52,8 +52,7 @@
/**
* @param requireEmbeddedTokenReference The requireEmbeddedTokenReference to set.
*/
- public void setRequireEmbeddedTokenReference(
- boolean requireEmbeddedTokenReference) {
+ public void setRequireEmbeddedTokenReference(boolean requireEmbeddedTokenReference) {
this.requireEmbeddedTokenReference = requireEmbeddedTokenReference;
}
@@ -81,8 +80,7 @@
/**
* @param requireKeyIdentifierReference The requireKeyIdentifierReference to set.
*/
- public void setRequireKeyIdentifierReference(
- boolean requireKeyIdentifierReference) {
+ public void setRequireKeyIdentifierReference(boolean requireKeyIdentifierReference) {
this.requireKeyIdentifierReference = requireKeyIdentifierReference;
}
@@ -115,11 +113,7 @@
}
public QName getName() {
- if ( version == SPConstants.SP_V12) {
- return SP12Constants.X509_TOKEN;
- } else {
- return SP11Constants.X509_TOKEN;
- }
+ return constants.getX509Token();
}
public PolicyComponent normalize() {
@@ -136,73 +130,69 @@
prefix = getName().getPrefix();
writer.setPrefix(prefix, namespaceURI);
}
-
- // <sp:X509Token>
+
+ // <sp:X509Token>
writer.writeStartElement(prefix, localName, namespaceURI);
-
+
String inclusion;
-
- if (version == SPConstants.SP_V12) {
- inclusion = SP12Constants.getAttributeValueFromInclusion(getInclusion());
- } else {
- inclusion = SP11Constants.getAttributeValueFromInclusion(getInclusion());
- }
-
+
+ inclusion = constants.getAttributeValueFromInclusion(getInclusion());
+
if (inclusion != null) {
- writer.writeAttribute(prefix, namespaceURI, SPConstants.ATTR_INCLUDE_TOKEN , inclusion);
+ writer.writeAttribute(prefix, namespaceURI, SPConstants.ATTR_INCLUDE_TOKEN, inclusion);
}
-
-
+
String pPrefix = writer.getPrefix(SPConstants.POLICY.getNamespaceURI());
if (pPrefix == null) {
pPrefix = SPConstants.POLICY.getPrefix();
writer.setPrefix(pPrefix, SPConstants.POLICY.getNamespaceURI());
}
-
+
// <wsp:Policy>
- writer.writeStartElement(pPrefix, SPConstants.POLICY.getLocalPart(), SPConstants.POLICY.getNamespaceURI());
-
+ writer.writeStartElement(pPrefix, SPConstants.POLICY.getLocalPart(), SPConstants.POLICY
+ .getNamespaceURI());
+
if (isRequireKeyIdentifierReference()) {
// <sp:RequireKeyIdentifierReference />
writer.writeStartElement(prefix, SPConstants.REQUIRE_KEY_IDENTIFIRE_REFERENCE, namespaceURI);
writer.writeEndElement();
}
-
+
if (isRequireIssuerSerialReference()) {
// <sp:RequireIssuerSerialReference />
writer.writeStartElement(prefix, SPConstants.REQUIRE_ISSUER_SERIAL_REFERENCE, namespaceURI);
writer.writeEndElement();
}
-
+
if (isRequireEmbeddedTokenReference()) {
// <sp:RequireEmbeddedTokenReference />
writer.writeStartElement(prefix, SPConstants.REQUIRE_EMBEDDED_TOKEN_REFERENCE, namespaceURI);
writer.writeEndElement();
}
-
+
if (isRequireThumbprintReference()) {
// <sp:RequireThumbprintReference />
writer.writeStartElement(prefix, SPConstants.REQUIRE_THUMBPRINT_REFERENCE, namespaceURI);
writer.writeEndElement();
}
-
+
if (tokenVersionAndType != null) {
// <sp:WssX509V1Token10 /> | ..
writer.writeStartElement(prefix, tokenVersionAndType, namespaceURI);
writer.writeEndElement();
}
-
- if(isDerivedKeys()) {
+
+ if (isDerivedKeys()) {
// <sp:RequireDerivedKeys/>
writer.writeStartElement(prefix, SPConstants.REQUIRE_DERIVED_KEYS, namespaceURI);
writer.writeEndElement();
}
-
+
// </wsp:Policy>
writer.writeEndElement();
-
+
// </sp:X509Token>
writer.writeEndElement();
}
-
+
}