directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erodrig...@apache.org
Subject svn commit: r534687 - /directory/apacheds/branches/kerberos-encryption-types/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosProtocolHandler.java
Date Thu, 03 May 2007 01:58:25 GMT
Author: erodriguez
Date: Wed May  2 18:58:24 2007
New Revision: 534687

URL: http://svn.apache.org/viewvc?view=rev&rev=534687
Log:
Improvement to exception handling.

Modified:
    directory/apacheds/branches/kerberos-encryption-types/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosProtocolHandler.java

Modified: directory/apacheds/branches/kerberos-encryption-types/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosProtocolHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/kerberos-encryption-types/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosProtocolHandler.java?view=diff&rev=534687&r1=534686&r2=534687
==============================================================================
--- directory/apacheds/branches/kerberos-encryption-types/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosProtocolHandler.java
(original)
+++ directory/apacheds/branches/kerberos-encryption-types/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosProtocolHandler.java
Wed May  2 18:58:24 2007
@@ -64,7 +64,7 @@
     private String contextKey = "context";
 
 
-    public KerberosProtocolHandler(KdcConfiguration config, PrincipalStore store)
+    public KerberosProtocolHandler( KdcConfiguration config, PrincipalStore store )
     {
         this.config = config;
         this.store = store;
@@ -164,20 +164,32 @@
 
                 case 11:
                 case 13:
-                    log.error( "Kerberos error:  " + ErrorType.KRB_AP_ERR_BADDIRECTION.getMessage()
);
+                    throw new KerberosException( ErrorType.KRB_AP_ERR_BADDIRECTION );
 
                 default:
-                    log.error( "Kerberos error:  " + ErrorType.KRB_AP_ERR_MSG_TYPE.getMessage()
);
+                    throw new KerberosException( ErrorType.KRB_AP_ERR_MSG_TYPE );
             }
         }
-        catch ( Exception e )
+        catch ( KerberosException ke )
         {
-            log.error( e.getMessage() );
-
-            KerberosException ke = ( KerberosException ) e;
+            if ( log.isDebugEnabled() )
+            {
+                log.debug( ke.getMessage(), ke );
+            }
+            else
+            {
+                log.warn( ke.getMessage() );
+            }
 
             session.write( getErrorMessage( config.getKdcPrincipal(), ke ) );
         }
+        catch ( Exception e )
+        {
+            log.error( "Unexpected exception:  " + e.getMessage(), e );
+
+            session.write( getErrorMessage( config.getKdcPrincipal(), new KerberosException(
+                ErrorType.KDC_ERR_SVC_UNAVAILABLE ) ) );
+        }
     }
 
 
@@ -190,7 +202,7 @@
     }
 
 
-    public ErrorMessage getErrorMessage( KerberosPrincipal principal, KerberosException exception
)
+    protected ErrorMessage getErrorMessage( KerberosPrincipal principal, KerberosException
exception )
     {
         ErrorMessageModifier modifier = new ErrorMessageModifier();
 
@@ -207,7 +219,7 @@
     }
 
 
-    public String getContextKey()
+    protected String getContextKey()
     {
         return ( this.contextKey );
     }



Mime
View raw message