directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erodrig...@apache.org
Subject svn commit: rev 56326 - in incubator/directory/kerberos/trunk/source/main/org/apache/kerberos: kdc messages
Date Tue, 02 Nov 2004 02:37:17 GMT
Author: erodriguez
Date: Mon Nov  1 18:37:16 2004
New Revision: 56326

Added:
   incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/kdc/ErrorService.java
   incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/ErrorMessageModifier.java
Modified:
   incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/ErrorMessage.java
Log:
Infrastructure for return error messages to clients.

Added: incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/kdc/ErrorService.java
==============================================================================
--- (empty file)
+++ incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/kdc/ErrorService.java
Mon Nov  1 18:37:16 2004
@@ -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.kdc;
+
+import org.apache.kerberos.messages.*;
+import org.apache.kerberos.messages.value.*;
+
+public class ErrorService {
+
+	private KdcConfiguration _config;
+	
+	public ErrorService(KdcConfiguration config) {
+		_config = config;
+	}
+	
+	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);
+		
+		return modifier.getErrorMessage();
+	}
+}
+

Modified: incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/ErrorMessage.java
==============================================================================
--- incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/ErrorMessage.java
(original)
+++ incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/ErrorMessage.java
Mon Nov  1 18:37:16 2004
@@ -29,12 +29,12 @@
 	private int               _errorCode;
 	private KerberosPrincipal _clientPrincipal; //optional
 	private KerberosPrincipal _serverPrincipal;
-	private String            _eText;           //optional
-	private byte[]            _eData;           //optional
+	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 eText, byte[] eData) {
+			String explanatoryText, byte[] explanatoryData) {
 		
 		super(MessageType.KRB_ERROR);
 		_clientTime      = clientTime;
@@ -44,8 +44,8 @@
 		_errorCode       = errorCode;
 		_clientPrincipal = clientPrincipal;
 		_serverPrincipal = serverPrincipal;
-		_eText           = eText;
-		_eData           = eData;
+		_explanatoryText = explanatoryText;
+		_explanatoryData = explanatoryData;
 	}
 
 	public KerberosPrincipal getClientPrincipal() {
@@ -54,17 +54,17 @@
 	public KerberosTime getClientTime() {
 		return _clientTime;
 	}
-	public Integer getCusec() {
+	public Integer getClientMicroSecond() {
 		return _cusec;
 	}
-	public byte[] getEData() {
-		return _eData;
+	public byte[] getExplanatoryData() {
+		return _explanatoryData;
 	}
 	public int getErrorCode() {
 		return _errorCode;
 	}
-	public String getEText() {
-		return _eText;
+	public String getExplanatoryText() {
+		return _explanatoryText;
 	}
 	public KerberosPrincipal getServerPrincipal() {
 		return _serverPrincipal;
@@ -72,7 +72,7 @@
 	public KerberosTime getServerTime() {
 		return _serverTime;
 	}
-	public int getSusec() {
+	public int getServerMicroSecond() {
 		return _susec;
 	}
 }

Added: incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/ErrorMessageModifier.java
==============================================================================
--- (empty file)
+++ incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/ErrorMessageModifier.java
Mon Nov  1 18:37:16 2004
@@ -0,0 +1,68 @@
+/*
+ *   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.messages;
+
+import org.apache.kerberos.messages.value.*;
+
+import javax.security.auth.kerberos.*;
+
+public class ErrorMessageModifier {
+
+	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 void setClientPrincipal(KerberosPrincipal principal) {
+		_clientPrincipal = principal;
+	}
+	public void setClientTime(KerberosTime time) {
+		_clientTime = time;
+	}
+	public void setClientMicroSecond(Integer cusec) {
+		_cusec = cusec;
+	}
+	public void setExplanatoryData(byte[] data) {
+		_explanatoryData = data;
+	}
+	public void setErrorCode(int code) {
+		_errorCode = code;
+	}
+	public void setExplanatoryText(String text) {
+		_explanatoryText = text;
+	}
+	public void setServerPrincipal(KerberosPrincipal principal) {
+		_serverPrincipal = principal;
+	}
+	public void setServerTime(KerberosTime time) {
+		_serverTime = time;
+	}
+	public void setServerMicroSecond(int susec) {
+		_susec = susec;
+	}
+}
+

Mime
View raw message