How to list the available algorithms ?

Hi,
I would like to get all the available algorithms so that the user can choose the one he wants.
Is it possible to write a generic function that can encryt/decrypt a file with an algorithm as parameter
Because I've got the following problem : I use this code to list the available algorithms :
public static String[] getCryptoImpls(String serviceType) {       
        Set result = new HashSet();                
        Provider[] providers = Security.getProviders();
        for (int i=0; i<providers.length; i++) {           
            Set keys = providers[ i].keySet();
            for (Iterator it=keys.iterator(); it.hasNext(); ) {
                String key = (String)it.next();
                key = key.split(" ")[0];   
                if (key.startsWith(serviceType+".")) {
                    result.add(key.substring(serviceType.length()+1));
                } else if (key.startsWith("Alg.Alias."+serviceType+".")) {                   
                    result.add(key.substring(serviceType.length()+11));
        return (String[])result.toArray(new String[result.size()]);
    }    I call it as : getCryptoImpls("Cipher");
But some elements of the list are not available !
Other problem :
I encrypt/decrypt files using a password, and when I use different algorithms when encrypting and
decrypting, it works ! Strange ...
I create a key like this :
SecretKey key = SecretKeyFactory.getInstance(algo).generateSecret(keySpec);here is the whole code for you to understand better :
    /*  CLASSE                  : CryptoUtils                                 */
    /*  PACKAGE                 : crypto.utils                                */   
    /*  AUTEUR                  : Guillaume YVON                              */
    /*  CREATION                : 15-07-2005                                  */
    /*  DERNIERE MODIFICATION   : 17-07-2005                                  */
    /*  DESCRIPTION             : gestion du cryptage / d�cryptage            */
package crypto.utils;
import crypto.component.*;
import java.io.*;
import java.util.*;
import java.security.*;
import javax.crypto.*;
import javax.crypto.spec.*;
import java.security.spec.*;
public class CryptoUtils {   
    public static final int ENCRYPT_MODE = 1;
    public static final int DECRYPT_MODE = 2;
    /* ----- D�claration de variables ----- */
    private static Cipher ecipher;
    private static Cipher dcipher;      
    /* Cr�ation d'un vecteur d'initialisation de 8 octets */
    private static byte[] salt = {
        (byte)0xA9, (byte)0x9B, (byte)0xC8, (byte)0x32,
        (byte)0x56, (byte)0x35, (byte)0xE3, (byte)0x03
    /* Compteur pour l'it�ration */
    private static int iterationCount = 19;
    /* Buffer utilis� pour transporter les octets entre les flux */
    private static byte[] buf = new byte[1024];
    /*            PROCEDURE D'INITIALISATION DES CLES DE CRYPTAGE             */
    /* PARAMETRES D'ENTREE                                                    */
    /*      - password => mot de passe pour le cryptage : String              */
    /* PARAMETRES DE SORTIE                                                   */
    /*      - aucun                                                           */
    private static void init(String password,String algo) {
        try {
            /* G�n�ration de la cl� de cryptage � partir du mot de passe */
            KeySpec keySpec = new PBEKeySpec(password.toCharArray(), salt, iterationCount);            
            SecretKey key = SecretKeyFactory.getInstance(algo).generateSecret(keySpec);
            ecipher = Cipher.getInstance(key.getAlgorithm());
            dcipher = Cipher.getInstance(key.getAlgorithm());
            /* Pr�paration des param�tres pour les ciphers */
            AlgorithmParameterSpec paramSpec = new PBEParameterSpec(salt, iterationCount);
            /* Cr�ation des ciphers */
            ecipher.init(Cipher.ENCRYPT_MODE, key, paramSpec);
            dcipher.init(Cipher.DECRYPT_MODE, key, paramSpec);
        } catch (Exception e){ System.err.println(e); }
    /*                   PROCEDURE DE CRYPTAGE / DECRYPTAGE                   */
    /* PARAMETRES D'ENTREE                                                    */
    /*      - mode        => mode de cryptage/decryptage : int                */
    /*      - in          => flux d'entr�e (lecture) : InputStream            */
    /*      - out         => flux de sortie (�criture) : OutputStream         */
    /*      - srcSize     => taille du fichier source : long                  */
    /*      - progressBar => barre de progression                             */
    /* PARAMETRES DE SORTIE                                                   */
    /*      - aucun                                                           */
    private static void crypt(int mode, InputStream in, OutputStream out, long srcSize,
JProgressBarWindow progressBar){
        try {           
            if(mode == ENCRYPT_MODE){
                /* Les octets �crits dans out seront crypt�s */
                out = new CipherOutputStream(out, ecipher);
            }else if(mode == DECRYPT_MODE){
                /* Les octets lus dans in seront d�crypt�s */           
                in = new CipherInputStream(in, dcipher);
            /* Lit dans le texte clair les octets et �crit dans out pour le cryptage */
            int sum = 0;
            int numRead = 0;           
            while ((numRead = in.read(buf)) >= 0) {               
                out.write(buf, 0, numRead);
                sum += numRead;
                Float percent = sum / (new Float(srcSize)) * 100;
                if(progressBar!=null) progressBar.setValue(percent.intValue());               
            out.close();
        } catch (java.io.IOException e) { System.out.println(e); }
    /*             PROCEDURE DE LANCEMENT DU CRYPTAGE/DECRYPTAGE              */
    /* PARAMETRES D'ENTREE                                                    */
    /*      - mode        => mode de cryptage/decryptage : int                */
    /*      - algo        => algorythme � utiliser : String                   */
    /*      - srcFile     => flux d'entr�e (lecture) : String                 */
    /*      - tgtFile     => flux de sortie (�criture) : String               */
    /*      - password    => taille du fichier source : String                */
    /*      - progressBar => barre de progression : JProgressBarWindow        */
    /*      - text        => texte � afficher : String                        */
    /* PARAMETRES DE SORTIE                                                   */
    /*      - aucun                                                           */
    public static void launch(int mode,String algo,String srcFile,String tgtFile,String password,
                                JProgressBarWindow progressBar,String text){
        try {           
            init(password,algo);                                  
            if(progressBar!=null && text!=null) progressBar.setLabelText(text);
            crypt(mode,new FileInputStream(srcFile),new
FileOutputStream(tgtFile),FileUtils.getFileSize(srcFile), progressBar);                           
        } catch (Exception e) {}
    /*      FONCTION QUI RENVOIE LES IMPLEMENTATIONS DISPONIBLES POUR         */
    /*                          UN TYPE DE SERVICE                            */
    /* PARAMETRES D'ENTREE                                                    */
    /*      - serviceType => nom du service                                   */   
    /* PARAMETRES DE SORTIE                                                   */
    /*      - liste des impl�mentations : String[]                            */
    public static String[] getCryptoImpls(String serviceType) {       
        Set result = new HashSet();                
        Provider[] providers = Security.getProviders();
        for (int i=0; i<providers.length; i++) {           
            Set keys = providers[ i].keySet();
            for (Iterator it=keys.iterator(); it.hasNext(); ) {
                String key = (String)it.next();
                key = key.split(" ")[0];   
                if (key.startsWith(serviceType+".")) {
                    result.add(key.substring(serviceType.length()+1));
                } else if (key.startsWith("Alg.Alias."+serviceType+".")) {                   
                    result.add(key.substring(serviceType.length()+11));
        return (String[])result.toArray(new String[result.size()]);
    /*     FONCTION QUI RENVOIE LA LISTE DES TYPES DE SERVICE DISPONIBLES     */   
    /* PARAMETRES D'ENTREE                                                    */
    /*      - aucun                                                           */   
    /* PARAMETRES DE SORTIE                                                   */
    /*      - liste des services : String[]                                   */
    public static String[] getServiceTypes() {
        Set result = new HashSet();           
        Provider[] providers = Security.getProviders();
        for (int i=0; i<providers.length; i++) {           
            Set keys = providers[ i].keySet();
            for (Iterator it=keys.iterator(); it.hasNext(); ) {
                String key = (String)it.next();
                key = key.split(" ")[0];   
                if (key.startsWith("Alg.Alias.")) {                   
                    key = key.substring(10);
                int ix = key.indexOf('.');
                result.add(key.substring(0, ix));
        return (String[])result.toArray(new String[result.size()]);
}Any tip is welcome !
(sorry for the french comments...)

From 11.1 onwards, the below two views are available to identify the jar files loaded into the Database.
JAVAJAR$
JAVAJAROBJECTS$
By querying the JAVAJAR$ view you can know information about the JAR files loaded into the Database and using JAVAJAROBJECTS$ view you can find all the java objects associated with the given JAR file.
These views are populated everytime you use LOADJAVA with "-jarsasdbobjects" option to load your custom java classes.
But unfortunately this feature is available only from 11.1 onwards and there is no clear workaround for above in 10.2 or earlier.

Similar Messages

  • How to list the JAR files loaded into the Oracle Database ?

    How to list the JAR files loaded into the Oracle Database ?

    From 11.1 onwards, the below two views are available to identify the jar files loaded into the Database.
    JAVAJAR$
    JAVAJAROBJECTS$
    By querying the JAVAJAR$ view you can know information about the JAR files loaded into the Database and using JAVAJAROBJECTS$ view you can find all the java objects associated with the given JAR file.
    These views are populated everytime you use LOADJAVA with "-jarsasdbobjects" option to load your custom java classes.
    But unfortunately this feature is available only from 11.1 onwards and there is no clear workaround for above in 10.2 or earlier.

  • How to list the abap programs order by updated date in ECD

    Hi experts,
    how to list the abap programs order by updated date in ECD?
    thanks.

    I wrote a custom program for displaying Z* development work into an ALV report. 2500 character limit prevents me from posting, message me your email and I'll send you source code.
    Edited by: Brad Gorlicki on Feb 18, 2010 11:25 PM

  • How to list the active savepoints in a session?

    How to list the active savepoints in a session?

    SR 3-4535479801: How to list the active savepoints in a session?
    Oracle Support - September 19, 2011 7:12:50 AM GMT-07:00 [ODM Answer]
    === ODM Answer ===
    Hello,
    That is the only way and it is also described in:
    How To Find Out The Savepoint For Current Process (Doc ID 108611.1)
    One thing to be aware in lower version is the dump if no savepoints are declared:
    ALTER SESSION SET EVENTS 'IMMEDIATE TRACE NAME SAVEPOINTS LEVEL 1' Raises ORA-03113/ORA-07445[SIGSEGV]/[STRLEN] Errors (Doc ID 342484.1)
    Best regards,
    George
    Oracle Support Database TEAM
    Oracle Support - September 19, 2011 6:36:39 AM GMT-07:00 [ODM Question]
    === ODM Question ===
    How to list the active savepoints in a session?
    Is there another way than the following as referenced in the Oracle forums: Re: How to list the active savepoints in a session? ?
    "alter session set events 'immediate trace name savepoints level 1';"
    A trace file is generated in the user_dump_directory.
    - September 17, 2011 5:12:53 PM GMT-07:00 [Customer Problem Description]
    Problem Description: How to list the active savepoints in a session?
    Is there another way than
    "alter session set events 'immediate trace name savepoints level 1';"
    A trace file is generated in the user_dump_directory.
    Re: How to list the active savepoints in a session?

  • How to list the contents of an OSX directory, and output to text file?

    hello there any hints with any known program that does following
    I have recorded my music directory to DVD and now i would like to make an .txt file what the dvd contains...cos its way of hand to write all 100xx files by hand...
    How to list the contents of an OSX directory, and output to text file?
    any prog that does that? any hints?
    best regards

    This script makes a hierarchical file listing all files in a folder and subfolder:
    Click here to launch Script Editor.
    choose folder with prompt "Choose a folder to process..." returning theFolder
    set theName to name of (info for theFolder)
    set thepath to quoted form of POSIX path of theFolder
    set currentIndex to theFolder as string
    do shell script "ls -R " & thepath returning theDir
    set theDirList to every paragraph of theDir
    set newList to {"Contents of folder \"" & theName & "\"" & return & thepath & return & return}
    set theFilePrefix to ""
    repeat with i from 1 to count of theDirList
    set theLine to item i of theDirList
    set my text item delimiters to "/"
    set theMarker to count of text items of thepath
    set theCount to count of text items of theLine
    set currentFolder to text item -1 of theLine
    set theFolderPrefix to ""
    if theCount is greater than theMarker then
    set theNestIndex to theCount - theMarker
    set theTally to -1
    set theFilePrefix to ""
    set theSuffix to ""
    repeat theNestIndex times
    set theFolderPrefix to theFolderPrefix & tab
    set theFilePrefix to theFilePrefix & tab
    if theTally is -1 then
    set theSuffix to text item theTally of theLine & theSuffix
    else
    set theSuffix to text item theTally of theLine & ":" & theSuffix
    end if
    set currentIndex to "" & theFolder & theSuffix
    set theTally to theTally - 1
    end repeat
    end if
    set my text item delimiters to ""
    if theLine is not "" then
    if word 1 of theLine is "Volumes" then
    set end of newList to theFolderPrefix & "Folder: > " & currentFolder & return
    else
    try
    if not folder of (info for alias (currentIndex & theLine & ":")) then
    set end of newList to theFilePrefix & tab & tab & tab & "> " & theLine & return
    end if
    end try
    end if
    end if
    end repeat
    open for access file ((path to desktop as string) & "Contents of folder- " & theName & ".txt") ¬
    with write permission returning theFile
    write (newList as string) to theFile
    close access theFile

  • What is the transanction code to list the available transanction codes

    what is the transanction code to list the available transanction codes

    Hi,
    Use transaction SE93. This will show all transactions in SAP and you can test them with this tran too.
    Regards
    Wayne

  • How to check the availability of a SCS-Instance

    Hi.
    We want to use HP serviceguard for our HA solution - but we do not want to pay so much money for the SAP serviceguard extensions. So we do it ourselves...
    My question: how to check the availability of the SCS-Instance on regular basis on os level?
    - is it enough to check the enqueue and message server process? I don't think so :o)
    - is it enough to check the latest entry of this file?
    /usr/sap/<SID>/SCS<SYSNR>/work/available.log
    some typical entry of this file looks like these:
    Unavailable 30.04.2009 17:03:07 - 04.05.2009 11:32:33
    Available   04.05.2009 11:33:33 - 05.05.2009 17:33:05
    Available   05.05.2009 17:35:36 - 05.05.2009 17:35:36
    Available   05.05.2009 17:37:51 - 06.05.2009 08:49:11
    Other ideas?
    Thanks for your help!
    Martin

    Hi,
    what type of script you want to run at OS level, u can check the status in MMC itself if you are using windows or u can check the status in index.html informaiton page or u can use JCMON at OS level to check the status.
    -Srini

  • How to find the available parameters in Framework Page

    Hi All,
    I am new to OA Framework need some help. I need to find out the list of parameters for a Framework page. Once I know the available parameter then I can pass the value so that page rendering will be based on the parameter value.
    How to know the list of parameters. Are they available in a Table or XML file.
    Thanks for your help.

    Sorry I am not clear earlier. Here is my requirement:
    I am implementing iRecruitment product at a client site. Customer want to upload the available jobs on external site like (Dice.com). When a job seeker clicks on the available job 'Apply now' link the control is coming to iRecruitment main page but that particular job information is not displayed
    But the customer requirement is the URL attached to external job site should also contain the job id so that particular job information will be displayed when the control comes to iRecruitment product.
    So my idea is to find out if this job id parameter existed in the given page. If it existed then I can add the same to the URL in the browser page.
    Thanks

  • [Solved]How to list groups available

    I added my own user to my Arch setup. How would I get a list of available groups so I could add my user to them?
    Last edited by jordanwb (2008-09-08 02:01:18)

    Misfit138 wrote:
    kensai wrote:edit "/etc/group", add your username in front of the group you want to be in.
    hehe
    The 'Slackware Way'...
    Old habits, hard to break. Let me install Slackware on Virtualbox, I miss it.
    Last edited by kensai (2008-09-08 02:17:40)

  • How to list all available tables for user "karl"

    How can I list all available tables (=table names) for user "karl"?
    Nice to have would be if (after each table name in another column of each row) the number of data rows in this table can be listed similar to:
    TABLE NUM ROWS
    TESTA 12
    TESTB 3455
    ANOTHERTAB 234
    How can I do this?

    from Laurent Schneider
    http://laurentschneider.com/wordpress/2007/04/how-do-i-store-the-counts-of-all-tables.html
    SQL> select
      2    table_name,
      3    to_number(
      4      extractvalue(
      5        xmltype(
      6 dbms_xmlgen.getxml('select count(*) c from '||table_name))
      7        ,'/ROWSET/ROW/C')) count
      8  from user_tables;
    TABLE_NAME                      COUNT
    DEPT                                4
    EMP                                14
    BONUS                               0
    SALGRADE                            5

  • How to list devices available ?

    Hello all,
    I am new on the NI forum and I recently followed Labview training (Basic 1 & 2).
    I would like to know how to get the list of available devices and the type of them.
    Ideally I would like to have an array of that form :
    Device Name          Device Type
    Dev1                       NI PCI 4472
    Dev2                       NI PCI 6731
    Is there a way to do that with Labview ?
    Thank you for your help.
    Regards,
    Olivier Schevin

    I use the node:
    Device Names Property
    Short Name: DevNames
    Property of DAQmx System
    Indicates an array that contains the names of all devices installed in the system.
    This returns all device names without making an assumption about naming conventions such as Dev1 to Dev6. daqMx allows for naming the device with meaningful names through MAX.  I would encourage using daqMx, I found it a large learning curve over traditional DAQ but was well worth the time.  I would also assume with DaqMx there will be a phase out of coding using traditional drivers over the next several years (I could be wrong about this) .
    Paul
    Paul Falkenstein
    Coleman Technologies Inc.
    CLA, CPI, AIA-Vision
    Labview 4.0- 2013, RT, Vision, FPGA

  • How to list the name of recipient in Sent mail folder

    In the Gmail folder in Mail, is a Sent Mail folder. It lists FROM, SUBJECT, and DATE RECEIVED. My wife is the only account using the Mail appl. She would like to know how to have the name of the mail recipient listed, rather than her name as the sender since she already knows that info.
    Thanks.
    Jerry

    Jerry,
    That should happen automatically in Mail.
    Click the Gmail Sent folder. Where the names of the columns is displayed, there should be a dot next to the first column name. Right-click or control-click to get the menu. Click to check To. If you don't want to see From bring up the menu again and click it to uncheck.
    Done.
    -Wayne
    Message was edited by: ParentalUnit

  • How to list the top 10 largest files in the current working directory ?

    How can I list the top 10 largest files in the current working directory in Solaris ?

    execute below....to get the large files in order.. change the <FS>
    find /<FS> -type f -size +1024 -ls | awk '{print $11, $7}' | sort -rn +1 | awk '{print $1, $2/1024/1024 "MB"}' | /bin/more

  • How to set the Availability Status globaly

    Our database will placed in Restricted mode for a major upgrade. How can I set the Availability to a status of Unavailable(Redirect to URL) and add the URL to redirect to for all of our APEX applications without going in one by one?
    Edited by: Ed Siegle on Sep 29, 2009 5:46 PM

    Sorry, did NOT see the database going down message, since APEX runs in the database, it would be rather hard for it to redirect anywhere, however as the other poster said, if you are using mod_plsql you could have a redirect rule built..
    Thank you,
    Tony Miller
    Webster, TX

  • How to list the uploaded files on the server with a jsp page

    hi every body , iam stuck up with yhis problem . I a have use Random Access File to upload files to the web server , now i want the user can see the files he /she has uploaded or the the files uploaded by others . plese help me how to implement this .
    Message was edited by:
    joshiashutosh

    hi every body , iam stuck up with yhis problem . I a
    have use Random Access File to upload files to the
    web server ,Huh?
    now i want the user can see the files he
    /she has uploaded or the the files uploaded by others
    . plese help me how to implement this .So get the directory using the File class the files are in and list the files inside, showing the result to the user... how difficult would that be?

Maybe you are looking for