/*
* Copyright 2011 by Graz University of Technology, Austria
* MOCCA has been developed by the E-Government Innovation Center EGIZ, a joint
* initiative of the Federal Chancellery Austria and Graz University of Technology.
*
* Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
* the European Commission - subsequent versions of the EUPL (the "Licence");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
* http://www.osor.eu/eupl/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*
* This product combines work with different licenses. See the "NOTICE" text
* file for details on the various modules and licenses.
* The "NOTICE" text file is part of the distribution. Any derivative works
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
package at.gv.egiz.bku.slcommands.impl;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.net.MalformedURLException;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.Result;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import at.buergerkarte.namespaces.personenbindung._20020506_.CompressedIdentityLinkType;
import at.buergerkarte.namespaces.securitylayer._1_2_3.AnyChildrenType;
import at.buergerkarte.namespaces.securitylayer._1_2_3.InfoboxReadRequestType;
import at.gv.egiz.bku.slcommands.InfoboxReadResult;
import at.gv.egiz.bku.slcommands.SLCommand;
import at.gv.egiz.bku.slcommands.SLCommandContext;
import at.gv.egiz.bku.slexceptions.SLCommandException;
import at.gv.egiz.bku.slexceptions.SLExceptionMessages;
import at.gv.egiz.bku.slexceptions.SLRuntimeException;
import at.gv.egiz.idlink.CompressedIdentityLinkFactory;
import at.gv.egiz.idlink.asn1.IdentityLink;
import at.gv.egiz.stal.InfoboxReadRequest;
import at.gv.egiz.stal.STALRequest;
/**
* An implementation of the {@link Infobox} IdentityLink as
* specified in Security Layer 1.2
*
* @author mcentner
*/
public class IdentityLinkInfoboxImpl extends AbstractBinaryFileInfobox {
/**
* Logging facility.
*/
private final Logger log = LoggerFactory.getLogger(IdentityLinkInfoboxImpl.class);
/**
* The box specific parameter IdentityLinkDomainIdentifier.
*/
public static final String BOX_SPECIFIC_PARAMETER_IDENTITY_LINK_DOMAIN_IDENTIFIER = "IdentityLinkDomainIdentifier";
private IdentityLinkTransformer identityLinkTransformer;
/**
* @return the identityLinkTransformer
*/
public IdentityLinkTransformer getIdentityLinkTransformer() {
return identityLinkTransformer;
}
/**
* @param identityLinkTransformer the identityLinkTransformer to set
*/
public void setIdentityLinkTransformer(
IdentityLinkTransformer identityLinkTransformer) {
this.identityLinkTransformer = identityLinkTransformer;
}
/**
* The value of the box specific parameter IdentityLinkDomainIdentifier.
*/
private String domainIdentifier;
@Override
public String getIdentifier() {
return "IdentityLink";
}
/**
* @return the value of the box specific parameter IdentityLinkDomainIdentifier
*/
public String getDomainIdentifier() {
return domainIdentifier;
}
@Override
public InfoboxReadResult read(InfoboxReadRequestType req, SLCommandContext cmdCtx) throws SLCommandException {
AnyChildrenType boxSpecificParameters = req.getBoxSpecificParameters();
if (boxSpecificParameters != null) {
// check BoxSpecificParameters
List