Class SecurityUtil


  • public class SecurityUtil
    extends Object
    Utility class for the Encryption and Signature related methods
    Author:
    Ashutosh Shahi
    • Field Detail

      • log

        protected static final Logger log
    • Constructor Detail

      • SecurityUtil

        public SecurityUtil()
        Creates a new instance of SecurityUtil
    • Method Detail

      • generateSymmetricKey

        public static SecretKey generateSymmetricKey​(String algorithm)
                                              throws com.sun.xml.wss.XWSSecurityException
        Throws:
        com.sun.xml.wss.XWSSecurityException
      • getLengthFromAlgorithm

        public static int getLengthFromAlgorithm​(String algorithm)
                                          throws com.sun.xml.wss.XWSSecurityException
        Lookup method to get the Key Length based on algorithm TODO: Not complete yet, need to add more algorithms NOTE: This method should only be used for DerivedKeyTokenLengths
        Throws:
        com.sun.xml.wss.XWSSecurityException
      • generateUUID

        public static String generateUUID()
      • P_SHA1

        public static byte[] P_SHA1​(byte[] secret,
                                    byte[] seed)
                             throws Exception
        Throws:
        Exception
      • getSecretKeyAlgorithm

        public static String getSecretKeyAlgorithm​(String encryptionAlgo)
      • getWsuIdOrId

        public static String getWsuIdOrId​(Element elem)
                                   throws com.sun.xml.wss.XWSSecurityException
        Throws:
        com.sun.xml.wss.XWSSecurityException
      • initInferredIssuedTokenContext

        public static void initInferredIssuedTokenContext​(FilterProcessingContext wssContext,
                                                          com.sun.xml.ws.security.Token str,
                                                          Key returnKey)
                                                   throws com.sun.xml.wss.XWSSecurityException
        Throws:
        com.sun.xml.wss.XWSSecurityException
      • isEncryptedKey

        public static boolean isEncryptedKey​(jakarta.xml.soap.SOAPElement elem)
      • isBinarySecret

        public static boolean isBinarySecret​(jakarta.xml.soap.SOAPElement elem)
      • updateSamlVsKeyCache

        public static void updateSamlVsKeyCache​(com.sun.xml.ws.security.SecurityTokenReference str,
                                                FilterProcessingContext ctx,
                                                Key symKey)
      • updateSamlVsKeyCache

        public static void updateSamlVsKeyCache​(com.sun.xml.ws.security.secext10.SecurityTokenReferenceType str,
                                                FilterProcessingContext ctx,
                                                Key symKey)
      • loadFromContext

        public static URL loadFromContext​(String configFileName,
                                          Object context)
        Returns a URL pointing to the given config file. The file name is looked up as a resource from a ServletContext. May return null if the file can not be found.
        Parameters:
        configFileName - The name of the file resource
        context - A ServletContext object. May not be null.
      • loadFromClasspath

        public static URL loadFromClasspath​(String configFileName)
        Returns a URL pointing to the given config file. The file is looked up as a resource on the classpath. May return null if the file can not be found.
        Parameters:
        configFileName - the name of the file resource. May not be null.
      • convertSTRToElement

        public static Element convertSTRToElement​(Object strElem,
                                                  Document doc)
                                           throws com.sun.xml.wss.XWSSecurityException
        Throws:
        com.sun.xml.wss.XWSSecurityException
      • copySubject

        public static void copySubject​(Subject to,
                                       Subject from)
      • getSubject

        public static Subject getSubject​(Map context)
      • getSCT

        public static com.sun.xml.ws.security.SecurityContextToken getSCT​(com.sun.xml.ws.security.SecurityContextToken sct,
                                                                          com.sun.xml.ws.api.SOAPVersion version)
      • copy

        public static void copy​(Map p1,
                                Map p2)
      • loadSPIClass

        public static Object loadSPIClass​(URL url,
                                          String spiName)
      • toLong

        public static long toLong​(String lng)
                           throws com.sun.xml.wss.XWSSecurityException
        Throws:
        com.sun.xml.wss.XWSSecurityException
      • getKeyAlgo

        public static String getKeyAlgo​(String algo)