directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erodrig...@apache.org
Subject svn commit: rev 56096 - incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/components
Date Sun, 31 Oct 2004 00:40:37 GMT
Author: erodriguez
Date: Sat Oct 30 17:40:37 2004
New Revision: 56096

Added:
   incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/components/TicketModifier.java
Modified:
   incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/components/Ticket.java
Log:
Replacing Realm and PrincipalName with JAAS Kerberos Principal.  Moving value objects to immutable
value, mutable companion pattern.

Modified: incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/components/Ticket.java
==============================================================================
--- incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/components/Ticket.java
(original)
+++ incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/components/Ticket.java
Sat Oct 30 17:40:37 2004
@@ -16,79 +16,69 @@
  */
 package org.apache.kerberos.messages.components;
 
-import org.apache.kerberos.kdc.*;
 import org.apache.kerberos.messages.value.*;
 
+import javax.security.auth.kerberos.*;
+
 /**
  * Ticket message component as handed out by the ticket granting service
  */
 public class Ticket {
+	
+	public static final int TICKET_VNO = 5;
 
-	private int           _ticketVersionNumber;
-	private Realm         _realm;
-	private PrincipalName _serverName;
-	
-	private EncTicketPart _encTicketPart = new EncTicketPart();
-	private EncryptedData _encPart       = new EncryptedData();
-	
-	public Ticket() {
-		_ticketVersionNumber = LocalConfig.TICKET_VNO;
-		// used to generate new Tickets during reply construction
+	private int               _ticketVersionNumber;
+	private KerberosPrincipal _serverPrincipal;
+	private EncryptedData     _encPart;
+	
+	private EncTicketPart _encTicketPart;
+	
+	public Ticket(KerberosPrincipal serverPrincipal, EncryptedData encPart) {
+		this(TICKET_VNO, serverPrincipal, encPart);
 	}
-
-	public Ticket(Realm realm, PrincipalName serverName, EncryptedData encPart) {
-		_ticketVersionNumber = LocalConfig.TICKET_VNO;
-		_realm               = realm;
-		_serverName          = serverName;
+	
+	public Ticket(int versionNumber, KerberosPrincipal serverPrincipal, EncryptedData encPart)
{
+		_ticketVersionNumber = versionNumber;
+		_serverPrincipal     = serverPrincipal;
 		_encPart             = encPart;
 	}
 	
-	// getters
-	public EncryptedData getEncPart() {
-		return _encPart;
-	}
-	public Realm getRealm() {
-		return _realm;
-	}
-	public PrincipalName getServerName() {
-		return _serverName;
+	public void setEncTicketPart(EncTicketPart decryptedPart) {
+		_encTicketPart = decryptedPart;
 	}
+	
+	// getters
 	public int getTicketVersionNumber() {
 		return _ticketVersionNumber;
 	}
-	
-	// setters
-	public void setEncTicketPart(EncTicketPart part) {
-		_encTicketPart = part;
-	}
-	public void setEncPart(EncryptedData part) {
-		_encPart = part;
+	public KerberosPrincipal getServerPrincipal() {
+		return _serverPrincipal;
 	}
-	public void setRealm(Realm _realm) {
-		this._realm = _realm;
+	public String getRealm() {
+		return _serverPrincipal.getRealm();
 	}
-	public void setServerName(PrincipalName name) {
-		_serverName = name;
+	public EncryptedData getEncPart() {
+		return _encPart;
 	}
-	public void setTicketVersionNumber(int versionNumber) {
-		_ticketVersionNumber = versionNumber;
+	public EncTicketPart getEncTicketPart() {
+		return _encTicketPart;
 	}
 	
 	// EncTicketPart delegate getters
 	public AuthorizationData getAuthorizationData() {
 		return _encTicketPart.getAuthorizationData();
 	}
-	public KerberosTime getAuthtime() {
-		return _encTicketPart.getAuthtime();
+	public KerberosTime getAuthTime() {
+		return _encTicketPart.getAuthTime();
 	}
 	public HostAddresses getClientAddresses() {
 		return _encTicketPart.getClientAddresses();
 	}
-	public PrincipalName getClientName() {
-		return _encTicketPart.getClientName();
+	public KerberosPrincipal getClientPrincipal() {
+		return _encTicketPart.getClientPrincipal();
 	}
-	public Realm getClientRealm() {
-		return _encTicketPart.getClientRealm();
+	public String getClientRealm() {
+		return _encTicketPart.getClientPrincipal().getRealm();
 	}
 	public KerberosTime getEndTime() {
 		return _encTicketPart.getEndTime();
@@ -109,50 +99,9 @@
 		return _encTicketPart.getTransitedEncoding();
 	}
 	
-	// EncTicketPart TicketFlag delegates 
+	// EncTicketPart TicketFlag delegates
 	public boolean getFlag(int flag) {
 		return _encTicketPart.getFlags().get(flag);
-	}
-	public void setFlag(int flag) {
-		_encTicketPart.getFlags().set(flag);
-	}
-	public void clearFlag(int flag) {
-		_encTicketPart.getFlags().clear(flag);
-	}
-	
-	// EncTicketPart delegate setters 
-	public void setAuthorizationData(AuthorizationData data) {
-		_encTicketPart.setAuthorizationData(data);
-	}
-	public void setAuthtime(KerberosTime authtime) {
-		_encTicketPart.setAuthtime(authtime);
-	}
-	public void setClientAddresses(HostAddresses addresses) {
-		_encTicketPart.setClientAddresses(addresses);
-	}
-	public void setClientName(PrincipalName name) {
-		_encTicketPart.setClientName(name);
-	}
-	public void setClientRealm(Realm realm) {
-		_encTicketPart.setClientRealm(realm);
-	}
-	public void setEndTime(KerberosTime time) {
-		_encTicketPart.setEndTime(time);
-	}
-	public void setFlags(TicketFlags flags) {
-		_encTicketPart.setFlags(flags);
-	}
-	public void setRenewTill(KerberosTime till) {
-		_encTicketPart.setRenewTill(till);
-	}
-	public void setSessionKey(EncryptionKey key) {
-		_encTicketPart.setSessionKey(key);
-	}
-	public void setStartTime(KerberosTime time) {
-		_encTicketPart.setStartTime(time);
-	}
-	public void setTransitedEncoding(TransitedEncoding encoding) {
-		_encTicketPart.setTransitedEncoding(encoding);
 	}
 }
 

Added: incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/components/TicketModifier.java
==============================================================================
--- (empty file)
+++ incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/messages/components/TicketModifier.java
Sat Oct 30 17:40:37 2004
@@ -0,0 +1,48 @@
+/*
+ *   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.components;
+
+import org.apache.kerberos.messages.value.*;
+
+import javax.security.auth.kerberos.*;
+
+public class TicketModifier {
+	
+	private int                       _ticketVersionNumber;
+	private KerberosPrincipalModifier _serverModifier = new KerberosPrincipalModifier();
+	private EncryptedData             _encPart;
+	
+	public Ticket getTicket() {
+		
+		KerberosPrincipal serverPrincipal = _serverModifier.getKerberosPrincipal();
+		return new Ticket(_ticketVersionNumber, serverPrincipal, _encPart);
+	}
+	
+	public void setTicketVersionNumber(int versionNumber) {
+		_ticketVersionNumber = versionNumber;
+	}
+	public void setEncPart(EncryptedData part) {
+		_encPart = part;
+	}
+	public void setServerName(PrincipalName name) {
+		_serverModifier.setPrincipalName(name);
+	}
+	public void setServerRealm(String realm) {
+		_serverModifier.setRealm(realm);
+	}
+}
+

Mime
View raw message