package org.fcrepo.server.security.xacml.pep.ws.operations; import java.net.URI; import java.util.HashMap; import java.util.Map; import javax.xml.ws.handler.soap.SOAPMessageContext; import org.apache.cxf.binding.soap.SoapFault; import org.fcrepo.common.Constants; import org.fcrepo.server.security.RequestCtx; import org.fcrepo.server.security.xacml.pep.ContextHandler; import org.fcrepo.server.security.xacml.pep.PEPException; import org.fcrepo.server.security.xacml.pep.ResourceAttributes; import org.fcrepo.server.security.xacml.util.LogUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.jboss.security.xacml.sunxacml.attr.AttributeValue; import org.jboss.security.xacml.sunxacml.attr.DateTimeAttribute; import org.jboss.security.xacml.sunxacml.attr.StringAttribute; public class CompareDatastreamChecksumHandler extends AbstractOperationHandler { private static final Logger logger = LoggerFactory.getLogger(CompareDatastreamChecksumHandler.class); public CompareDatastreamChecksumHandler(ContextHandler contextHandler) throws PEPException { super(contextHandler); } @Override public RequestCtx handleRequest(SOAPMessageContext context) throws OperationHandlerException { logger.debug("GetDatastreamHandler/handleRequest!"); RequestCtx req = null; Object oMap = null; String pid = null; String dsID = null; String versionDate = null; try { oMap = getSOAPRequestObjects(context); logger.debug("Retrieved SOAP Request Objects"); } catch (SoapFault af) { logger.error("Error obtaining SOAP Request Objects", af); throw new OperationHandlerException("Error obtaining SOAP Request Objects", af); } try { pid = (String) callGetter("getPid",oMap); dsID = (String) callGetter("getDsID", oMap); versionDate = (String) callGetter("getVersionDate", oMap); } catch (Exception e) { logger.error("Error obtaining parameters", e); throw new OperationHandlerException("Error obtaining parameters.", e); } logger.debug("Extracted SOAP Request Objects"); Map<URI, AttributeValue> actions = new HashMap<URI, AttributeValue>(); Map<URI, AttributeValue> resAttr; try { resAttr = ResourceAttributes.getResources(pid); if (dsID != null && !dsID.isEmpty()) { resAttr.put(Constants.DATASTREAM.ID.getURI(), new StringAttribute(dsID)); } if (versionDate != null && !versionDate.isEmpty()) { resAttr.put(Constants.DATASTREAM.AS_OF_DATETIME.getURI(), DateTimeAttribute.getInstance(versionDate)); } actions.put(Constants.ACTION.ID.getURI(), Constants.ACTION.COMPARE_DATASTREAM_CHECKSUM .getStringAttribute()); actions.put(Constants.ACTION.API.getURI(), Constants.ACTION.APIM.getStringAttribute()); req = getContextHandler().buildRequest(getSubjects(context), actions, resAttr, getEnvironment(context)); LogUtil.statLog(getUser(context), Constants.ACTION.COMPARE_DATASTREAM_CHECKSUM.uri, pid, dsID); } catch (Exception e) { logger.error(e.getMessage(), e); throw new OperationHandlerException(e.getMessage(), e); } return req; } @Override public RequestCtx handleResponse(SOAPMessageContext context) throws OperationHandlerException { return null; } }