directory-commits mailing list archives

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

Modified:
   incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/io/encoder/EncKdcRepPartEncoder.java
   incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/io/encoder/EncTicketPartEncoder.java
   incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/io/encoder/KdcReplyEncoder.java
   incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/io/encoder/KdcReqBodyEncoder.java
   incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/io/encoder/KerberosMessageEncoder.java
Log:
Replacing Realm and PrincipalName with JAAS KerberosPrincipal.

Modified: incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/io/encoder/EncKdcRepPartEncoder.java
==============================================================================
--- incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/io/encoder/EncKdcRepPartEncoder.java
(original)
+++ incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/io/encoder/EncKdcRepPartEncoder.java
Sat Oct 30 17:21:04 2004
@@ -81,7 +81,7 @@
 			vector.add(new DERTaggedObject(8, encodeKerberosTime(reply.getRenewTill())));
 		
 		vector.add(new DERTaggedObject(9, encodeRealm(reply.getServerRealm())));
-		vector.add(new DERTaggedObject(10, encodePrincipalName(reply.getServerName())));
+		vector.add(new DERTaggedObject(10, encodePrincipalName(reply.getServerPrincipal())));
 		
 		// OPTIONAL
 		if (reply.getClientAddresses() != null)

Modified: incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/io/encoder/EncTicketPartEncoder.java
==============================================================================
--- incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/io/encoder/EncTicketPartEncoder.java
(original)
+++ incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/io/encoder/EncTicketPartEncoder.java
Sat Oct 30 17:21:04 2004
@@ -25,11 +25,11 @@
 	
 	public static final int APPLICATION_CODE = 3;
 	
-	public byte[] encode(Ticket ticket) throws IOException {
+	public byte[] encode(EncTicketPart ticketPart) throws IOException {
 		ByteArrayOutputStream baos = new ByteArrayOutputStream();
 		ASN1OutputStream aos = new ASN1OutputStream(baos);
 		
-		DERSequence ticketSequence = encodeInitialSequence(ticket);
+		DERSequence ticketSequence = encodeInitialSequence(ticketPart);
 		aos.writeObject(new DERApplicationSpecific(APPLICATION_CODE, ticketSequence));
 		aos.close();
 		
@@ -51,29 +51,29 @@
 	                      caddr[9]             HostAddresses OPTIONAL,
 	                      authorization-data[10]   AuthorizationData OPTIONAL
 	}*/
-	public DERSequence encodeInitialSequence(Ticket ticket) {
+	public DERSequence encodeInitialSequence(EncTicketPart ticketPart) {
 		ASN1EncodableVector vector = new ASN1EncodableVector();
 		
-		vector.add(new DERTaggedObject(0, encodeTicketFlags(ticket.getFlags())));
-		vector.add(new DERTaggedObject(1, encodeEncryptionKey(ticket.getSessionKey())));
-		vector.add(new DERTaggedObject(2, encodeRealm(ticket.getClientRealm())));
-		vector.add(new DERTaggedObject(3, encodePrincipalName(ticket.getClientName())));
-		vector.add(new DERTaggedObject(4, encodeTransitedEncoding(ticket.getTransitedEncoding())));
-		vector.add(new DERTaggedObject(5, encodeKerberosTime(ticket.getAuthtime())));
+		vector.add(new DERTaggedObject(0, encodeTicketFlags(ticketPart.getFlags())));
+		vector.add(new DERTaggedObject(1, encodeEncryptionKey(ticketPart.getSessionKey())));
+		vector.add(new DERTaggedObject(2, encodeRealm(ticketPart.getClientRealm())));
+		vector.add(new DERTaggedObject(3, encodePrincipalName(ticketPart.getClientPrincipal())));
+		vector.add(new DERTaggedObject(4, encodeTransitedEncoding(ticketPart.getTransitedEncoding())));
+		vector.add(new DERTaggedObject(5, encodeKerberosTime(ticketPart.getAuthTime())));
 		
 		// OPTIONAL
-		if (ticket.getStartTime() != null)
-			vector.add(new DERTaggedObject(6, encodeKerberosTime(ticket.getStartTime())));
+		if (ticketPart.getStartTime() != null)
+			vector.add(new DERTaggedObject(6, encodeKerberosTime(ticketPart.getStartTime())));
 		
-		vector.add(new DERTaggedObject(7, encodeKerberosTime(ticket.getEndTime())));
+		vector.add(new DERTaggedObject(7, encodeKerberosTime(ticketPart.getEndTime())));
 		
 		// OPTIONAL
-		if (ticket.getRenewTill() != null)
-			vector.add(new DERTaggedObject(8, encodeKerberosTime(ticket.getRenewTill())));
-		if (ticket.getClientAddresses() != null)
-			vector.add(new DERTaggedObject(9, encodeHostAddresses(ticket.getClientAddresses())));
-		if (ticket.getAuthorizationData() != null)
-			vector.add(new DERTaggedObject(10, encodeAuthorizationData(ticket.getAuthorizationData())));
+		if (ticketPart.getRenewTill() != null)
+			vector.add(new DERTaggedObject(8, encodeKerberosTime(ticketPart.getRenewTill())));
+		if (ticketPart.getClientAddresses() != null)
+			vector.add(new DERTaggedObject(9, encodeHostAddresses(ticketPart.getClientAddresses())));
+		if (ticketPart.getAuthorizationData() != null)
+			vector.add(new DERTaggedObject(10, encodeAuthorizationData(ticketPart.getAuthorizationData())));
 		
 		return new DERSequence(vector);
 	}

Modified: incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/io/encoder/KdcReplyEncoder.java
==============================================================================
--- incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/io/encoder/KdcReplyEncoder.java
(original)
+++ incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/io/encoder/KdcReplyEncoder.java
Sat Oct 30 17:21:04 2004
@@ -57,8 +57,8 @@
 		vector.add(new DERTaggedObject(1, new DERInteger(app.getMessageType().getOrdinal())));
 		if (app.getPaData() != null)
 			vector.add(new DERTaggedObject(2, encodePaData(app.getPaData())));
-		vector.add(new DERTaggedObject(3, encodeRealm(app.getCrealm())));
-		vector.add(new DERTaggedObject(4, encodePrincipalName(app.getCname())));
+		vector.add(new DERTaggedObject(3, encodeRealm(app.getClientRealm())));
+		vector.add(new DERTaggedObject(4, encodePrincipalName(app.getClientPrincipal())));
 		vector.add(new DERTaggedObject(5, encodeTicket(app.getTicket())));
 		vector.add(new DERTaggedObject(6, encodeEncryptedData(app.getEncPart())));
 		

Modified: incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/io/encoder/KdcReqBodyEncoder.java
==============================================================================
--- incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/io/encoder/KdcReqBodyEncoder.java
(original)
+++ incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/io/encoder/KdcReqBodyEncoder.java
Sat Oct 30 17:21:04 2004
@@ -59,12 +59,12 @@
 		
 		vector.add(new DERTaggedObject(0, encodeKdcOptions(request.getKdcOptions())));
 		// OPTIONAL
-		if (request.getCname() != null)
-			vector.add(new DERTaggedObject(1, encodePrincipalName(request.getCname())));
+		if (request.getClientPrincipal() != null)
+			vector.add(new DERTaggedObject(1, encodePrincipalName(request.getClientPrincipal())));
 		vector.add(new DERTaggedObject(2, encodeRealm(request.getRealm())));
 		// OPTIONAL
-		if (request.getSname() != null)
-			vector.add(new DERTaggedObject(3, encodePrincipalName(request.getSname())));
+		if (request.getServerPrincipal() != null)
+			vector.add(new DERTaggedObject(3, encodePrincipalName(request.getServerPrincipal())));
 		// OPTIONAL
 		if (request.getFrom() != null)
 			vector.add(new DERTaggedObject(4, encodeKerberosTime(request.getFrom())));

Modified: incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/io/encoder/KerberosMessageEncoder.java
==============================================================================
--- incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/io/encoder/KerberosMessageEncoder.java
(original)
+++ incubator/directory/kerberos/trunk/source/main/org/apache/kerberos/io/encoder/KerberosMessageEncoder.java
Sat Oct 30 17:21:04 2004
@@ -23,6 +23,8 @@
 
 import java.util.*;
 
+import javax.security.auth.kerberos.*;
+
 public abstract class KerberosMessageEncoder {
 	
 	/*
@@ -30,18 +32,18 @@
 	              name-type[0]     INTEGER,
 	              name-string[1]   SEQUENCE OF GeneralString
 	}*/
-	protected DERSequence encodePrincipalName(PrincipalName name) {
+	protected DERSequence encodePrincipalName(KerberosPrincipal principal) {
 		
 		ASN1EncodableVector vector = new ASN1EncodableVector();
 		
-		vector.add(new DERTaggedObject(0, new DERInteger(name.getNameType())));
-		vector.add(new DERTaggedObject(1, encodeNameSequence(name)));
+		vector.add(new DERTaggedObject(0, new DERInteger(principal.getNameType())));
+		vector.add(new DERTaggedObject(1, encodeNameSequence(principal)));
 		
 		return new DERSequence(vector);
 	}
 	
-	protected DERSequence encodeNameSequence(PrincipalName name) {
-		Iterator it = name.getNameStrings().iterator();
+	protected DERSequence encodeNameSequence(KerberosPrincipal principal) {
+		Iterator it = getNameStrings(principal).iterator();
 		
 		ASN1EncodableVector vector = new ASN1EncodableVector();
 		
@@ -52,6 +54,16 @@
 		
 	}
 	
+	protected List getNameStrings(KerberosPrincipal principal) {
+		
+		final String COMPONENT_SEPARATOR = "/";
+		final String REALM_SEPARATOR     = "@";
+		
+		String nameComponent = principal.getName().split(REALM_SEPARATOR)[0];
+		String[] components = nameComponent.split(COMPONENT_SEPARATOR);
+		return Arrays.asList(components);
+	}
+	
 	/*
 	Ticket ::=                    [APPLICATION 1] SEQUENCE {
         tkt-vno[0]                   INTEGER,
@@ -64,8 +76,8 @@
 		ASN1EncodableVector vector = new ASN1EncodableVector();
 		
 		vector.add(new DERTaggedObject(0, new DERInteger(ticket.getTicketVersionNumber())));
-		vector.add(new DERTaggedObject(1, new DERGeneralString(ticket.getRealm().toString())));
-		vector.add(new DERTaggedObject(2, encodePrincipalName(ticket.getServerName())));
+		vector.add(new DERTaggedObject(1, new DERGeneralString(ticket.getRealm())));
+		vector.add(new DERTaggedObject(2, encodePrincipalName(ticket.getServerPrincipal())));
 		vector.add(new DERTaggedObject(3, encodeEncryptedData(ticket.getEncPart())));
 		
 		DERApplicationSpecific ticketSequence = null;
@@ -147,7 +159,7 @@
 		return new DERSequence(vector);
 	}
 	
-	protected DERGeneralString encodeRealm(Realm realm) {
+	protected DERGeneralString encodeRealm(String realm) {
 		return new DERGeneralString(realm.toString());
 	}
 	

Mime
View raw message