axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ruchi...@apache.org
Subject svn commit: r439246 - in /webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/builder: ./ EncryptionBuilder.java SignatureBuilder.java TimestampBuilder.java
Date Fri, 01 Sep 2006 09:24:40 GMT
Author: ruchithf
Date: Fri Sep  1 02:24:39 2006
New Revision: 439246

URL: http://svn.apache.org/viewvc?rev=439246&view=rev
Log:
Oops ... missed the builder package

Added:
    webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/builder/
    webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/builder/EncryptionBuilder.java
    webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/builder/SignatureBuilder.java
    webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/builder/TimestampBuilder.java

Added: webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/builder/EncryptionBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/builder/EncryptionBuilder.java?rev=439246&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/builder/EncryptionBuilder.java
(added)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/builder/EncryptionBuilder.java
Fri Sep  1 02:24:39 2006
@@ -0,0 +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
+ *
+ *      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.
+ */
+
+package org.apache.rampart.builder;
+
+import org.apache.rampart.RampartException;
+import org.apache.rampart.RampartMessageData;
+
+/**
+ *
+ */
+public class EncryptionBuilder {
+    
+    public void build(RampartMessageData messageData) throws RampartException {
+        //TODO
+    }
+}

Added: webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/builder/SignatureBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/builder/SignatureBuilder.java?rev=439246&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/builder/SignatureBuilder.java
(added)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/builder/SignatureBuilder.java
Fri Sep  1 02:24:39 2006
@@ -0,0 +1,90 @@
+/*
+ * 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
+ *
+ *      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.
+ */
+
+package org.apache.rampart.builder;
+
+import org.apache.axis2.context.MessageContext;
+import org.apache.rampart.RampartException;
+import org.apache.rampart.RampartMessageData;
+import org.apache.rampart.util.RampartUtil;
+import org.apache.ws.secpolicy.model.Token;
+import org.apache.ws.secpolicy.model.X509Token;
+import org.apache.ws.security.WSPasswordCallback;
+import org.apache.ws.security.handler.WSHandlerConstants;
+import org.apache.ws.security.message.WSSecDKSign;
+import org.apache.ws.security.message.WSSecSignature;
+
+import javax.security.auth.callback.CallbackHandler;
+
+/**
+ *
+ */
+public class SignatureBuilder {
+
+    public void build(RampartMessageData messageData) throws RampartException {
+        
+        Token initiatorToken = messageData.getPolicyData().getInitiatorToken();
+        
+        //TODO:Handle different initiator token types here
+        
+        //Create message
+        if(!initiatorToken.isDerivedKeys() && initiatorToken instanceof X509Token
) {
+            WSSecSignature wsSign = new WSSecSignature();
+            wsSign.setWsConfig(messageData.getConfig());
+    
+            int keyIdentifier = RampartUtil.getKeyIdentifier((X509Token)initiatorToken);
+            if (keyIdentifier != 0) {
+                wsSign.setKeyIdentifierType(keyIdentifier);
+            }
+            String asymmSignature = messageData.getPolicyData()
+                    .getAlgorithmSuite().getAsymmetricSignature();
+            
+            if (asymmSignature != null) {
+                wsSign.setSignatureAlgorithm(asymmSignature);
+            }
+    
+            MessageContext msgCtx = messageData.getMsgContext();
+            
+            CallbackHandler handler = RampartUtil.getPasswordCB(msgCtx
+                    .getAxisService().getClassLoader(), messageData
+                    .getPolicyData().getRampartConfig().getPwCbClass());
+            
+            if(handler == null) {
+                //If not found then try to find a call back handler instance located in the
message context
+                
+                handler = (CallbackHandler)msgCtx.getProperty(WSHandlerConstants.PW_CALLBACK_REF);
+            }
+            
+            if(handler == null) {
+                throw new RampartException("missingCallbackHandler");
+            }
+            
+            String user = messageData.getPolicyData().getRampartConfig()
+                    .getUser();
+            wsSign.setUserInfo(user, RampartUtil.performCallback(handler, user,
+                    WSPasswordCallback.SIGNATURE).getPassword());
+            
+            if (messageData.getSignatureParts().size() > 0) {
+                wsSign.setParts(messageData.getSignatureParts());
+            }
+        } else {
+            WSSecDKSign dkSig = new WSSecDKSign();
+            //TODO: Handle derieved key signature
+            
+        }
+    }
+
+}

Added: webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/builder/TimestampBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/builder/TimestampBuilder.java?rev=439246&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/builder/TimestampBuilder.java
(added)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/builder/TimestampBuilder.java
Fri Sep  1 02:24:39 2006
@@ -0,0 +1,55 @@
+/*
+ * 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
+ *
+ *      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.
+ */
+
+package org.apache.rampart.builder;
+
+import org.apache.rampart.RampartException;
+import org.apache.rampart.RampartMessageData;
+import org.apache.ws.security.message.WSSecTimestamp;
+
+/**
+ *
+ */
+public class TimestampBuilder {
+
+    public void build(RampartMessageData messageData) throws RampartException {
+        WSSecTimestamp timeStampBuilder = new WSSecTimestamp();
+        timeStampBuilder.setWsConfig(messageData.getConfig());
+
+        timeStampBuilder.setTimeToLive(getTimeToLive(messageData));
+        // add the Timestamp to the SOAP Enevelope
+        timeStampBuilder.build(messageData.getDocument(), messageData
+                .getSecHeader());
+    }
+
+    private int getTimeToLive(RampartMessageData messageData) {
+
+        String ttl = messageData.getPolicyData().getRampartConfig()
+                .getTimestampTTL();
+        int ttl_i = 0;
+        if (ttl != null) {
+            try {
+                ttl_i = Integer.parseInt(ttl);
+            } catch (NumberFormatException e) {
+                ttl_i = messageData.getTimeToLive();
+            }
+        }
+        if (ttl_i <= 0) {
+            ttl_i = messageData.getTimeToLive();
+        }
+        return ttl_i;
+    }
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message