下面列出了怎么用javax.xml.crypto.Data的API类实例代码及写法,或者点击链接到github查看源代码。
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
@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());
}
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);
}
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);
}
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);
}
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);
}
@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());
}
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);
}
@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());
}
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);
}
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);
}
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);
}
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);
}
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);
}
@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);
}
/**
* 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);
/**
* 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();
/**
* 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;
/**
* 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;
/**
* 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;
/**
* 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);
/**
* 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);
/**
* 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;