Implemented bureau authentication

* Token member for bureaus
* Exception type for failed authentication
* Authenticate function
* Bureau id to credentials
* Fixed bad constructor and toString


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5149 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Jamie Doornbos
2008-06-02 04:38:01 +00:00
parent 6c34b9e3ed
commit 69451c5682
5 changed files with 74 additions and 19 deletions
@@ -35,6 +35,20 @@ public class BureauCredentials extends Credentials
*/
public String sessionToken;
/**
* The id of the bureau logging in.
*/
public String bureauId;
/**
* Test if a given name object matches the name that we generate.
*/
public static boolean isBureau (Name name)
{
String normal = name.getNormal();
return normal.startsWith("@@bureau:") && normal.endsWith("@@");
}
/**
* Creates an empty credentials for streaming. Should not be used directly.
*/
@@ -48,18 +62,14 @@ public class BureauCredentials extends Credentials
public BureauCredentials (String bureauId)
{
super(new Name("@@bureau:" + bureauId + "@@"));
this.bureauId = bureauId;
}
@Override // inherit documentation
protected void toString (StringBuilder buf)
{
super.toString(buf);
buf.append(" token=").append(sessionToken);
}
// inherit documentation - from Object
public String toString ()
{
return super.toString() + ", token=" + sessionToken;
buf.append(" id=").append(bureauId).
append(" token=").append(sessionToken);
}
}