directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erodrig...@apache.org
Subject svn commit: r153008 - in incubator/directory/protocols/kerberos/trunk/core/src/java/org/apache/kerberos: kdc/ErrorService.java kdc/KerberosException.java messages/ErrorMessage.java messages/ErrorMessageModifier.java
Date Wed, 09 Feb 2005 04:58:41 GMT
Author: erodriguez
Date: Tue Feb  8 20:58:39 2005
New Revision: 153008

URL: http://svn.apache.org/viewcvs?view=rev&rev=153008
Log:
Enhanced the error handling subsystem to return explanatory data in Kerberos error messages.

Modified:
    incubator/directory/protocols/kerberos/trunk/core/src/java/org/apache/kerberos/kdc/ErrorService.java
    incubator/directory/protocols/kerberos/trunk/core/src/java/org/apache/kerberos/kdc/KerberosException.java
    incubator/directory/protocols/kerberos/trunk/core/src/java/org/apache/kerberos/messages/ErrorMessage.java
    incubator/directory/protocols/kerberos/trunk/core/src/java/org/apache/kerberos/messages/ErrorMessageModifier.java

Modified: incubator/directory/protocols/kerberos/trunk/core/src/java/org/apache/kerberos/kdc/ErrorService.java
URL: http://svn.apache.org/viewcvs/incubator/directory/protocols/kerberos/trunk/core/src/java/org/apache/kerberos/kdc/ErrorService.java?view=diff&r1=153007&r2=153008
==============================================================================
--- incubator/directory/protocols/kerberos/trunk/core/src/java/org/apache/kerberos/kdc/ErrorService.java
(original)
+++ incubator/directory/protocols/kerberos/trunk/core/src/java/org/apache/kerberos/kdc/ErrorService.java
Tue Feb  8 20:58:39 2005
@@ -14,29 +14,38 @@
  *   limitations under the License.
  *
  */
+
 package org.apache.kerberos.kdc;
 
-import org.apache.kerberos.messages.*;
-import org.apache.kerberos.messages.value.*;
+import org.apache.kerberos.messages.ErrorMessage;
+import org.apache.kerberos.messages.ErrorMessageModifier;
+import org.apache.kerberos.messages.value.KerberosTime;
 
-public class ErrorService {
 
-	private KdcConfiguration _config;
+public class ErrorService
+{
+	private KdcConfiguration config;
+	
 	
-	public ErrorService(KdcConfiguration config) {
-		_config = config;
+	public ErrorService( KdcConfiguration config )
+	{
+		this.config = config;
 	}
 	
-	public ErrorMessage getReplyFor(KerberosException exception) {
+	
+	public ErrorMessage getReplyFor( KerberosException exception )
+	{
 		ErrorMessageModifier modifier = new ErrorMessageModifier();
 		
 		KerberosTime now = new KerberosTime();
 		
-		modifier.setErrorCode(exception.getOrdinal());
-		modifier.setExplanatoryText(exception.getMessage());
-		modifier.setServerPrincipal(_config.getKdcPrincipal());
-		modifier.setServerTime(now);
-		modifier.setServerMicroSecond(0);
+		modifier.setErrorCode( exception.getOrdinal() );
+		modifier.setExplanatoryText( exception.getMessage() );
+		modifier.setServerPrincipal( config.getKdcPrincipal() );
+		modifier.setServerTime( now );
+		modifier.setServerMicroSecond( 0 );
+		
+		modifier.setExplanatoryData( exception.getExplanatoryData() );
 		
 		return modifier.getErrorMessage();
 	}

Modified: incubator/directory/protocols/kerberos/trunk/core/src/java/org/apache/kerberos/kdc/KerberosException.java
URL: http://svn.apache.org/viewcvs/incubator/directory/protocols/kerberos/trunk/core/src/java/org/apache/kerberos/kdc/KerberosException.java?view=diff&r1=153007&r2=153008
==============================================================================
--- incubator/directory/protocols/kerberos/trunk/core/src/java/org/apache/kerberos/kdc/KerberosException.java
(original)
+++ incubator/directory/protocols/kerberos/trunk/core/src/java/org/apache/kerberos/kdc/KerberosException.java
Tue Feb  8 20:58:39 2005
@@ -14,47 +14,12 @@
  *   limitations under the License.
  *
  */
+
 package org.apache.kerberos.kdc;
 
 
 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");
 	public static final KerberosException KDC_ERR_NAME_EXP = new KerberosException(1,
@@ -187,23 +152,43 @@
 			"Client names do not match");
 	public static final KerberosException KRB_ERR_KDC_NAME_MISMATCH = new KerberosException(76,
 			"KDC names do not match");
-
-	public String toString() {
-		return _fName;
+	
+	private final int    ordinal;
+	private final String name;
+	
+	private byte[] explanatoryData; 
+	
+	
+	protected KerberosException( int ordinal, String name )
+	{
+		super( name );
+		
+		this.ordinal = ordinal;
+		this.name    = name;
 	}
 	
-	public int getOrdinal() {
-		return _fOrdinal;
+	protected KerberosException( int ordinal, String name, byte[] explanatoryData )
+	{
+		super( name );
+		
+		this.ordinal         = ordinal;
+		this.name            = name;
+		this.explanatoryData = explanatoryData;
 	}
-
-	/// PRIVATE /////
-	private final String _fName;
-	private final int    _fOrdinal;
-
-	protected KerberosException(int ordinal, String name) {
-		super(name);
-		_fOrdinal = ordinal;
-		_fName    = name;
+	
+	public String toString()
+	{
+		return name;
+	}
+	
+	public int getOrdinal()
+	{
+		return ordinal;
+	}
+	
+	public byte[] getExplanatoryData()
+	{
+		return explanatoryData;
 	}
 }
 

Modified: incubator/directory/protocols/kerberos/trunk/core/src/java/org/apache/kerberos/messages/ErrorMessage.java
URL: http://svn.apache.org/viewcvs/incubator/directory/protocols/kerberos/trunk/core/src/java/org/apache/kerberos/messages/ErrorMessage.java?view=diff&r1=153007&r2=153008
==============================================================================
--- incubator/directory/protocols/kerberos/trunk/core/src/java/org/apache/kerberos/messages/ErrorMessage.java
(original)
+++ incubator/directory/protocols/kerberos/trunk/core/src/java/org/apache/kerberos/messages/ErrorMessage.java
Tue Feb  8 20:58:39 2005
@@ -14,66 +14,88 @@
  *   limitations under the License.
  *
  */
-package org.apache.kerberos.messages;
 
-import org.apache.kerberos.messages.value.*;
+package org.apache.kerberos.messages;
 
-import javax.security.auth.kerberos.*;
+import javax.security.auth.kerberos.KerberosPrincipal;
 
-public class ErrorMessage extends KerberosMessage {
+import org.apache.kerberos.messages.value.KerberosTime;
 
-	private KerberosTime      _clientTime;      //optional
-	private Integer           _cusec;           //optional
-	private KerberosTime      _serverTime;
-	private int               _susec;
-	private int               _errorCode;
-	private KerberosPrincipal _clientPrincipal; //optional
-	private KerberosPrincipal _serverPrincipal;
-	private String            _explanatoryText; //optional
-	private byte[]            _explanatoryData; //optional
 
-	public ErrorMessage(KerberosTime clientTime, Integer cusec, KerberosTime serverTime, int
susec,
-			int errorCode, KerberosPrincipal clientPrincipal, KerberosPrincipal serverPrincipal,
-			String explanatoryText, byte[] explanatoryData) {
+public class ErrorMessage extends KerberosMessage
+{
+	private KerberosTime      clientTime;        //optional
+	private Integer           clientMicroSecond; //optional
+	private KerberosTime      serverTime;
+	private int               serverMicroSecond;
+	private int               errorCode;
+	private KerberosPrincipal clientPrincipal;   //optional
+	private KerberosPrincipal serverPrincipal;
+	private String            explanatoryText;   //optional
+	private byte[]            explanatoryData;   //optional
+	
+	
+	public ErrorMessage( KerberosTime clientTime, Integer clientMicroSecond, KerberosTime serverTime,
+	        int serverMicroSecond, int errorCode, KerberosPrincipal clientPrincipal,
+	        KerberosPrincipal serverPrincipal, String explanatoryText, byte[] explanatoryData
)
+	{
+		super( MessageType.KRB_ERROR );
 		
-		super(MessageType.KRB_ERROR);
-		_clientTime      = clientTime;
-		_cusec           = cusec;
-		_serverTime      = serverTime;
-		_susec           = susec;
-		_errorCode       = errorCode;
-		_clientPrincipal = clientPrincipal;
-		_serverPrincipal = serverPrincipal;
-		_explanatoryText = explanatoryText;
-		_explanatoryData = explanatoryData;
-	}
-
-	public KerberosPrincipal getClientPrincipal() {
-		return _clientPrincipal;
-	}
-	public KerberosTime getClientTime() {
-		return _clientTime;
-	}
-	public Integer getClientMicroSecond() {
-		return _cusec;
-	}
-	public byte[] getExplanatoryData() {
-		return _explanatoryData;
-	}
-	public int getErrorCode() {
-		return _errorCode;
-	}
-	public String getExplanatoryText() {
-		return _explanatoryText;
-	}
-	public KerberosPrincipal getServerPrincipal() {
-		return _serverPrincipal;
-	}
-	public KerberosTime getServerTime() {
-		return _serverTime;
-	}
-	public int getServerMicroSecond() {
-		return _susec;
+		this.clientTime        = clientTime;
+		this.clientMicroSecond = clientMicroSecond;
+		this.serverTime        = serverTime;
+		this.serverMicroSecond = serverMicroSecond;
+		this.errorCode         = errorCode;
+		this.clientPrincipal   = clientPrincipal;
+		this.serverPrincipal   = serverPrincipal;
+		this.explanatoryText   = explanatoryText;
+		this.explanatoryData   = explanatoryData;
+	}
+	
+	
+	public KerberosPrincipal getClientPrincipal()
+	{
+		return clientPrincipal;
+	}
+	
+	public KerberosTime getClientTime()
+	{
+		return clientTime;
+	}
+	
+	public Integer getClientMicroSecond()
+	{
+		return clientMicroSecond;
+	}
+	
+	public byte[] getExplanatoryData()
+	{
+		return explanatoryData;
+	}
+	
+	public int getErrorCode()
+	{
+		return errorCode;
+	}
+	
+	public String getExplanatoryText()
+	{
+		return explanatoryText;
+	}
+	
+	public KerberosPrincipal getServerPrincipal()
+	{
+		return serverPrincipal;
+	}
+	
+	public KerberosTime getServerTime()
+	{
+		return serverTime;
+	}
+	
+	public int getServerMicroSecond()
+	{
+		return serverMicroSecond;
 	}
 }
 

Modified: incubator/directory/protocols/kerberos/trunk/core/src/java/org/apache/kerberos/messages/ErrorMessageModifier.java
URL: http://svn.apache.org/viewcvs/incubator/directory/protocols/kerberos/trunk/core/src/java/org/apache/kerberos/messages/ErrorMessageModifier.java?view=diff&r1=153007&r2=153008
==============================================================================
--- incubator/directory/protocols/kerberos/trunk/core/src/java/org/apache/kerberos/messages/ErrorMessageModifier.java
(original)
+++ incubator/directory/protocols/kerberos/trunk/core/src/java/org/apache/kerberos/messages/ErrorMessageModifier.java
Tue Feb  8 20:58:39 2005
@@ -14,55 +14,77 @@
  *   limitations under the License.
  *
  */
-package org.apache.kerberos.messages;
 
-import org.apache.kerberos.messages.value.*;
+package org.apache.kerberos.messages;
 
-import javax.security.auth.kerberos.*;
+import javax.security.auth.kerberos.KerberosPrincipal;
 
-public class ErrorMessageModifier {
+import org.apache.kerberos.messages.value.KerberosTime;
 
-	private KerberosTime      _clientTime;      //optional
-	private Integer           _cusec;           //optional
-	private KerberosTime      _serverTime;
-	private int               _susec;
-	private int               _errorCode;
-	private KerberosPrincipal _clientPrincipal; //optional
-	private KerberosPrincipal _serverPrincipal;
-	private String            _explanatoryText; //optional
-	private byte[]            _explanatoryData; //optional
 
-	public ErrorMessage getErrorMessage() {
-		return new ErrorMessage(_clientTime, _cusec, _serverTime, _susec, _errorCode,
-			_clientPrincipal, _serverPrincipal, _explanatoryText, _explanatoryData);
-	}
+public class ErrorMessageModifier
+{
+	private KerberosTime      clientTime;        //optional
+	private Integer           clientMicroSecond; //optional
+	private KerberosTime      serverTime;
+	private int               serverMicroSecond;
+	private int               errorCode;
+	private KerberosPrincipal clientPrincipal;   //optional
+	private KerberosPrincipal serverPrincipal;
+	private String            explanatoryText;   //optional
+	private byte[]            explanatoryData;   //optional
+	
 	
-	public void setClientPrincipal(KerberosPrincipal principal) {
-		_clientPrincipal = principal;
+	public ErrorMessage getErrorMessage()
+	{
+		return new ErrorMessage( clientTime, clientMicroSecond, serverTime, serverMicroSecond,
+		        errorCode, clientPrincipal, serverPrincipal, explanatoryText, explanatoryData );
 	}
-	public void setClientTime(KerberosTime time) {
-		_clientTime = time;
+	
+	
+	public void setClientPrincipal( KerberosPrincipal principal )
+	{
+		this.clientPrincipal = principal;
 	}
-	public void setClientMicroSecond(Integer cusec) {
-		_cusec = cusec;
+	
+	public void setClientTime( KerberosTime time )
+	{
+		this.clientTime = time;
 	}
-	public void setExplanatoryData(byte[] data) {
-		_explanatoryData = data;
+	
+	public void setClientMicroSecond( Integer clientMicroSecond )
+	{
+		this.clientMicroSecond = clientMicroSecond;
 	}
-	public void setErrorCode(int code) {
-		_errorCode = code;
+	
+	public void setExplanatoryData( byte[] data )
+	{
+		this.explanatoryData = data;
 	}
-	public void setExplanatoryText(String text) {
-		_explanatoryText = text;
+	
+	public void setErrorCode( int code )
+	{
+		this.errorCode = code;
 	}
-	public void setServerPrincipal(KerberosPrincipal principal) {
-		_serverPrincipal = principal;
+	
+	public void setExplanatoryText( String text )
+	{
+		this.explanatoryText = text;
 	}
-	public void setServerTime(KerberosTime time) {
-		_serverTime = time;
+	
+	public void setServerPrincipal( KerberosPrincipal principal )
+	{
+		this.serverPrincipal = principal;
 	}
-	public void setServerMicroSecond(int susec) {
-		_susec = susec;
+	
+	public void setServerTime( KerberosTime time )
+	{
+		this.serverTime = time;
 	}
+	
+	public void setServerMicroSecond( int serverMicroSecond )
+	{
+		this.serverMicroSecond = serverMicroSecond;
+	}	
 }
 



Mime
View raw message