Source code: Identifier.java

index |  69 lines | javadoc ]

package nl.west.aaa;


import java.io.*;
import java.net.*;

/**
 * Identifies a aaa server or client.
 * Possibly sotre keys for transport,
 * acceptable record formats etc..
 */
public class Identifier
{

    /**
     * Currently a host is identified by it's
     * hostname until a better scheme is
     * available.
     */
    private String hostname;

    /**
     * Construct a new Indetifier given
     * it's hostname.
     */
    public Identifier(String hostname)
    { 
        this.hostname=hostname;
    }

    public Identifier(InetAddress addr)
    {
        this.hostname=addr.getHostName();
    }
    
    /**
     * Produces a string representation
     * of this Identifier.
     */
    public String toString()
    {
        return "ID{"+hostname+"}";
    }

    /**
     * Test if these Identifiers match.
     * If the hostname match the Identifiers match.
     */
    public boolean equals(Identifier id)
    {
        return (id!=null)&&(id.hostname.equals(hostname));
    }

    /**
     * Test if these Identifiers match.
     * If the hostname match the Identifiers match.
     */
    public boolean equals(Object o)
    {
        if(!(o instanceof Identifier))
            return false;
        return this.equals((Identifier)o);
    }
    
    public String getHostname()
    {
	return hostname;
    }
}


Arthur <arthur@ch.twi.tudelft.nl> http://ch.twi.tudelft.nl/~arthur/
2002-05-27