Skip to content
Related Articles

Related Articles

javax.xml.crypto Package in Java

View Discussion
Improve Article
Save Article
Like Article
  • Difficulty Level : Easy
  • 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
Module Graph

 

  • 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:


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!