javax.xml.crypto Package in Java
Last Updated :
25 Mar, 2022
Common classes having the XML cryptography for the Package javax.xml.crypto. now this crypto package includes similar classes that are used to accessing XML cryptographic on its operations, such as creating an XML signature or encrypted XML data.
There are two types of javax.xml.crypto classes in this package that are KeySelector class, which allows developers to supply implementing that will locate and optionally validate keys using the information obtained in KeyInfo objects, and in URIDereferencer classes, which are giving permission to developers to generate and create uniquely their own self URI dereferencing implementations to under this useful Package javax.xml.crypto
This Package javax.xml.crypto creating base at the uniquely like XML mechanisms types that will be validating the XML generating its process that an ongoing mechanism process using internal methods to parsing and invoking the XML signatures and KeyInfo into structures as well, as on the JSR supports one implemented similar type like DOM. These XML Digital Signatures are obtaining implementation goals like sets of packages with Java SE supporting the DOM mechanisms through new module types similar as this example will be added in the future as JDOM
Module java.xml.crypto: Explaining the API of XML cryptographies
The Module Graph:
java.xml.crypto
--> java.xml
--> java.base
GeeksforGeeks
 - java.xml.crypto
- java.xml
- java.base
Uses of Package javax.xml.crypto Within this package javax.xml.cryptoÂ
- javax.xml.crypto: Package that use in javax.xml.crypto
- javax.xml.crypto: Common classes having XML cryptography
- javax.xml.crypto.dom: DOM-specified classes having the javax.xml.crypto package
- javax.xml.crypto.dsig: Classes for creating and verifying XML digital signatures
- javax.xml.crypto.dsig.dom: DOM-specified classes for the similar its javax.xml.crypto.dsig packages
- javax.xml.crypto.dsig.keyinfo: this Classes are for parsing and accessing the KeyInfo elements and structures
- javax.xml.crypto.dsig.spec: This Parameterised javax.xml.crypto.dsig.spec classes are commonly uses XML digital signatures
- javax.xml.crypto: It have Common similar classes for using XML cryptography
Interface Summary
- AlgorithmMethod: An abstraction of representing an algorithm declaring in the XML Security specifications on it
- Data: Having an abstraction representation of resulting in an implementing a URIReference or the input/output of its subsequent Transformations
- KeySelectorResult: The resultant has returned by the method KeySelector.select
- NodeSetData: This node has an abstracted representation of Data types that have occurred a node-set
- URIDereferencer: It is  implementing of URIReferences on it
- URIReference: It validates a data object via a path URI-Reference, as specified by the RFC-2396
- XMLCryptoContext: Accessing a set of common context data for XML cryptographic methods of operations performing on it
- XMLStructure: An abstract representation of an XML structure query from any namespaces
Class Summary
- KeySelector: The Key selector is having work as finding an accessing key and returning a key in it by using the information obtained in its KeyInfo objects
- KeySelector.Purpose: The objective of this KeySelector.Purpose key is that has goal to be selected within a selection
- OctetStreamData: A streaming of a Data types holding an octet-stream Data
Exception Summary
- KeySelectorException: This KeySelectorException is an exceptional condition that is thrown by a simple class KeySelector
- MarshalException: An exceptional condition that indicates towards during the phase of XML marshaling or unmarshalling process running
- NoSuchMechanismException: This NoSuchMechanismException exception is thrown by a particular XML mechanism is happening by accessing a requested but is not available in its running environment
- URIReferenceException: this URIReferenceException shows an exceptional condition thrown exception meanwhile there is a dereferencing in the URIReference
- XMLCryptoContext: Contains common context content data stored for XML cryptographic operations running it
- XMLStructure: A classification of an XML structure for Exception as from any namespace
Example:
Java
// Java Program to show Showing Syntax and use of Package
// javax.xml.crypto Via Classes, Interfaces And Exceptions
// Having URIReference and XMLCryptoContext
public MyServer(final URIReference abc,
XMLCryptoContext cde)
throws URIReferenceException
{
String str = abc.getURI();
if (str.equals(STYLESHEET)
|| str.equals(STYLESHEET_B64)) {
// Try block to check for exceptions
try {
// reading from file
FileInputStream fcs
= new FileInputStream(new File(
DATA_DIR,
str.substring(str.lastIndexOf('/'))));
return new OctetStreamData(fcs, abc.getURI(),
ref.getType());
// Display message only
System.out.println("Hello GFG Readers!");
}
// Catch block to handle exceptions
catch (Exception e) {
throw new URIReferenceException(e);
}
}
// Fallback on it
return defaultUd.dereference(abc, cde);
}
Output:

Similar Reads
Java.util Package in Java Java.util PackageIt contains the collections framework, legacy collection classes, event model, date and time facilities, internationalization, and miscellaneous utility classes (a string tokenizer, a random-number generator, and a bit array).Following are the Important Classes in Java.util package
4 min read
Java.io Package in Java Java.io Package in JavaThis package provides for system input and output through data streams, serialization and the file system. Unless otherwise noted, passing a null argument to a constructor or method in any class or interface in this package will cause a NullPointerException to be thrown. Follo
1 min read
Java.lang package in Java Java.lang package in JavaProvides classes that are fundamental to the design of the Java programming language. The most important classes are Object, which is the root of the class hierarchy, and Class, instances of which represent classes at run time. Following are the Important Classes in Java.lan
3 min read
Java.lang.Package Class in Java In Java, the package class was introduced in JDK 1.2 to encapsulate version data associated with a package. As the number of packages increases, knowing the version of the package has become important. This versioning information is retrieved and made available by the ClassLoader instance that loade
9 min read
JEP Package Tool in Java J package tool was introduced as an incubation tool in java 14. It remained an incubation tool till java 15. Â It packages java applications into platform-specific features. Basically, this tool converts our java source file into an executable file. In Windows, the executable file is of two types .ex
3 min read