FSAssertionArtifact.java revision a688bcbb4bcff5398fdd29b86f83450257dc0df4
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3e14f97f673e8a630f076077de35afdd43dc1587Roger A. Faulkner * Copyright (c) 2006 Sun Microsystems Inc. All Rights Reserved
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * The contents of this file are subject to the terms
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin * of the Common Development and Distribution License
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * (the License). You may not use this file except in
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * compliance with the License.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * You can obtain a copy of the License at
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * See the License for the specific language governing
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * permission and limitations under the License.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * When distributing Covered Code, include this CDDL
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * Header Notice in each file and include the License file
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * If applicable, add the following below the CDDL Header,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * with the fields enclosed by brackets [] replaced by
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * your own identifying information:
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * "Portions Copyrighted [year] [name of copyright owner]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * $Id: FSAssertionArtifact.java,v 1.3 2008/06/25 05:46:43 qcheng Exp $
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinimport com.sun.identity.federation.message.common.FSMsgException;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinimport com.sun.identity.saml.protocol.AssertionArtifact;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * This class represents the <code>AssertionArtifact</code> element in the
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * <code>SAML</code> protocol schema. Current implementation supports
34f9b3eef6fdadbda0a846aa4d68691ac40eace5Roland Mainz * TYPE 1 artifact only. Other type of artifact can be supported by
34f9b3eef6fdadbda0a846aa4d68691ac40eace5Roland Mainz * extending this class.
34f9b3eef6fdadbda0a846aa4d68691ac40eace5Roland Mainz * @supported.all.api
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinpublic class FSAssertionArtifact extends AssertionArtifact {
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * Default Artifact length
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * Default Artifact Type Code 0 Constant
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * Default Artifact Type Code 1 Constant
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * Default Artifact Type Code Byte Array
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin public final static byte[] ARTIFACT_1_TYPE_CODE = {0, 3};
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * Default Constructor.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * Constructor to create <code>AssertionArtifact</code> object.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * @param theArtifact is the string that is generated by a provider.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * @throws SAMLException if there is an error decoding
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * the artifact string , the length of the artifact string
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * is incorrect , the <code>TYPE CODE</code> in the artifact
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * or other errors which prevent creation of
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * this object.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin public FSAssertionArtifact(String theArtifact) throws FSMsgException {
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin // check if the input is empty
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin if ((theArtifact == null) || (theArtifact.length() == 0)) {
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin FSUtils.debug.message("FSAssertionArtifact: empty input.");
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin // decode the artifact
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin FSUtils.debug.message("FSAssertionArtifact: decode error");
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin // check if the length is 42bytes
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin FSUtils.debug.message("FSAssertionArtifact: the length is"
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin // check if the typecode is correct
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin FSUtils.debug.message("FSAssertionArtifact: wrong typecode.");
34f9b3eef6fdadbda0a846aa4d68691ac40eace5Roland Mainz // get the sourceID and assertionHandle
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin System.arraycopy(raw, 2, sBytes, 0, IFSConstants.ART_ID_LENGTH);
34f9b3eef6fdadbda0a846aa4d68691ac40eace5Roland Mainz System.arraycopy(raw, 22, aBytes, 0, IFSConstants.ART_ID_LENGTH);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * Constructor to create <code>FSAssertionArtifact</code> object.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * @param idBytes the source identifier in the <code>Assertion</code>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * @param handleBytes the assertion identifier
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * @throws SAMLException if wrong input or couldn't encode the artifact.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin public FSAssertionArtifact(byte[] idBytes, byte[] handleBytes)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin FSUtils.debug.message("FSAssertionArtifact: null input.");
34f9b3eef6fdadbda0a846aa4d68691ac40eace5Roland Mainz if ((idBytes.length != IFSConstants.ART_ID_LENGTH) ||
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin FSUtils.debug.message("FSAssertionArtifact: wrong input length.");
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin assertionHandle = SAMLUtils.byteArrayToString(handleBytes);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin FSUtils.debug.message("FSAssertionArtifact: exception encode"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin + " input:", e);