javax.xml.crypto.Data Java Examples

The following examples show how to use javax.xml.crypto.Data. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GenerationTests.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public Data dereference(final URIReference ref, XMLCryptoContext ctx)
throws URIReferenceException {
    String uri = ref.getURI();
    if (uri.equals(STYLESHEET) || uri.equals(STYLESHEET_B64)) {
        try {
            FileInputStream fis = new FileInputStream(new File
                (DATA_DIR, uri.substring(uri.lastIndexOf('/'))));
            return new OctetStreamData(fis,ref.getURI(),ref.getType());
        } catch (Exception e) { throw new URIReferenceException(e); }
    }

    // fallback on builtin deref
    return defaultUd.dereference(ref, ctx);
}
 
Example #2
Source File: GenerationTests.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public Data dereference(final URIReference ref, XMLCryptoContext ctx)
throws URIReferenceException {
    String uri = ref.getURI();
    if (uri.equals(STYLESHEET) || uri.equals(STYLESHEET_B64)) {
        try {
            FileInputStream fis = new FileInputStream(new File
                (DATA_DIR, uri.substring(uri.lastIndexOf('/'))));
            return new OctetStreamData(fis,ref.getURI(),ref.getType());
        } catch (Exception e) { throw new URIReferenceException(e); }
    }

    // fallback on builtin deref
    return defaultUd.dereference(ref, ctx);
}
 
Example #3
Source File: ValidationTests.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public Data dereference(final URIReference ref, XMLCryptoContext ctx)
throws URIReferenceException {
    String uri = ref.getURI();
    if (uri.equals(STYLESHEET) || uri.equals(STYLESHEET_B64)) {
        try {
            FileInputStream fis = new FileInputStream(new File
                (DATA_DIR, uri.substring(uri.lastIndexOf('/'))));
            return new OctetStreamData(fis,ref.getURI(),ref.getType());
        } catch (Exception e) { throw new URIReferenceException(e); }
    }

    // fallback on builtin deref
    return defaultUd.dereference(ref, ctx);
}
 
Example #4
Source File: GenerationTests.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public Data dereference(final URIReference ref, XMLCryptoContext ctx)
throws URIReferenceException {
    String uri = ref.getURI();
    if (uri.equals(STYLESHEET) || uri.equals(STYLESHEET_B64)) {
        try {
            FileInputStream fis = new FileInputStream(new File
                (DATA_DIR, uri.substring(uri.lastIndexOf('/'))));
            return new OctetStreamData(fis,ref.getURI(),ref.getType());
        } catch (Exception e) { throw new URIReferenceException(e); }
    }

    // fallback on builtin deref
    return defaultUd.dereference(ref, ctx);
}
 
Example #5
Source File: GenerationTests.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public Data dereference(final URIReference ref, XMLCryptoContext ctx)
throws URIReferenceException {
    String uri = ref.getURI();
    if (uri.equals(STYLESHEET) || uri.equals(STYLESHEET_B64)) {
        try {
            FileInputStream fis = new FileInputStream(new File
                (DATA_DIR, uri.substring(uri.lastIndexOf('/'))));
            return new OctetStreamData(fis,ref.getURI(),ref.getType());
        } catch (Exception e) { throw new URIReferenceException(e); }
    }

    // fallback on builtin deref
    return defaultUd.dereference(ref, ctx);
}
 
Example #6
Source File: ValidationTests.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public Data dereference(final URIReference ref, XMLCryptoContext ctx)
throws URIReferenceException {
    String uri = ref.getURI();
    if (uri.equals(STYLESHEET) || uri.equals(STYLESHEET_B64)) {
        try {
            FileInputStream fis = new FileInputStream(new File
                (DATA_DIR, uri.substring(uri.lastIndexOf('/'))));
            return new OctetStreamData(fis,ref.getURI(),ref.getType());
        } catch (Exception e) { throw new URIReferenceException(e); }
    }

    // fallback on builtin deref
    return defaultUd.dereference(ref, ctx);
}
 
Example #7
Source File: ValidationTests.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public Data dereference(final URIReference ref, XMLCryptoContext ctx)
throws URIReferenceException {
    String uri = ref.getURI();
    if (uri.equals(STYLESHEET) || uri.equals(STYLESHEET_B64)) {
        try {
            FileInputStream fis = new FileInputStream(new File
                (DATA_DIR, uri.substring(uri.lastIndexOf('/'))));
            return new OctetStreamData(fis,ref.getURI(),ref.getType());
        } catch (Exception e) { throw new URIReferenceException(e); }
    }

    // fallback on builtin deref
    return defaultUd.dereference(ref, ctx);
}
 
Example #8
Source File: GenerationTests.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public Data dereference(final URIReference ref, XMLCryptoContext ctx)
throws URIReferenceException {
    String uri = ref.getURI();
    if (uri.equals(STYLESHEET) || uri.equals(STYLESHEET_B64)) {
        try {
            FileInputStream fis = new FileInputStream(new File
                (DATA_DIR, uri.substring(uri.lastIndexOf('/'))));
            return new OctetStreamData(fis,ref.getURI(),ref.getType());
        } catch (Exception e) { throw new URIReferenceException(e); }
    }

    // fallback on builtin deref
    return defaultUd.dereference(ref, ctx);
}
 
Example #9
Source File: GenerationTests.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public Data dereference(final URIReference ref, XMLCryptoContext ctx)
throws URIReferenceException {
    String uri = ref.getURI();
    if (uri.equals(STYLESHEET) || uri.equals(STYLESHEET_B64)) {
        try {
            FileInputStream fis = new FileInputStream(new File
                (DATA_DIR, uri.substring(uri.lastIndexOf('/'))));
            return new OctetStreamData(fis,ref.getURI(),ref.getType());
        } catch (Exception e) { throw new URIReferenceException(e); }
    }

    // fallback on builtin deref
    return defaultUd.dereference(ref, ctx);
}
 
Example #10
Source File: ValidationTests.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public Data dereference(final URIReference ref, XMLCryptoContext ctx)
throws URIReferenceException {
    String uri = ref.getURI();
    if (uri.equals(STYLESHEET) || uri.equals(STYLESHEET_B64)) {
        try {
            FileInputStream fis = new FileInputStream(new File
                (DATA_DIR, uri.substring(uri.lastIndexOf('/'))));
            return new OctetStreamData(fis,ref.getURI(),ref.getType());
        } catch (Exception e) { throw new URIReferenceException(e); }
    }

    // fallback on builtin deref
    return defaultUd.dereference(ref, ctx);
}
 
Example #11
Source File: GenerationTests.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public Data dereference(final URIReference ref, XMLCryptoContext ctx)
throws URIReferenceException {
    String uri = ref.getURI();
    if (uri.equals(STYLESHEET) || uri.equals(STYLESHEET_B64)) {
        try {
            FileInputStream fis = new FileInputStream(new File
                (DATA_DIR, uri.substring(uri.lastIndexOf('/'))));
            return new OctetStreamData(fis,ref.getURI(),ref.getType());
        } catch (Exception e) { throw new URIReferenceException(e); }
    }

    // fallback on builtin deref
    return defaultUd.dereference(ref, ctx);
}
 
Example #12
Source File: ErrorHandlerPermissions.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Data dereference(final URIReference ref, XMLCryptoContext ctx)
        throws URIReferenceException {
    // return static content
    return new OctetStreamData(new ByteArrayInputStream(
            "<test>test</test>".getBytes()), ref.getURI(),
            ref.getType());
}
 
Example #13
Source File: GenerationTests.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public Data dereference(final URIReference ref, XMLCryptoContext ctx)
throws URIReferenceException {
    String uri = ref.getURI();
    if (uri.equals(STYLESHEET) || uri.equals(STYLESHEET_B64)) {
        try {
            FileInputStream fis = new FileInputStream(new File
                (DATA_DIR, uri.substring(uri.lastIndexOf('/'))));
            return new OctetStreamData(fis,ref.getURI(),ref.getType());
        } catch (Exception e) { throw new URIReferenceException(e); }
    }

    // fallback on builtin deref
    return defaultUd.dereference(ref, ctx);
}
 
Example #14
Source File: ValidationTests.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public Data dereference(final URIReference ref, XMLCryptoContext ctx)
throws URIReferenceException {
    String uri = ref.getURI();
    if (uri.equals(STYLESHEET) || uri.equals(STYLESHEET_B64)) {
        try {
            FileInputStream fis = new FileInputStream(new File
                (DATA_DIR, uri.substring(uri.lastIndexOf('/'))));
            return new OctetStreamData(fis,ref.getURI(),ref.getType());
        } catch (Exception e) { throw new URIReferenceException(e); }
    }

    // fallback on builtin deref
    return defaultUd.dereference(ref, ctx);
}
 
Example #15
Source File: GenerationTests.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public Data dereference(final URIReference ref, XMLCryptoContext ctx)
throws URIReferenceException {
    String uri = ref.getURI();
    if (uri.equals(STYLESHEET) || uri.equals(STYLESHEET_B64)) {
        try {
            FileInputStream fis = new FileInputStream(new File
                (DATA_DIR, uri.substring(uri.lastIndexOf('/'))));
            return new OctetStreamData(fis,ref.getURI(),ref.getType());
        } catch (Exception e) { throw new URIReferenceException(e); }
    }

    // fallback on builtin deref
    return defaultUd.dereference(ref, ctx);
}
 
Example #16
Source File: ErrorHandlerPermissions.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Data dereference(final URIReference ref, XMLCryptoContext ctx)
        throws URIReferenceException {
    // return static content
    return new OctetStreamData(new ByteArrayInputStream(
            "<test>test</test>".getBytes()), ref.getURI(),
            ref.getType());
}
 
Example #17
Source File: ValidationTests.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public Data dereference(final URIReference ref, XMLCryptoContext ctx)
throws URIReferenceException {
    String uri = ref.getURI();
    if (uri.equals(STYLESHEET) || uri.equals(STYLESHEET_B64)) {
        try {
            FileInputStream fis = new FileInputStream(new File
                (DATA_DIR, uri.substring(uri.lastIndexOf('/'))));
            return new OctetStreamData(fis,ref.getURI(),ref.getType());
        } catch (Exception e) { throw new URIReferenceException(e); }
    }

    // fallback on builtin deref
    return defaultUd.dereference(ref, ctx);
}
 
Example #18
Source File: ValidationTests.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public Data dereference(final URIReference ref, XMLCryptoContext ctx)
throws URIReferenceException {
    String uri = ref.getURI();
    if (uri.equals(STYLESHEET) || uri.equals(STYLESHEET_B64)) {
        try {
            FileInputStream fis = new FileInputStream(new File
                (DATA_DIR, uri.substring(uri.lastIndexOf('/'))));
            return new OctetStreamData(fis,ref.getURI(),ref.getType());
        } catch (Exception e) { throw new URIReferenceException(e); }
    }

    // fallback on builtin deref
    return defaultUd.dereference(ref, ctx);
}
 
Example #19
Source File: ErrorHandlerPermissions.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Data dereference(final URIReference ref, XMLCryptoContext ctx)
        throws URIReferenceException {
    // return static content
    return new OctetStreamData(new ByteArrayInputStream(
            "<test>test</test>".getBytes()), ref.getURI(),
            ref.getType());
}
 
Example #20
Source File: ValidationTests.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public Data dereference(final URIReference ref, XMLCryptoContext ctx)
throws URIReferenceException {
    String uri = ref.getURI();
    if (uri.equals(STYLESHEET) || uri.equals(STYLESHEET_B64)) {
        try {
            FileInputStream fis = new FileInputStream(new File
                (DATA_DIR, uri.substring(uri.lastIndexOf('/'))));
            return new OctetStreamData(fis,ref.getURI(),ref.getType());
        } catch (Exception e) { throw new URIReferenceException(e); }
    }

    // fallback on builtin deref
    return defaultUd.dereference(ref, ctx);
}
 
Example #21
Source File: ValidationTests.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public Data dereference(final URIReference ref, XMLCryptoContext ctx)
throws URIReferenceException {
    String uri = ref.getURI();
    if (uri.equals(STYLESHEET) || uri.equals(STYLESHEET_B64)) {
        try {
            FileInputStream fis = new FileInputStream(new File
                (DATA_DIR, uri.substring(uri.lastIndexOf('/'))));
            return new OctetStreamData(fis,ref.getURI(),ref.getType());
        } catch (Exception e) { throw new URIReferenceException(e); }
    }

    // fallback on builtin deref
    return defaultUd.dereference(ref, ctx);
}
 
Example #22
Source File: SagaInstanceRepositoryJdbc.java    From light-saga-4j with Apache License 2.0 4 votes vote down vote up
@Override
public <Data> SagaInstanceData<Data> findWithData(String sagaType, String sagaId) {
  SagaInstance sagaInstance = find(sagaType, sagaId);
  Data sagaData = SagaDataSerde.deserializeSagaData(sagaInstance.getSerializedSagaData());
  return new SagaInstanceData<>(sagaInstance, sagaData);
}
 
Example #23
Source File: Transform.java    From openjdk-8-source with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Transforms the specified data using the underlying transform algorithm.
 *
 * @param data the data to be transformed
 * @param context the <code>XMLCryptoContext</code> containing
 *    additional context (may be <code>null</code> if not applicable)
 * @return the transformed data
 * @throws NullPointerException if <code>data</code> is <code>null</code>
 * @throws TransformException if an error occurs while executing the
 *    transform
 */
public abstract Data transform(Data data, XMLCryptoContext context)
    throws TransformException;
 
Example #24
Source File: Reference.java    From jdk8u-jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns the dereferenced data, if
 * <a href="XMLSignContext.html#Supported Properties">reference caching</a>
 * is enabled. This is the result of dereferencing the URI of this
 * reference during a validation or generation operation.
 *
 * @return the dereferenced data, or <code>null</code> if reference
 *    caching is not enabled or this reference has not been generated or
 *    validated
 */
Data getDereferencedData();
 
Example #25
Source File: RetrievalMethod.java    From openjdk-8-source with GNU General Public License v2.0 2 votes vote down vote up
/**
* Dereferences the <code>KeyInfo</code> information referenced by this
* <code>RetrievalMethod</code> and applies the specified
* <code>Transform</code>s.
*
* @param context an <code>XMLCryptoContext</code> that may contain
*    additional useful information for dereferencing the URI. The
*    context's <code>baseURI</code> and <code>dereferencer</code>
*    parameters (if specified) are used to resolve and dereference this
*    <code>RetrievalMethod</code>
* @return a <code>Data</code> object representing the raw contents of the
*    <code>KeyInfo</code> information referenced by this
*    <code>RetrievalMethod</code>. It is the caller's responsibility to
*    convert the returned data to an appropriate
*    <code>KeyInfo</code> object.
* @throws NullPointerException if <code>context</code> is <code>null</code>
* @throws URIReferenceException if there is an error while dereferencing
*/
Data dereference(XMLCryptoContext context) throws URIReferenceException;
 
Example #26
Source File: XMLSignatureFactory.java    From openjdk-jdk9 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Creates a <code>Reference</code> with the specified parameters.
 *
 * <p>This method is useful when a list of transforms have already been
 * applied to the <code>Reference</code>. See for example,
 * the
 * <a href="http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=dss">
 * OASIS-DSS (Digital Signature Services)</a> specification.
 *
 * <p>When an <code>XMLSignature</code> containing this reference is
 * generated, the specified <code>transforms</code> (if non-null) are
 * applied to the specified <code>result</code>. The
 * <code>Transforms</code> element of the resulting <code>Reference</code>
 * element is set to the concatenation of the
 * <code>appliedTransforms</code> and <code>transforms</code>.
 *
 * @param uri the reference URI (may be <code>null</code>)
 * @param dm the digest method
 * @param appliedTransforms a list of {@link Transform}s that have
 *    already been applied. The list is defensively
 *    copied to protect against subsequent modification. The list must
 *    contain at least one entry.
 * @param result the result of processing the sequence of
 *    <code>appliedTransforms</code>
 * @param transforms a list of {@link Transform}s that are to be applied
 *    when generating the signature. The list is defensively copied to
 *    protect against subsequent modification. May be <code>null</code>
 *    or empty.
 * @param type the reference type, as a URI (may be <code>null</code>)
 * @param id the reference ID (may be <code>null</code>)
 * @return a <code>Reference</code>
 * @throws ClassCastException if any of the transforms (in either list)
 *    are not of type <code>Transform</code>
 * @throws IllegalArgumentException if <code>uri</code> is not RFC 2396
 *    compliant or <code>appliedTransforms</code> is empty
 * @throws NullPointerException if <code>dm</code>,
 *    <code>appliedTransforms</code> or <code>result</code> is
 *    <code>null</code>
 */
public abstract Reference newReference(String uri, DigestMethod dm,
    List<? extends Transform> appliedTransforms, Data result,
    List<? extends Transform> transforms, String type, String id);
 
Example #27
Source File: XMLSignatureFactory.java    From openjdk-8-source with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Creates a <code>Reference</code> with the specified parameters.
 *
 * <p>This method is useful when a list of transforms have already been
 * applied to the <code>Reference</code>. See for example,
 * the
 * <a href="http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=dss">
 * OASIS-DSS (Digital Signature Services)</a> specification.
 *
 * <p>When an <code>XMLSignature</code> containing this reference is
 * generated, the specified <code>transforms</code> (if non-null) are
 * applied to the specified <code>result</code>. The
 * <code>Transforms</code> element of the resulting <code>Reference</code>
 * element is set to the concatenation of the
 * <code>appliedTransforms</code> and <code>transforms</code>.
 *
 * @param uri the reference URI (may be <code>null</code>)
 * @param dm the digest method
 * @param appliedTransforms a list of {@link Transform}s that have
 *    already been applied. The list is defensively
 *    copied to protect against subsequent modification. The list must
 *    contain at least one entry.
 * @param result the result of processing the sequence of
 *    <code>appliedTransforms</code>
 * @param transforms a list of {@link Transform}s that are to be applied
 *    when generating the signature. The list is defensively copied to
 *    protect against subsequent modification. May be <code>null</code>
 *    or empty.
 * @param type the reference type, as a URI (may be <code>null</code>)
 * @param id the reference ID (may be <code>null</code>)
 * @return a <code>Reference</code>
 * @throws ClassCastException if any of the transforms (in either list)
 *    are not of type <code>Transform</code>
 * @throws IllegalArgumentException if <code>uri</code> is not RFC 2396
 *    compliant or <code>appliedTransforms</code> is empty
 * @throws NullPointerException if <code>dm</code>,
 *    <code>appliedTransforms</code> or <code>result</code> is
 *    <code>null</code>
 */
@SuppressWarnings("rawtypes")
public abstract Reference newReference(String uri, DigestMethod dm,
    List appliedTransforms, Data result, List transforms, String type,
    String id);
 
Example #28
Source File: Reference.java    From openjdk-8-source with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns the dereferenced data, if
 * <a href="XMLSignContext.html#Supported Properties">reference caching</a>
 * is enabled. This is the result of dereferencing the URI of this
 * reference during a validation or generation operation.
 *
 * @return the dereferenced data, or <code>null</code> if reference
 *    caching is not enabled or this reference has not been generated or
 *    validated
 */
Data getDereferencedData();
 
Example #29
Source File: Reference.java    From openjdk-jdk9 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns the dereferenced data, if
 * <a href="XMLSignContext.html#Supported%20Properties">reference caching</a>
 * is enabled. This is the result of dereferencing the URI of this
 * reference during a validation or generation operation.
 *
 * @return the dereferenced data, or <code>null</code> if reference
 *    caching is not enabled or this reference has not been generated or
 *    validated
 */
Data getDereferencedData();
 
Example #30
Source File: Transform.java    From openjdk-jdk9 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Transforms the specified data using the underlying transform algorithm.
 * If the output of this transform is an <code>OctetStreamData</code>, then
 * this method returns <code>null</code> and the bytes are written to the
 * specified <code>OutputStream</code>. Otherwise, the
 * <code>OutputStream</code> is ignored and the method behaves as if
 * {@link #transform(Data, XMLCryptoContext)} were invoked.
 *
 * @param data the data to be transformed
 * @param context the <code>XMLCryptoContext</code> containing
 *    additional context (may be <code>null</code> if not applicable)
 * @param os the <code>OutputStream</code> that should be used to write
 *    the transformed data to
 * @return the transformed data (or <code>null</code> if the data was
 *    written to the <code>OutputStream</code> parameter)
 * @throws NullPointerException if <code>data</code> or <code>os</code>
 *    is <code>null</code>
 * @throws TransformException if an error occurs while executing the
 *    transform
 */
public abstract Data transform
    (Data data, XMLCryptoContext context, OutputStream os)
    throws TransformException;