directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r149208 - in incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos: exception/ exception/KdcErrorNameExpiry.java exception/KerberosException.java kdc/KerberosException.java sam/ sam/SamException.java sam/SamVerifier.java
Date Mon, 31 Jan 2005 03:26:06 GMT
Author: akarasulu
Date: Sun Jan 30 19:26:04 2005
New Revision: 149208

URL: http://svn.apache.org/viewcvs?view=rev&rev=149208
Log:
changes ...

 o put note to e-man about KerberosException hierarchy
 o added couple examples to demo the hierarchy to keep if you think its cool
 o added SAM exception and interface


Added:
    incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/exception/
    incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/exception/KdcErrorNameExpiry.java
    incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/exception/KerberosException.java
    incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/sam/
    incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/sam/SamException.java
    incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/sam/SamVerifier.java
Modified:
    incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/kdc/KerberosException.java

Added: incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/exception/KdcErrorNameExpiry.java
URL: http://svn.apache.org/viewcvs/incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/exception/KdcErrorNameExpiry.java?view=auto&rev=149208
==============================================================================
--- incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/exception/KdcErrorNameExpiry.java
(added)
+++ incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/exception/KdcErrorNameExpiry.java
Sun Jan 30 19:26:04 2005
@@ -0,0 +1,44 @@
+/*
+ *   Copyright 2004 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.kerberos.exception;
+
+
+/**
+ * A Kerberos exception representing the expiration of a client entry within the
+ * user store (database).
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class KdcErrorNameExpiry extends KerberosException
+{
+    /** the code associated with this protocol error */
+    public static final int CODE = 1;
+
+    /** the standard message associated with this protocol error */
+    public static final String MSG = "Client's entry in database expired";
+
+
+    /**
+     * Creates an exception representing the expiration of a client entry within
+     * the database.
+     */
+    public KdcErrorNameExpiry()
+    {
+        super( 1, MSG );
+    }
+}

Added: incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/exception/KerberosException.java
URL: http://svn.apache.org/viewcvs/incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/exception/KerberosException.java?view=auto&rev=149208
==============================================================================
--- incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/exception/KerberosException.java
(added)
+++ incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/exception/KerberosException.java
Sun Jan 30 19:26:04 2005
@@ -0,0 +1,76 @@
+/*
+ *   Copyright 2004 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.kerberos.exception;
+
+
+/**
+ * The root of the Kerberos exception hierarchy.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class KerberosException extends Exception
+{
+    /** The Kerberos error code associated with this exception */
+    private final int errCode;
+
+
+    // ------------------------------------------------------------------------
+    // C O N S T R U C T O R S
+    // ------------------------------------------------------------------------
+
+
+    /**
+     * Creates a KerberosException with an error code and a message.
+     *
+     * @param errCode the error code associated with this KerberosException
+     * @param msg the standard Kerberos error message for this KerberosException
+     */
+    public KerberosException( int errCode, String msg )
+    {
+        super( msg );
+
+        this.errCode = errCode;
+    }
+
+
+    /**
+     * Creates a KerberosException with an error code, a message and an
+     * underlying throwable that caused this fault.
+     *
+     * @param errCode the error code associated with this KerberosException
+     * @param msg the standard Kerberos error message for this KerberosException
+     * @param cause the underlying failure if any
+     */
+    public KerberosException( int errCode, String msg, Throwable cause )
+    {
+        super( msg, cause );
+
+        this.errCode = errCode;
+    }
+
+
+    /**
+     * Gets the protocol error code associated with this KerberosException.
+     *
+     * @return the error code associated with this KerberosException
+     */
+    public int getErrorCode()
+    {
+        return this.errCode;
+    }
+}

Modified: incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/kdc/KerberosException.java
URL: http://svn.apache.org/viewcvs/incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/kdc/KerberosException.java?view=diff&r1=149207&r2=149208
==============================================================================
--- incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/kdc/KerberosException.java
(original)
+++ incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/kdc/KerberosException.java
Sun Jan 30 19:26:04 2005
@@ -16,7 +16,44 @@
  */
 package org.apache.kerberos.kdc;
 
-public class KerberosException extends Exception {
+
+public class KerberosException extends Exception
+{
+
+/*
+ * Not a good idea to create constant exceptions that are thrown in different
+ * places at different times by different threads.  This will be a problem when
+ * they have different stack traces from different worker threads.  You're asking
+ * for a race condition here where one stack trace will overwrite another if
+ * the same exception is thrown in two places.  Try just creating constants for
+ * various messages and their codes like (String) KDC_ERR_NONE_MSG and (int)
+ * KDC_ERR_NONE_CODE.  This may become unmanageable though.
+ *
+ * Another alternative would be to just create a KerberosException hierarchy
+ * and hardcode the messages and type values into the subclasses.  You should
+ * always create and throw a new exception rather than trying to reuse them as
+ * constants.
+ *
+ * Don't bother thinking about wasting an object creation everytime.  This is
+ * how it should happen.  Secondly exceptions are not common pathways within
+ * processing.  So they should not be occurring frequently.  It will not slow
+ * you down to create the exception from scratch.  As an example I started off
+ * the hierarchy within the new exception package so it does not conflict with
+ * this class.
+ *
+ * However I do have the feeling that you probably want a type safe enum here
+ * rather than exception codes only because things like KDC_ERR_NONE represent
+ * the absense of an error.  It seems like a protocol response code.  So I'd
+ * separate that out into its own type safe enum but use that enum within
+ * subclasses of the KerberosException.  This infact is exactly what I have
+ * done in the LDAP side and it works well.  When I bubble up an exception from
+ * deep down I catch it and return a PDU with the error code (LdapResultCode) I
+ * get from the exception.  Works out rather nicely athough initial setup costs
+ * some typing.
+ *
+ * Cheers,
+ * -aok
+ */
 
 	public static final KerberosException KDC_ERR_NONE = new KerberosException(0,
 			"No error");

Added: incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/sam/SamException.java
URL: http://svn.apache.org/viewcvs/incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/sam/SamException.java?view=auto&rev=149208
==============================================================================
--- incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/sam/SamException.java
(added)
+++ incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/sam/SamException.java
Sun Jan 30 19:26:04 2005
@@ -0,0 +1,51 @@
+/*
+ *   Copyright 2004 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.kerberos.sam;
+
+
+/**
+ * Base class for all SAM subsystem errors.
+ *
+ * @warning this should extend from KerberosException in o.a.k.exception.
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class SamException extends Exception
+{
+    public SamException()
+    {
+        super();
+    }
+
+
+    public SamException( String message )
+    {
+        super( message );
+    }
+
+
+    public SamException( Throwable cause )
+    {
+        super( cause );
+    }
+
+
+    public SamException( String message, Throwable cause )
+    {
+        super( message, cause );
+    }
+}

Added: incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/sam/SamVerifier.java
URL: http://svn.apache.org/viewcvs/incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/sam/SamVerifier.java?view=auto&rev=149208
==============================================================================
--- incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/sam/SamVerifier.java
(added)
+++ incubator/directory/kerberos/trunk/core/src/java/org/apache/kerberos/sam/SamVerifier.java
Sun Jan 30 19:26:04 2005
@@ -0,0 +1,44 @@
+/*
+ *   Copyright 2004 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.kerberos.sam;
+
+
+/**
+ * Single-use Authentication Mechanism verifier (subsystem) interface.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public interface SamVerifier
+{
+    /**
+     * Verifies the single use password supplied.
+     *
+     * @param uid the unique id of the user within an authentication domain
+     * @param domain the authentication domain of the user
+     * @param sup the value of the single use password
+     * @return true if the single-use password is verified a correct, false otherwise
+     */
+    boolean verify( String uid, String domain, String sup ) throws SamException;
+
+    /**
+     * Gets the registered SAM algorithm type implemented by this SamVerifier.
+     *
+     * @return the type value for the SAM algorithm used to verify the SUP.
+     */
+    int getSamType();
+}



Mime
View raw message