harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smish...@apache.org
Subject svn commit: r486503 - /harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/module/Krb5LoginModule.java
Date Wed, 13 Dec 2006 05:33:29 GMT
Author: smishura
Date: Tue Dec 12 21:33:28 2006
New Revision: 486503

URL: http://svn.apache.org/viewvc?view=rev&rev=486503
Log:
Krb5LoginModule: implement abort(), commit() and logout() methods

Modified:
    harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/module/Krb5LoginModule.java

Modified: harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/module/Krb5LoginModule.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/module/Krb5LoginModule.java?view=diff&rev=486503&r1=486502&r2=486503
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/module/Krb5LoginModule.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/module/Krb5LoginModule.java
Tue Dec 12 21:33:28 2006
@@ -20,6 +20,7 @@
 import java.net.InetAddress;
 import java.util.Map;
 
+import javax.security.auth.DestroyFailedException;
 import javax.security.auth.Subject;
 import javax.security.auth.callback.Callback;
 import javax.security.auth.callback.CallbackHandler;
@@ -51,14 +52,28 @@
 
     private CallbackHandler callbackHandler;
 
+    private KerberosPrincipal client;
+    
+    private KerberosTicket krbTicket;
+    
     public boolean abort() throws LoginException {
-        // TODO
-        return false;
+        
+        try {
+            krbTicket.destroy();
+        } catch (DestroyFailedException e) {
+            throw new LoginException();
+        }
+
+        client = null;
+        krbTicket = null;
+        
+        return true;
     }
 
     public boolean commit() throws LoginException {
-        // TODO
-        return false;
+        subject.getPrincipals().add(client);
+        subject.getPrivateCredentials().add(krbTicket);
+        return true;
     }
 
     public void initialize(Subject subject, CallbackHandler callbackHandler,
@@ -124,9 +139,8 @@
             buf.append('@');
             buf.append(reply.getCrealm());
 
-            KerberosPrincipal client = new KerberosPrincipal(buf.toString(),
+            client = new KerberosPrincipal(buf.toString(),
                     reply.getCname().getType());
-            subject.getPrincipals().add(client);
 
             // add ticket to private credentials
             byte[] ticket = reply.getTicket().getEncoded();
@@ -149,15 +163,13 @@
 
             boolean[] flags = reply.getFlags().toBooleanArray();
 
-            KerberosTicket krbTicket = new KerberosTicket(ticket, client,
+            krbTicket = new KerberosTicket(ticket, client,
                     server, sessionKey, keyType, flags, reply.getAuthtime(),
                     reply.getStarttime(), reply.getEndtime(), reply
                             .getRenewtill(),
                     //TODO InetAddress[] clientAddresses
                     null);
 
-            subject.getPrivateCredentials().add(krbTicket);
-
             return true; //FIXME 
         } catch (Exception e) {
             LoginException ex = new LoginException();
@@ -167,7 +179,19 @@
     }
 
     public boolean logout() throws LoginException {
-        // TODO
-        return false;
+
+        subject.getPrincipals().remove(client);
+        subject.getPrivateCredentials().remove(krbTicket);
+        
+        try {
+            krbTicket.destroy();
+        } catch (DestroyFailedException e) {
+            throw new LoginException();
+        }
+
+        client = null;
+        krbTicket = null;
+
+        return true;
     }
 }



Mime
View raw message