Example usage for java.io ByteArrayOutputStream reset

List of usage examples for java.io ByteArrayOutputStream reset

Introduction

In this page you can find the example usage for java.io ByteArrayOutputStream reset.

Prototype

public synchronized void reset() 

Source Link

Document

Resets the count field of this ByteArrayOutputStream to zero, so that all currently accumulated output in the output stream is discarded.

Usage

From source file:com.amalto.core.query.StorageQueryTest.java

License:asdf

public void testDuplicateFieldNames() {
    UserQueryBuilder qb = from(product);

    List<String> viewables = new ArrayList<String>();
    viewables.add("Product/Id");
    viewables.add("Product/Name");
    viewables.add("Product/Family");
    viewables.add("ProductFamily/Id");
    viewables.add("ProductFamily/Name");

    List<IWhereItem> conditions = new ArrayList<IWhereItem>();
    conditions.add(new WhereCondition("Product/Family", "JOINS", "ProductFamily/Id", "&"));

    IWhereItem fullWhere = new WhereAnd(conditions);
    qb.where(UserQueryHelper.buildCondition(qb, fullWhere, repository));

    // add order by Id to make the test stable
    qb.orderBy(product.getField("Id"), Direction.ASC);

    for (String viewableBusinessElement : viewables) {
        String viewableTypeName = StringUtils.substringBefore(viewableBusinessElement, "/"); //$NON-NLS-1$
        String viewablePath = StringUtils.substringAfter(viewableBusinessElement, "/"); //$NON-NLS-1$
        qb.select(UserQueryHelper.getFields(repository.getComplexType(viewableTypeName), viewablePath).get(0));
    }//from  w  w  w .j a  va 2s.  c o m

    StorageResults results = storage.fetch(qb.getSelect());
    assertEquals(2, results.getCount());

    DataRecordWriter writer = new ViewSearchResultsWriter();
    ByteArrayOutputStream output = new ByteArrayOutputStream();
    List<String> strings = new ArrayList<String>();
    for (DataRecord result : results) {
        try {
            writer.write(result, output);
            String document = new String(output.toByteArray(), Charset.forName("UTF-8"));
            strings.add(document);
            output.reset();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
    assertEquals(2, strings.size());
    assertEquals(
            "<result xmlns:metadata=\"http://www.talend.com/mdm/metadata\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n\t<Id>1</Id>\n\t<Name>Product name</Name>\n\t<Family>[2]</Family>\n\t<Id>2</Id>\n\t<Name>Product family #2</Name>\n</result>",
            strings.get(0));
    assertEquals(
            "<result xmlns:metadata=\"http://www.talend.com/mdm/metadata\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n\t<Id>2</Id>\n\t<Name>Renault car</Name>\n\t<Family/>\n\t<Id/>\n\t<Name/>\n</result>",
            strings.get(1));
}

From source file:com.amalto.core.query.StorageQueryTest.java

License:asdf

public void testTMDM8828() {
    UserQueryBuilder qb = from(organisation);

    List<String> viewables = new ArrayList<String>();
    viewables.add("Organisation/OrganisationId");
    viewables.add("Location/LocationId");
    viewables.add("Location/translation/locationTranslation");

    // add order by Id to make the test stable
    qb.orderBy(organisation.getField("OrganisationId"), Direction.ASC);

    List<IWhereItem> conditions = new ArrayList<IWhereItem>();
    conditions.add(new WhereCondition("Organisation/locations/location", "JOINS", "Location/LocationId", "&"));
    conditions.add(new WhereCondition("Organisation/OrganisationId", "=", "2", "&"));

    IWhereItem fullWhere = new WhereAnd(conditions);
    qb.where(UserQueryHelper.buildCondition(qb, fullWhere, repository));

    for (String viewableBusinessElement : viewables) {
        String viewableTypeName = StringUtils.substringBefore(viewableBusinessElement, "/"); //$NON-NLS-1$
        String viewablePath = StringUtils.substringAfter(viewableBusinessElement, "/"); //$NON-NLS-1$
        TypedExpression expression = UserQueryHelper
                .getFields(repository.getComplexType(viewableTypeName), viewablePath).get(0);
        qb.select(expression);//from  w  ww .j  a va2  s  . co m
    }

    StorageResults results = storage.fetch(qb.getSelect());
    assertEquals(2, results.getCount());

    DataRecordWriter writer = new ViewSearchResultsWriter();
    ByteArrayOutputStream output = new ByteArrayOutputStream();
    List<String> strings = new ArrayList<String>();
    for (DataRecord result : results) {
        try {
            writer.write(result, output);
            String document = new String(output.toByteArray(), Charset.forName("UTF-8"));
            strings.add(document);
            output.reset();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
    assertEquals(2, strings.size());
    assertEquals(
            "<result xmlns:metadata=\"http://www.talend.com/mdm/metadata\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n\t<OrganisationId>2</OrganisationId>\n\t<LocationId>t2</LocationId>\n\t<locationTranslation>Trans1</locationTranslation>\n</result>",
            strings.get(0));
    assertEquals(
            "<result xmlns:metadata=\"http://www.talend.com/mdm/metadata\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n\t<OrganisationId>2</OrganisationId>\n\t<LocationId>t2</LocationId>\n\t<locationTranslation>Trans2</locationTranslation>\n</result>",
            strings.get(1));
}

From source file:com.amalto.core.query.StorageQueryTest.java

License:asdf

public void testFKInreusableTypeWithViewSearch2() throws Exception {
    UserQueryBuilder qb = from(organization).selectId(organization)
            .select(organization.getField("org_address/city"))
            .select(organization.getField("org_address/street"))
            .select(alias(organization.getField("post_address/city"), "city"))
            .select(alias(organization.getField("post_address/street"), "street"));
    StorageResults results = storage.fetch(qb.getSelect());
    assertEquals(1, results.getCount());
    DataRecordWriter writer = new ViewSearchResultsWriter();
    ByteArrayOutputStream output = new ByteArrayOutputStream();
    String resultAsString = "";
    for (DataRecord result : results) {
        try {/*from  w w w  . j  av a 2  s .  c  om*/
            writer.write(result, output);
        } catch (IOException e) {
            throw new XmlServerException(e);
        }
        resultAsString = new String(output.toByteArray(), Charset.forName("UTF-8"));
        output.reset();
    }
    String startRoot = "<result xmlns:metadata=\"http://www.talend.com/mdm/metadata\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">";
    String endRoot = "</result>";

    String expectedResult = startRoot
            + "<org_id>1</org_id><city>[SH]</city><street>waitan rd</street><city>[BJ]</city><street>changan rd</street>"
            + endRoot;
    assertTrue(expectedResult.equals(resultAsString.replaceAll("\\r|\\n|\\t", "")));
}

From source file:com.amalto.core.query.StorageQueryTest.java

License:asdf

public void testFetchAllE2WithViewSearchResultsWriter() throws Exception {
    UserQueryBuilder qb = from(e2);/*  www. j a  v  a2  s.c o  m*/
    StorageResults results = storage.fetch(qb.getSelect());
    assertEquals(7, results.getCount());
    DataRecordWriter writer = new ViewSearchResultsWriter();
    ByteArrayOutputStream output = new ByteArrayOutputStream();
    ArrayList<String> resultsAsString = new ArrayList<String>();
    for (DataRecord result : results) {
        try {
            writer.write(result, output);
        } catch (IOException e) {
            throw new XmlServerException(e);
        }
        String document = new String(output.toByteArray(), Charset.forName("UTF-8"));
        resultsAsString.add(document);
        output.reset();
    }

    assertEquals(7, resultsAsString.size());

    String startRoot = "<result xmlns:metadata=\"http://www.talend.com/mdm/metadata\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">";
    String endRoot = "</result>";

    Set<String> expectedResults = new HashSet<String>();
    expectedResults.add(startRoot
            + "<subelement>111</subelement><subelement1>222</subelement1><name>qwe</name><fk>[ccc][ddd]</fk>"
            + endRoot);
    expectedResults.add(startRoot
            + "<subelement>344</subelement><subelement1>544</subelement1><name>55</name><fk>[aaa][bbb]</fk>"
            + endRoot);
    expectedResults.add(startRoot
            + "<subelement>333</subelement><subelement1>444</subelement1><name>tyty</name><fk>[ttt][yyy]</fk>"
            + endRoot);
    expectedResults.add(startRoot
            + "<subelement>666</subelement><subelement1>777</subelement1><name>iuj</name><fk>[aaa][bbb]</fk>"
            + endRoot);
    expectedResults.add(startRoot
            + "<subelement>6767</subelement><subelement1>7878</subelement1><name>ioiu</name><fk>[ccc][ddd]</fk>"
            + endRoot);
    expectedResults.add(startRoot
            + "<subelement>999</subelement><subelement1>888</subelement1><name>iuiiu</name><fk>[ccc][ddd]</fk>"
            + endRoot);
    expectedResults.add(startRoot
            + "<subelement>119</subelement><subelement1>120</subelement1><name>zhang</name>" + endRoot);
    for (String s : resultsAsString) {
        expectedResults.remove(s.replaceAll("\\r|\\n|\\t", ""));
    }
    assertTrue(expectedResults.isEmpty());
}

From source file:com.amalto.core.query.StorageQueryTest.java

License:asdf

public void testFetchAllE2WithJoinE1() {

    ComplexTypeMetadata type = repository.getComplexType("Product");
    UserQueryBuilder qb = UserQueryBuilder.from(type);

    List<TypedExpression> fields = UserQueryHelper.getFields(product, "Id");
    for (TypedExpression field : fields) {
        qb.select(field);/*ww  w .  ja v  a 2s . co  m*/
        qb.orderBy(product.getField("Id"), OrderBy.Direction.ASC);
    }
    fields = UserQueryHelper.getFields(product, "Name");
    for (TypedExpression field : fields) {
        qb.select(field);
    }
    fields = UserQueryHelper.getFields(productFamily, "Name");
    for (TypedExpression field : fields) {
        TypedExpression typeExpression = new Alias(field, "ProductFamily_Name");
        qb.select(typeExpression);
    }

    ArrayList conditions = new ArrayList();
    WhereCondition cond = new WhereCondition("Product/Family", "JOINS", "ProductFamily/Id", "&", false);
    conditions.add(cond);
    WhereAnd fullWhere = new WhereAnd(conditions);
    qb.where(UserQueryHelper.buildCondition(qb, fullWhere, repository));

    StorageResults results = storage.fetch(qb.getSelect());
    assertEquals(2, results.getCount());

    DataRecordWriter writer = new ViewSearchResultsWriter();
    ByteArrayOutputStream output = new ByteArrayOutputStream();
    List<String> resultsAsString = new ArrayList<String>();
    for (DataRecord result : results) {
        try {
            writer.write(result, output);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        String document = new String(output.toByteArray(), Charset.forName("UTF-8"));
        resultsAsString.add(document);
        output.reset();
    }
    assertEquals(2, resultsAsString.size());

    StringBuilder sb = new StringBuilder();
    sb.append(
            "<result xmlns:metadata=\"http://www.talend.com/mdm/metadata\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n");
    sb.append("\t<Id>1</Id>\n");
    sb.append("\t<Name>Product name</Name>\n");
    sb.append("\t<ProductFamily_Name>Product family #2</ProductFamily_Name>\n");
    sb.append("</result>");
    assertEquals(sb.toString(), resultsAsString.get(0));

    sb = new StringBuilder();
    sb.append(
            "<result xmlns:metadata=\"http://www.talend.com/mdm/metadata\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n");
    sb.append("\t<Id>2</Id>\n");
    sb.append("\t<Name>Renault car</Name>\n");
    sb.append("\t<ProductFamily_Name/>\n");
    sb.append("</result>");
    assertEquals(sb.toString(), resultsAsString.get(1));

    // Test Fetch Product by whereCondition = (Product/Id Equals 1) and (Product/Family Joins ProductFamily/Id)
    WhereCondition condition = new WhereCondition("Product/Id", "=", "1", "&", false);
    fullWhere.add(condition);
    qb.where(UserQueryHelper.buildCondition(qb, fullWhere, repository));

    results = storage.fetch(qb.getSelect());
    assertEquals(1, results.getCount());

    writer = new ViewSearchResultsWriter();
    output = new ByteArrayOutputStream();
    resultsAsString = new ArrayList<String>();
    for (DataRecord result : results) {
        try {
            writer.write(result, output);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        String document = new String(output.toByteArray(), Charset.forName("UTF-8"));
        resultsAsString.add(document);
        output.reset();
    }
    assertEquals(1, resultsAsString.size());

    sb = new StringBuilder();
    sb.append(
            "<result xmlns:metadata=\"http://www.talend.com/mdm/metadata\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n");
    sb.append("\t<Id>1</Id>\n");
    sb.append("\t<Name>Product name</Name>\n");
    sb.append("\t<ProductFamily_Name>Product family #2</ProductFamily_Name>\n");
    sb.append("</result>");
    assertEquals(sb.toString(), resultsAsString.get(0));
}

From source file:org.sakaiproject.dav.DavServlet.java

/**
 * URL rewriter./*from w  w  w  . j  a va  2 s . com*/
 * 
 * @param path
 *        Path which has to be rewiten
 */
protected String rewriteUrl(String path) {

    /**
     * Note: This code portion is very similar to URLEncoder.encode. Unfortunately, there is no way to specify to the URLEncoder which characters should be encoded. Here, ' ' should be encoded as "%20" and '/' shouldn't be encoded.
     */

    int maxBytesPerChar = 10;
    StringBuilder rewrittenPath = new StringBuilder(path.length());
    ByteArrayOutputStream buf = new ByteArrayOutputStream(maxBytesPerChar);
    OutputStreamWriter writer = null;
    try {
        writer = new OutputStreamWriter(buf, "UTF8");
    } catch (Exception e) {
        e.printStackTrace();
        writer = new OutputStreamWriter(buf);
    }

    for (int i = 0; i < path.length(); i++) {
        int c = (int) path.charAt(i);
        if (safeCharacters.get(c)) {
            rewrittenPath.append((char) c);
        } else {
            // convert to external encoding before hex conversion
            try {
                writer.write(c);
                writer.flush();
            } catch (IOException e) {
                buf.reset();
                continue;
            }
            byte[] ba = buf.toByteArray();
            for (int j = 0; j < ba.length; j++) {
                // Converting each byte in the buffer
                byte toEncode = ba[j];
                rewrittenPath.append('%');
                int low = (int) (toEncode & 0x0f);
                int high = (int) ((toEncode & 0xf0) >> 4);
                rewrittenPath.append(hexadecimal[high]);
                rewrittenPath.append(hexadecimal[low]);
            }
            buf.reset();
        }
    }

    return rewrittenPath.toString();

}

From source file:org.eclipse.hawkbit.ddi.rest.resource.DdiArtifactDownloadTest.java

@Test
@WithUser(principal = TestdataFactory.DEFAULT_CONTROLLER_ID, authorities = "ROLE_CONTROLLER", allSpPermissions = true)
@Description("Test various HTTP range requests for artifact download, e.g. chunk download or download resume.")
public void rangeDownloadArtifact() throws Exception {
    // create target
    final Target target = testdataFactory.createTarget();
    final List<Target> targets = Arrays.asList(target);

    // create ds/*from w w  w  . ja v  a2  s.  c o  m*/
    final DistributionSet ds = testdataFactory.createDistributionSet("");

    final int resultLength = 5 * 1000 * 1024;

    // create artifact
    final byte random[] = RandomUtils.nextBytes(resultLength);
    final Artifact artifact = artifactManagement.create(new ArtifactUpload(new ByteArrayInputStream(random),
            getOsModule(ds), "file1", false, resultLength));

    assertThat(random.length).isEqualTo(resultLength);

    // now assign and download successful
    assignDistributionSet(ds, targets);

    final int range = 100 * 1024;

    // full file download with standard range request
    final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    for (int i = 0; i < resultLength / range; i++) {
        final String rangeString = "" + i * range + "-" + ((i + 1) * range - 1);

        final MvcResult result = mvc.perform(get(
                "/{tenant}/controller/v1/{controllerId}/softwaremodules/{softwareModuleId}/artifacts/{filename}",
                tenantAware.getCurrentTenant(), target.getControllerId(), getOsModule(ds), "file1")
                        .header("Range", "bytes=" + rangeString))
                .andExpect(status().isPartialContent())
                .andExpect(header().string("ETag", artifact.getSha1Hash()))
                .andExpect(content().contentType(MediaType.APPLICATION_OCTET_STREAM))
                .andExpect(header().string("Accept-Ranges", "bytes"))
                .andExpect(
                        header().string("Last-Modified", dateFormat.format(new Date(artifact.getCreatedAt()))))
                .andExpect(header().longValue("Content-Length", range))
                .andExpect(header().string("Content-Range", "bytes " + rangeString + "/" + resultLength))
                .andExpect(header().string("Content-Disposition", "attachment;filename=file1")).andReturn();

        outputStream.write(result.getResponse().getContentAsByteArray());
    }

    assertThat(outputStream.toByteArray()).isEqualTo(random);

    // return last 1000 Bytes
    MvcResult result = mvc.perform(get(
            "/{tenant}/controller/v1/{controllerId}/softwaremodules/{softwareModuleId}/artifacts/{filename}",
            tenantAware.getCurrentTenant(), target.getControllerId(), getOsModule(ds), "file1").header("Range",
                    "bytes=-1000"))
            .andExpect(status().isPartialContent()).andExpect(header().string("ETag", artifact.getSha1Hash()))
            .andExpect(content().contentType(MediaType.APPLICATION_OCTET_STREAM))
            .andExpect(header().string("Accept-Ranges", "bytes"))
            .andExpect(header().string("Last-Modified", dateFormat.format(new Date(artifact.getCreatedAt()))))
            .andExpect(header().longValue("Content-Length", 1000))
            .andExpect(header().string("Content-Range",
                    "bytes " + (resultLength - 1000) + "-" + (resultLength - 1) + "/" + resultLength))
            .andExpect(header().string("Content-Disposition", "attachment;filename=file1")).andReturn();

    assertThat(result.getResponse().getContentAsByteArray())
            .isEqualTo(Arrays.copyOfRange(random, resultLength - 1000, resultLength));

    // skip first 1000 Bytes and return the rest
    result = mvc.perform(get(
            "/{tenant}/controller/v1/{controllerId}/softwaremodules/{softwareModuleId}/artifacts/{filename}",
            tenantAware.getCurrentTenant(), target.getControllerId(), getOsModule(ds), "file1").header("Range",
                    "bytes=1000-"))
            .andExpect(status().isPartialContent()).andExpect(header().string("ETag", artifact.getSha1Hash()))
            .andExpect(content().contentType(MediaType.APPLICATION_OCTET_STREAM))
            .andExpect(header().string("Accept-Ranges", "bytes"))
            .andExpect(header().string("Last-Modified", dateFormat.format(new Date(artifact.getCreatedAt()))))
            .andExpect(header().longValue("Content-Length", resultLength - 1000))
            .andExpect(header().string("Content-Range",
                    "bytes " + 1000 + "-" + (resultLength - 1) + "/" + resultLength))
            .andExpect(header().string("Content-Disposition", "attachment;filename=file1")).andReturn();

    assertThat(result.getResponse().getContentAsByteArray())
            .isEqualTo(Arrays.copyOfRange(random, 1000, resultLength));

    // Start download from file end fails
    mvc.perform(get(
            "/{tenant}/controller/v1/{controllerId}/softwaremodules/{softwareModuleId}/artifacts/{filename}",
            tenantAware.getCurrentTenant(), target.getControllerId(), getOsModule(ds), "file1").header("Range",
                    "bytes=" + random.length + "-"))
            .andExpect(status().isRequestedRangeNotSatisfiable())
            .andExpect(content().contentType(MediaType.APPLICATION_OCTET_STREAM))
            .andExpect(header().string("Accept-Ranges", "bytes"))
            .andExpect(header().string("Last-Modified", dateFormat.format(new Date(artifact.getCreatedAt()))))
            .andExpect(header().string("Content-Range", "bytes */" + random.length))
            .andExpect(header().string("Content-Disposition", "attachment;filename=file1"));

    // multipart download - first 20 bytes in 2 parts
    result = mvc.perform(get(
            "/{tenant}/controller/v1/{controllerId}/softwaremodules/{softwareModuleId}/artifacts/{filename}",
            tenantAware.getCurrentTenant(), target.getControllerId(), getOsModule(ds), "file1").header("Range",
                    "bytes=0-9,10-19"))
            .andExpect(status().isPartialContent()).andExpect(header().string("ETag", artifact.getSha1Hash()))
            .andExpect(content().contentType("multipart/byteranges; boundary=THIS_STRING_SEPARATES_MULTIPART"))
            .andExpect(header().string("Accept-Ranges", "bytes"))
            .andExpect(header().string("Last-Modified", dateFormat.format(new Date(artifact.getCreatedAt()))))
            .andExpect(header().string("Content-Disposition", "attachment;filename=file1")).andReturn();

    outputStream.reset();

    outputStream.write("\r\n--THIS_STRING_SEPARATES_MULTIPART\r\n".getBytes(StandardCharsets.ISO_8859_1));
    outputStream
            .write(("Content-Range: bytes 0-9/" + resultLength + "\r\n").getBytes(StandardCharsets.ISO_8859_1));
    outputStream.write(Arrays.copyOfRange(random, 0, 10));
    outputStream.write("\r\n--THIS_STRING_SEPARATES_MULTIPART\r\n".getBytes(StandardCharsets.ISO_8859_1));
    outputStream.write(
            ("Content-Range: bytes 10-19/" + resultLength + "\r\n").getBytes(StandardCharsets.ISO_8859_1));
    outputStream.write(Arrays.copyOfRange(random, 10, 20));
    outputStream.write("\r\n--THIS_STRING_SEPARATES_MULTIPART--".getBytes(StandardCharsets.ISO_8859_1));

    assertThat(result.getResponse().getContentAsByteArray()).isEqualTo(outputStream.toByteArray());

}

From source file:com.qut.middleware.esoe.sso.plugins.redirect.handler.impl.RedirectLogicImpl.java

private AuthnRequest getRedirectRequest(SSOProcessorData data, RedirectBindingData bindingData)
        throws RedirectBindingException {
    InflaterInputStream inflaterStream = null;
    ByteArrayOutputStream inflatedByteStream = null;
    byte[] chunk = new byte[TMP_BUFFER_SIZE];

    boolean signed = (bindingData.getSignature() != null && bindingData.getSignature().length() > 0);

    SSOProcessor ssoProcessor = data.getSSOProcessor();
    String remoteAddress = data.getRemoteAddress();

    try {/*from  w w  w.ja va2s  . c om*/
        if (bindingData.getSAMLRequestString() == null || bindingData.getSAMLRequestString().length() <= 0) {
            ssoProcessor.createStatusAuthnResponse(data, StatusCodeConstants.requester, null,
                    "No AuthnRequest document was supplied to the Redirect binding.", true);
            this.logger.error(
                    "[SSO for {}] Redirect binding failed: No AuthnRequest document was supplied in the request.",
                    remoteAddress);
            throw new RedirectBindingException(
                    "Redirect binding failed as no AuthnRequest document was supplied in the request.");
        }

        if (bindingData.getRequestEncoding() != null
                && !bindingData.getRequestEncoding().equals(BindingConstants.deflateEncoding)) {
            ssoProcessor.createStatusAuthnResponse(data, StatusCodeConstants.requester, null,
                    "The given SAML Request encoding is not supported in this implementation.", true);
            this.logger.error(
                    "[SSO for {}] Redirect binding failed: SAML Request encoding '{}' is not supported in the current implementation.",
                    new Object[] { remoteAddress, bindingData.getRequestEncoding() });
            throw new RedirectBindingException(
                    "Redirect binding failed as the given SAML Request encoding is not supported in the current implementation.");
        }

        if (bindingData.getSignature() != null) {
            ssoProcessor.createStatusAuthnResponse(data, StatusCodeConstants.requester, null,
                    "Signed Redirect binding documents are not supported in this implementation.", true);
            this.logger.error(
                    "[SSO for {}] Redirect binding failed: Signed Redirect binding documents are not supported in the current implementation.",
                    remoteAddress);
            throw new RedirectBindingException(
                    "Redirect binding failed as Signed Redirect binding documents are not supported in the current implementation.");
        }
    } catch (SSOException e) {
        this.logger.error("[SSO for {}] Redirect binding failed to generate an error response. Error was: {}",
                new Object[] { remoteAddress, e.getMessage() });
        throw new RedirectBindingException(
                "Redirect binding failed to generate an error reponse. Original error follows", e);
    }

    try {
        /*
         * Retrieves the AuthnRequest from the encoded and compressed String extracted from the request of SAML HTTP
         * Redirect. The AuthnRequest XML is retrieved in the following order: 1. Base64 decode, 2. Inflate
         */
        byte[] decodedBytes = Base64.decodeBase64(bindingData.getSAMLRequestString().getBytes());
        ByteArrayInputStream decodedByteStream = new ByteArrayInputStream(decodedBytes);
        inflaterStream = new InflaterInputStream(decodedByteStream, new Inflater(true));
        inflatedByteStream = new ByteArrayOutputStream();

        int writeCount = 0;
        int count = 0;
        // Inflate and dump in the output stream to build a byte array.
        while ((count = inflaterStream.read(chunk)) >= 0) {
            inflatedByteStream.write(chunk, 0, count);
            writeCount = writeCount + count;
        }

        byte[] samlRequestDocument = inflatedByteStream.toByteArray();

        AuthnRequest authnRequest = ssoProcessor.unmarshallRequest(samlRequestDocument, signed);
        this.logger.debug("[SSO for {}] AuthnRequest was unmarshalled successfully by the SSO Processor",
                remoteAddress);

        return authnRequest;
    } catch (IOException e) {
        this.logger.error(
                "[SSO for {}] IO exception occurred while inflating the request document. Error was: {}",
                new Object[] { remoteAddress, e.getMessage() });
        throw new RedirectBindingException("IO exception occurred while inflating the request document.");
    } catch (SignatureValueException e) {
        this.logger.error(
                "[SSO for {}] Signature value exception occurred while trying to unmarshal the redirect request. Error was: {}",
                new Object[] { remoteAddress, e.getMessage() });
        this.logger.debug(
                "[SSO for {}] Signature value exception occurred while trying to unmarshal the redirect request. Exception follows",
                remoteAddress, e);
        throw new RedirectBindingException(
                "Signature value exception occurred while trying to unmarshal the redirect request.");
    } catch (ReferenceValueException e) {
        this.logger.error(
                "[SSO for {}] Reference value exception occurred while unmarshalling the redirect request. Error was: {}",
                new Object[] { remoteAddress, e.getMessage() });
        this.logger.debug(
                "[SSO for {}] Reference value exception occurred while unmarshalling the redirect request. Exception follows",
                remoteAddress, e);
        throw new RedirectBindingException(
                "Reference value exception occurred while unmarshalling the redirect request.");
    } catch (UnmarshallerException e) {
        this.logger.error(
                "[SSO for {}] Unmarshaller exception occurred while unmarshalling the redirect request. Error was: {}",
                new Object[] { remoteAddress, e.getMessage() });
        this.logger.debug(
                "[SSO for {}] Unmarshaller exception occurred while unmarshalling the redirect request. Exception follows",
                remoteAddress, e);
        throw new RedirectBindingException(
                "Unmarshaller exception occurred while unmarshalling the redirect request.");
    } finally {
        try {
            if (inflatedByteStream != null) {
                inflatedByteStream.reset();
                inflatedByteStream.close();
            }

            if (inflaterStream != null)
                inflaterStream.close();
        } catch (IOException e) {
            this.logger.error("Unable to close stream correctly - " + e.getLocalizedMessage());
            this.logger.debug(e.getLocalizedMessage(), e);
        }
    }
}