axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ruchi...@apache.org
Subject svn commit: r386817 - in /webservices/axis2/trunk/java/modules/security: src/org/apache/axis2/security/trust/ test-resources/trust/ test/org/apache/axis2/security/trust/
Date Sat, 18 Mar 2006 07:10:20 GMT
Author: ruchithf
Date: Fri Mar 17 23:10:19 2006
New Revision: 386817

URL: http://svn.apache.org/viewcvs?rev=386817&view=rev
Log:
Adding a test case to test trust dispatcher configuration

Added:
    webservices/axis2/trunk/java/modules/security/test-resources/trust/
    webservices/axis2/trunk/java/modules/security/test-resources/trust/dispatcher.config.xml
    webservices/axis2/trunk/java/modules/security/test/org/apache/axis2/security/trust/
    webservices/axis2/trunk/java/modules/security/test/org/apache/axis2/security/trust/TempIssuer.java
    webservices/axis2/trunk/java/modules/security/test/org/apache/axis2/security/trust/TokenRequestDispatcherConfigTest.java
Modified:
    webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/trust/TokenRequestDispatcherConfig.java

Modified: webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/trust/TokenRequestDispatcherConfig.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/trust/TokenRequestDispatcherConfig.java?rev=386817&r1=386816&r2=386817&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/trust/TokenRequestDispatcherConfig.java
(original)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/trust/TokenRequestDispatcherConfig.java
Fri Mar 17 23:10:19 2006
@@ -59,7 +59,7 @@
             String isDefault = element.getAttributeValue(DEFAULT_ATTR);
             if(isDefault != null && "true".equalsIgnoreCase(isDefault)) {
                 //Use the first default issuer as the default isser
-                if(conf.defaultIssuerClassName != null) {
+                if(conf.defaultIssuerClassName == null) {
                     conf.defaultIssuerClassName = classAttr;
                 }
             }
@@ -72,12 +72,12 @@
                     throw new TrustException("invalidTokenTypeDefinition",
                             new String[] { "Issuer", classAttr });
                 }
-                if(conf.issuers != null) {
+                if(conf.issuers == null) {
                     conf.issuers = new Hashtable();
                 }
                 //If the token type is not aleady declared then add it to the 
                 //table with the issuer classname
-                if(!conf.issuers.keySet().contains(value)) {
+                if(conf.issuers.keySet().size() > 0 && !conf.issuers.keySet().contains(value))
{
                     conf.issuers.put(value, classAttr);
                 }
             }

Added: webservices/axis2/trunk/java/modules/security/test-resources/trust/dispatcher.config.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/security/test-resources/trust/dispatcher.config.xml?rev=386817&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/security/test-resources/trust/dispatcher.config.xml
(added)
+++ webservices/axis2/trunk/java/modules/security/test-resources/trust/dispatcher.config.xml
Fri Mar 17 23:10:19 2006
@@ -0,0 +1,6 @@
+<token-dispatcher-configuration>
+	<issuer class="org.apache.axis2.security.trust.TempIssuer" default="true">
+		<tokenType>http://example.org/mySpecialToken1</tokenType>
+		<tokenType>http://example.org/mySpecialToken2</tokenType>
+	</issuer>
+</token-dispatcher-configuration>

Added: webservices/axis2/trunk/java/modules/security/test/org/apache/axis2/security/trust/TempIssuer.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/security/test/org/apache/axis2/security/trust/TempIssuer.java?rev=386817&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/security/test/org/apache/axis2/security/trust/TempIssuer.java
(added)
+++ webservices/axis2/trunk/java/modules/security/test/org/apache/axis2/security/trust/TempIssuer.java
Fri Mar 17 23:10:19 2006
@@ -0,0 +1,13 @@
+package org.apache.axis2.security.trust;
+
+import org.apache.axis2.context.MessageContext;
+import org.apache.ws.commons.om.OMElement;
+
+public class TempIssuer implements TokenIssuer {
+
+    public OMElement issue(OMElement request, MessageContext msgCtx) throws TrustException
{
+        // TODO TODO
+        throw new UnsupportedOperationException("TODO");
+    }
+
+}

Added: webservices/axis2/trunk/java/modules/security/test/org/apache/axis2/security/trust/TokenRequestDispatcherConfigTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/security/test/org/apache/axis2/security/trust/TokenRequestDispatcherConfigTest.java?rev=386817&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/security/test/org/apache/axis2/security/trust/TokenRequestDispatcherConfigTest.java
(added)
+++ webservices/axis2/trunk/java/modules/security/test/org/apache/axis2/security/trust/TokenRequestDispatcherConfigTest.java
Fri Mar 17 23:10:19 2006
@@ -0,0 +1,51 @@
+/*
+ * 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.axis2.security.trust;
+
+import junit.framework.TestCase;
+
+public class TokenRequestDispatcherConfigTest extends TestCase {
+
+    public TokenRequestDispatcherConfigTest() {
+        super();
+    }
+
+    public TokenRequestDispatcherConfigTest(String arg0) {
+        super(arg0);
+    }
+
+    public void testWithConfigFile() {
+        try {
+            TokenRequestDispatcherConfig config = TokenRequestDispatcherConfig
+                    .load("test-resources/trust/dispatcher.config.xml");
+            
+            assertEquals("Incorrect default issuer class name",
+                    "org.apache.axis2.security.trust.TempIssuer", config
+                            .getDefaultIssuerName());
+            
+            TokenIssuer issuer = config.getIssuer("http://example.org/mySpecialToken1");
+            
+            assertEquals(
+                    "Incorrect issuer for token type : " +
+                    "http://example.org/mySpecialToken1",
+                    TempIssuer.class.getName(), issuer.getClass().getName());
+            
+        } catch (TrustException e) {
+            fail(e.getMessage());
+        }
+    }
+}



Mime
View raw message