use of org.apache.cxf.rs.security.saml.DeflateEncoderDecoder in project ddf by codice.
the class RestSecurityTest method testInflateDeflateWithTokenDuplication.
@Test
public void testInflateDeflateWithTokenDuplication() throws Exception {
String token = "valid_grant valid_grant valid_grant valid_grant valid_grant valid_grant";
DeflateEncoderDecoder deflateEncoderDecoder = new DeflateEncoderDecoder();
byte[] deflatedToken = deflateEncoderDecoder.deflateToken(token.getBytes());
String cxfInflatedToken = IOUtils.toString(deflateEncoderDecoder.inflateToken(deflatedToken));
String streamInflatedToken = IOUtils.toString(new InflaterInputStream(new ByteArrayInputStream(deflatedToken), new Inflater(true)));
assertNotSame(cxfInflatedToken, token);
assertEquals(streamInflatedToken, token);
}
use of org.apache.cxf.rs.security.saml.DeflateEncoderDecoder in project ddf by codice.
the class SamlSecurityTest method testInflateDeflateWithTokenDuplication.
@Test
public void testInflateDeflateWithTokenDuplication() throws Exception {
String token = "valid_grant valid_grant valid_grant valid_grant valid_grant valid_grant";
DeflateEncoderDecoder deflateEncoderDecoder = new DeflateEncoderDecoder();
byte[] deflatedToken = deflateEncoderDecoder.deflateToken(token.getBytes());
String cxfInflatedToken = IOUtils.toString(deflateEncoderDecoder.inflateToken(deflatedToken));
String streamInflatedToken = IOUtils.toString(new InflaterInputStream(new ByteArrayInputStream(deflatedToken), new Inflater(true)));
assertNotSame(cxfInflatedToken, token);
assertEquals(streamInflatedToken, token);
}
use of org.apache.cxf.rs.security.saml.DeflateEncoderDecoder in project cxf by apache.
the class JAXRSSamlTest method encodeToken.
private String encodeToken(String assertion) throws Base64Exception {
byte[] tokenBytes = assertion.getBytes(StandardCharsets.UTF_8);
tokenBytes = new DeflateEncoderDecoder().deflateToken(tokenBytes);
StringWriter writer = new StringWriter();
Base64Utility.encode(tokenBytes, 0, tokenBytes.length, writer);
return writer.toString();
}
use of org.apache.cxf.rs.security.saml.DeflateEncoderDecoder in project cxf by apache.
the class SamlRedirectBindingFilter method encodeAuthnRequest.
protected String encodeAuthnRequest(Element authnRequest) throws IOException {
String requestMessage = DOM2Writer.nodeToString(authnRequest);
DeflateEncoderDecoder encoder = new DeflateEncoderDecoder();
byte[] deflatedBytes = encoder.deflateToken(requestMessage.getBytes(StandardCharsets.UTF_8));
return Base64Utility.encode(deflatedBytes);
}
use of org.apache.cxf.rs.security.saml.DeflateEncoderDecoder in project cxf by apache.
the class SamlPostBindingFilter method encodeAuthnRequest.
protected String encodeAuthnRequest(Element authnRequest) throws IOException {
String requestMessage = DOM2Writer.nodeToString(authnRequest);
final byte[] deflatedBytes;
// Not correct according to the spec but required by some IDPs.
if (useDeflateEncoding) {
DeflateEncoderDecoder encoder = new DeflateEncoderDecoder();
deflatedBytes = encoder.deflateToken(requestMessage.getBytes(StandardCharsets.UTF_8));
} else {
deflatedBytes = requestMessage.getBytes(StandardCharsets.UTF_8);
}
return Base64Utility.encode(deflatedBytes);
}
Aggregations