You are viewing a plain text version of this content. The canonical link for it is here.
Posted to rampart-dev@ws.apache.org by na...@apache.org on 2008/02/08 14:27:09 UTC

svn commit: r619875 - /webservices/rampart/trunk/java/modules/rampart-policy/src/main/java/org/apache/ws/secpolicy/model/SupportingToken.java

Author: nandana
Date: Fri Feb  8 05:27:05 2008
New Revision: 619875

URL: http://svn.apache.org/viewvc?rev=619875&view=rev
Log:
adding encrypted supporting token support

Modified:
    webservices/rampart/trunk/java/modules/rampart-policy/src/main/java/org/apache/ws/secpolicy/model/SupportingToken.java

Modified: webservices/rampart/trunk/java/modules/rampart-policy/src/main/java/org/apache/ws/secpolicy/model/SupportingToken.java
URL: http://svn.apache.org/viewvc/webservices/rampart/trunk/java/modules/rampart-policy/src/main/java/org/apache/ws/secpolicy/model/SupportingToken.java?rev=619875&r1=619874&r2=619875&view=diff
==============================================================================
--- webservices/rampart/trunk/java/modules/rampart-policy/src/main/java/org/apache/ws/secpolicy/model/SupportingToken.java (original)
+++ webservices/rampart/trunk/java/modules/rampart-policy/src/main/java/org/apache/ws/secpolicy/model/SupportingToken.java Fri Feb  8 05:27:05 2008
@@ -173,6 +173,7 @@
     }
 
     public QName getName() {
+        //TODO Should we refactor this class ?? with a SuppotingTokenBase and sub classes 
         switch (type) {
         case SPConstants.SUPPORTING_TOKEN_SUPPORTING:
             return version == SPConstants.SP_V12 ? SP12Constants.SUPPORTING_TOKENS : 
@@ -186,10 +187,51 @@
         case SPConstants.SUPPORTING_TOKEN_SIGNED_ENDORSING:
             return version == SPConstants.SP_V12 ? SP12Constants.SIGNED_ENDORSING_SUPPORTING_TOKENS: 
                                                    SP11Constants.SIGNED_ENDORSING_SUPPORTING_TOKENS;
+        case SPConstants.SUPPORTING_TOKEN_ENCRYPTED:
+            return SP12Constants.ENCRYPTED_SUPPORTING_TOKENS;
+            
+        case SPConstants.SUPPORTING_TOKEN_SIGNED_ENCRYPTED:
+            return SP12Constants.SIGNED_ENCRYPTED_SUPPORTING_TOKENS;
+            
+        case SPConstants.SUPPORTING_TOKEN_ENDORSING_ENCRYPTED:
+            return SP12Constants.ENDORSING_ENCRYPTED_SUPPORTING_TOKENS;
+            
+        case SPConstants.SUPPORTING_TOKEN_SIGNED_ENDORSING_ENCRYPTED:
+            return SP12Constants.SIGNED_ENDORSING_ENCRYPTED_SUPPORTING_TOKENS;
         default:
             return null;
         }
     }
+    
+    /**
+     * @return true if the supporting token should be encrypted
+     */
+    
+    public boolean isEncryptedToken() {
+        
+        switch (type) {
+        case SPConstants.SUPPORTING_TOKEN_SUPPORTING:
+            return false;
+        case SPConstants.SUPPORTING_TOKEN_SIGNED:
+            return false;
+        case SPConstants.SUPPORTING_TOKEN_ENDORSING:
+            return false;
+        case SPConstants.SUPPORTING_TOKEN_SIGNED_ENDORSING:
+            return false;
+        case SPConstants.SUPPORTING_TOKEN_ENCRYPTED:
+            return true;        
+        case SPConstants.SUPPORTING_TOKEN_SIGNED_ENCRYPTED:
+            return true;         
+        case SPConstants.SUPPORTING_TOKEN_ENDORSING_ENCRYPTED:
+            return true;          
+        case SPConstants.SUPPORTING_TOKEN_SIGNED_ENDORSING_ENCRYPTED:
+            return true;
+        default:
+            return false;
+        }
+        
+        
+    }
 
     public PolicyComponent normalize() {
         return this;
@@ -208,24 +250,7 @@
             writer.setPrefix(prefix, namespaceURI);
         }
 
-        String localname = null;
-
-        switch (getTokenType()) {
-        case SPConstants.SUPPORTING_TOKEN_SUPPORTING:
-            localname = SPConstants.SUPPORTING_TOKENS;
-            break;
-        case SPConstants.SUPPORTING_TOKEN_SIGNED:
-            localname = SPConstants.SIGNED_SUPPORTING_TOKENS;
-            break;
-        case SPConstants.SUPPORTING_TOKEN_ENDORSING:
-            localname = SPConstants.ENDORSING_SUPPORTING_TOKENS;
-            break;
-        case SPConstants.SUPPORTING_TOKEN_SIGNED_ENDORSING:
-            localname = SPConstants.SIGNED_ENDORSING_SUPPORTING_TOKENS;
-            break;
-        default:
-            throw new RuntimeException("Invalid SupportingTokenType");
-        }
+        String localname = getName().getLocalPart();
 
         // <sp:SupportingToken>
         writer.writeStartElement(prefix, localname, namespaceURI);