mace-opensaml-users - Re: SAMLArtifact class
Subject: OpenSAML user discussion
List archive
- From: Tom Scavo <>
- To:
- Subject: Re: SAMLArtifact class
- Date: Fri, 21 Jan 2005 16:12:36 -0500
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=oc2Bu+JD72iLiTRd3DsiGDZcgu/edyoDB0/iL+qwSBdvsLaSSn4mxODMxKIiAmpARar+tK3WZRB+O9PrR/+4VyKP2EDwIijulTtOGNlB4GlMaWCkF4BV4CD7793rGrwUrW0XLND815pD/6sBglyjEFcsvjHQh8VMgkCq2oWL59Y=
On Thu, 13 Jan 2005 07:50:16 -0500, Tom Scavo
<>
wrote:
> Is anybody working on a SAMLArtifact class? Has an API been agreed
> upon? (I have some code.)
One possible API is given by the following interface:
public interface Artifact extends ByteSizedSequence {
public TypeCode getTypeCode();
public RemainingArtifact getRemainingArtifact();
public static interface TypeCode extends ByteSizedSequence {
public Parser getParser() throws Exception;
}
public static interface RemainingArtifact extends ByteSizedSequence {}
public String encode();
public static interface Parser {
public Artifact parse( String s ) throws Exception;
}
}
where ByteSizedSequence is the simple interface
public interface ByteSizedSequence {
public int size();
public byte[] getBytes();
public String toString();
public boolean equals( Object o );
}
Here is one possible implementation of Artifact:
public class SAMLArtifact implements Artifact {
protected Artifact.TypeCode typeCode = null;
protected Artifact.RemainingArtifact remainingArtifact = null;
public SAMLArtifact() {}
public Artifact.TypeCode getTypeCode() {
return this.typeCode;
}
public Artifact.RemainingArtifact getRemainingArtifact() {
return this.remainingArtifact;
}
public static final class TypeCodeImpl extends TwoByteSequence
implements Artifact.TypeCode {
public TypeCodeImpl( byte b0, byte b1 ) { super( b0, b1 ); }
public TypeCodeImpl( short tc ) { super( tc ); }
public String toString() {
return "0x" + super.toString();
}
public Artifact.Parser getParser() throws Exception {
String prefix = "org.opensaml.artifact.SAMLArtifactType";
String suffix = "$ParserImpl";
String typeCodeStr = super.toString();
String className = prefix + typeCodeStr + suffix;
return (Artifact.Parser) Class.forName( className ).newInstance();
}
}
public static Artifact.TypeCode getTypeCode( String s ) {
byte[] bytes = Base64.decodeBase64( s.getBytes() );
return new TypeCodeImpl( (byte) bytes[0], (byte) bytes[1] );
}
public int size() {
return this.typeCode.size() + this.remainingArtifact.size();
}
public byte[] getBytes() {
byte[] bytes0 = this.typeCode.getBytes();
byte[] bytes1 = this.remainingArtifact.getBytes();
return Util.concatenate( bytes0, bytes1 );
}
public String encode() {
return new String( Base64.encodeBase64( this.getBytes() ) );
}
public String toString() {
return new String( Hex.encodeHex( this.getBytes() ) );
}
public boolean equals( Object o ) {
SAMLArtifact artifact = (SAMLArtifact) o;
return Arrays.equals( this.getBytes(), artifact.getBytes() );
}
public static class ParserImpl implements Artifact.Parser {
public Artifact parse( String s ) throws Exception {
return new SAMLArtifact();
}
}
}
Specifc implementations of SAML artifacts would extend SAMLArtifact.
For instance, I have implemented
SAMLArtifactType0000
SAMLArtifactType0001
SAMLArtifactType0002
SAMLArtifactType0003
SAMLArtifactType0004
The class name is always "SAMLArtifactType" followed by the hex
encoding of the type code. Each class contains an implementation of
Artifact.Parser called ParserImpl. In this way, the SAMLArtifact
implementation can locate the appropriate parser on-demand (based on
the type code).
Let me know what you think.
Cheers,
Tom
- SAMLArtifact class, Tom Scavo, 01/13/2005
- Re: SAMLArtifact class, Walter Hoehn, 01/13/2005
- Re: SAMLArtifact class, Tom Scavo, 01/13/2005
- Re: SAMLArtifact class, Walter Hoehn, 01/13/2005
- Re: SAMLArtifact class, Tom Scavo, 01/15/2005
- Re: SAMLArtifact class, Tom Scavo, 01/21/2005
- Re: SAMLArtifact class, Tom Scavo, 01/15/2005
- Re: SAMLArtifact class, Walter Hoehn, 01/13/2005
- Re: SAMLArtifact class, Tom Scavo, 01/13/2005
- RE: SAMLArtifact class, Scott Cantor, 01/13/2005
- Re: SAMLArtifact class, Tom Scavo, 01/21/2005
- Re: SAMLArtifact class, Tom Scavo, 01/25/2005
- RE: SAMLArtifact class, Scott Cantor, 01/25/2005
- Re: SAMLArtifact class, Walter Hoehn, 01/13/2005
Archive powered by MHonArc 2.6.16.