Author: gnodet
Date: Tue Jul  1 12:16:34 2008
New Revision: 673185

URL: http://svn.apache.org/viewvc?rev=673185&view=rev
Log:
Fix proxies

Added:
    
servicemix/components/shared-libraries/trunk/servicemix-common/src/test/java/org/apache/servicemix/common/security/
    
servicemix/components/shared-libraries/trunk/servicemix-common/src/test/java/org/apache/servicemix/common/security/AuthenticationServiceTest.java
Modified:
    
servicemix/components/shared-libraries/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/security/AuthenticationService.java
    
servicemix/components/shared-libraries/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/security/KeystoreInstance.java
    
servicemix/components/shared-libraries/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/security/KeystoreManager.java

Modified: 
servicemix/components/shared-libraries/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/security/AuthenticationService.java
URL: 
http://svn.apache.org/viewvc/servicemix/components/shared-libraries/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/security/AuthenticationService.java?rev=673185&r1=673184&r2=673185&view=diff
==============================================================================
--- 
servicemix/components/shared-libraries/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/security/AuthenticationService.java
 (original)
+++ 
servicemix/components/shared-libraries/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/security/AuthenticationService.java
 Tue Jul  1 12:16:34 2008
@@ -48,11 +48,16 @@
                                                                                
     new Class[] { AuthenticationService.class },
                                                                                
     new InvocationHandler() {
                 public Object invoke(Object proxy, Method method, Object[] 
args) throws Throwable {
-                    Object o = target.getClass().getMethod(method.getName(), 
method.getParameterTypes()).invoke(proxy, args);
-                    return o;
+                    try {
+                        Object o = 
target.getClass().getMethod(method.getName(), 
method.getParameterTypes()).invoke(target, args);
+                        return o;
+                    } catch (Throwable t) {
+                        t.printStackTrace();
+                        throw t;
+                    }
                 }
             });
         }
     }
-    
+
 }

Modified: 
servicemix/components/shared-libraries/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/security/KeystoreInstance.java
URL: 
http://svn.apache.org/viewvc/servicemix/components/shared-libraries/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/security/KeystoreInstance.java?rev=673185&r1=673184&r2=673185&view=diff
==============================================================================
--- 
servicemix/components/shared-libraries/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/security/KeystoreInstance.java
 (original)
+++ 
servicemix/components/shared-libraries/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/security/KeystoreInstance.java
 Tue Jul  1 12:16:34 2008
@@ -57,11 +57,11 @@
 
     public static final class Proxy {
         public static KeystoreInstance create(final Object target) {
-            return (KeystoreInstance) 
java.lang.reflect.Proxy.newProxyInstance(AuthenticationService.class.getClassLoader(),
 
+            return (KeystoreInstance) 
java.lang.reflect.Proxy.newProxyInstance(KeystoreInstance.class.getClassLoader(),
                                                                                
new Class[] { KeystoreInstance.class },
                                                                                
new InvocationHandler() {
                 public Object invoke(Object proxy, Method method, Object[] 
args) throws Throwable {
-                    Object o = target.getClass().getMethod(method.getName(), 
method.getParameterTypes()).invoke(proxy, args);
+                    Object o = target.getClass().getMethod(method.getName(), 
method.getParameterTypes()).invoke(target, args);
                     return o;
                 }
             });

Modified: 
servicemix/components/shared-libraries/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/security/KeystoreManager.java
URL: 
http://svn.apache.org/viewvc/servicemix/components/shared-libraries/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/security/KeystoreManager.java?rev=673185&r1=673184&r2=673185&view=diff
==============================================================================
--- 
servicemix/components/shared-libraries/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/security/KeystoreManager.java
 (original)
+++ 
servicemix/components/shared-libraries/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/security/KeystoreManager.java
 Tue Jul  1 12:16:34 2008
@@ -86,11 +86,11 @@
 
     public static final class Proxy {
         public static KeystoreManager create(final Object target) {
-            return (KeystoreManager) 
java.lang.reflect.Proxy.newProxyInstance(AuthenticationService.class.getClassLoader(),
 
-                                                                              
new Class[] { KeystoreManager.class }, 
+            return (KeystoreManager) 
java.lang.reflect.Proxy.newProxyInstance(KeystoreManager.class.getClassLoader(),
+                                                                              
new Class[] { KeystoreManager.class },
                                                                               
new InvocationHandler() {
                 public Object invoke(Object proxy, Method method, Object[] 
args) throws Throwable {
-                    Object o = target.getClass().getMethod(method.getName(), 
method.getParameterTypes()).invoke(proxy, args);
+                    Object o = target.getClass().getMethod(method.getName(), 
method.getParameterTypes()).invoke(target, args);
                     if (method.getName().equals("getKeystore")) {
                         o = KeystoreInstance.Proxy.create(o);
                     }

Added: 
servicemix/components/shared-libraries/trunk/servicemix-common/src/test/java/org/apache/servicemix/common/security/AuthenticationServiceTest.java
URL: 
http://svn.apache.org/viewvc/servicemix/components/shared-libraries/trunk/servicemix-common/src/test/java/org/apache/servicemix/common/security/AuthenticationServiceTest.java?rev=673185&view=auto
==============================================================================
--- 
servicemix/components/shared-libraries/trunk/servicemix-common/src/test/java/org/apache/servicemix/common/security/AuthenticationServiceTest.java
 (added)
+++ 
servicemix/components/shared-libraries/trunk/servicemix-common/src/test/java/org/apache/servicemix/common/security/AuthenticationServiceTest.java
 Tue Jul  1 12:16:34 2008
@@ -0,0 +1,40 @@
+/*
+ * 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
+ *
+ * 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.servicemix.common.security;
+
+import java.security.GeneralSecurityException;
+
+import javax.security.auth.Subject;
+
+import org.apache.servicemix.jbi.security.UserPrincipal;
+import junit.framework.TestCase;
+
+public class AuthenticationServiceTest extends TestCase {
+
+    public void test() throws Exception {
+        AuthenticationService svc = AuthenticationService.Proxy.create(new 
Svc());
+        Subject s = new Subject();
+        svc.authenticate(s, null, "user", null);
+        assertEquals(1, s.getPrincipals().size());
+    }
+
+    public static class Svc {
+        public void authenticate(Subject subject, String domain, String user, 
Object credentials) throws GeneralSecurityException {
+            subject.getPrincipals().add(new UserPrincipal(user));
+        }
+    }
+}


Reply via email to