Trying to generate secure rpc key pairs with java

I see a couple of different classes that will generate public private key pairs in various algorithms for me but it doesn't appear that I can supply a pass phrase to use with these.
I want to write java code that will create a NIS+ secureRPC key pair for me.
thanks.

See now this is a really good question. I don't have an answer, but I really like seeing these types of questions here

Similar Messages

  • Can a link 5 usb key paired with hp's wireless elite keyboard?

    Hi, I have a link 5 wireless mouse and a old hp's wireless elite keyboard.  I don't know if they both use bluetooth or one is bluetootha and the other 2.4GHz or not.  But can a link 5 usb key paired with a hp's version 1 wireless keyboard?  If not, how can I get a wireless usb key for my hp wireless eilte keyboard?

    Hello,
    A Link 5 USB mouse can be used with some devices and HP has listed them at the following link:
    HP Link-5technology liberates USB ports
    HP also introduced new PCaccessories with HP’s exclusive Link-5 technology. Link-5 allows users to connect up to fiveHP-compatible PC accessories with one receiver, freeing up valuableUSB ports.
    There are no drivers orsoftware to install. Users simply press the ”Connect” button on aLink-5 device to pair it with their PC. The wireless receiver then“remembers” all paired devices, making Link-5 accessories ideal forthose using a PC in multiple settings such as the home, office orother mobile locations.
    Link-5 delivers reliableconnectivity using 2.4-GHz wireless technology and has anintelligent sleep mode to ensure the longest possible battery life.The latest Link-5 accessories lineup includes:
    HP Wireless Mini Keyboard: Just the right mobile companion fora tablet or entertainment PC, this full-featured keyboard islightweight and ultra-small in size.
    HP Wireless Ultrathin Wireless Keyboard: Offering a stylishlook and feel, this keyboard is durable, full-featured and a greatvalue.
    HP Wireless Elite v2 Keyboard: Featuring a sleek, ultra-slimdesign, this keyboard offers superb performance and comfort.
    HP Wireless Optical Comfort Mouse: Offering a comfortable,secure grip for use in the right or left hand, this mouse featuresan optical sensor with adjustable sensitivity that works on mostsurfaces.
    HP Wireless Laser Comfort Mouse: Using a laser sensor withadjustable sensitivity, this mouse delivers optimal performance andworks on most surfaces.
    HP Wireless Mobile Mouse: Designed for users who are on the go,this mouse delivers reliable wireless connectivity at a greatvalue.
    It is only mention v2 not v1, so not sure if it will work. You should not be able to buy a key, because each device is sold with their specific usb receiver, so the answer is, you cannot get one, except if you buy  a new part.
    Thanks,
    I work for HP! Please remember to provide and if this helped click ON

  • Read "Qualified Range Key Generation" with Java API.

    Hi guru,
    I use MDM 5.5 SP6.
    In MDM Console I read Qualified Range Key Generation it in "ADMIN -> Remote Systems -> Qualified Range".
    I have to get "Qualified Range Key Generation" with Java API.
    It's possible?

    Hi Rocco,
    I am also thinking  of same scenario.I thought it is possible in Java Apis by calling the webservices for MDM.there is a service of "get key mapping" where we can pass this "Qualified key range" as  parameter.In MDM we have to define a look up table for that key ranges .We will access that table through JAVA API and then link it with the key mapping service .
    If u find any solution to apply this ,please share.
    thanks and regards
    Ank

  • How to generate key pair using java ?(its urgent)

    We r working on java card. For security purpose I want a Key pair.
    If anyone is able to uide me by giving me a small code or algorithm i am very thankful.
    Its an urgent !!!!
    Plz inform me if any relative information u r having.

    import java.security.KeyPairGenerator;
    import java.security.KeyPair;
    import java.security.PrivateKey;
    import java.security.PublicKey;
    import java.security.SecureRandom;
    import java.security.KeyFactory;
    import java.security.spec.PKCS8EncodedKeySpec;
    import java.security.spec.X509EncodedKeySpec;
    import java.io.FileOutputStream;
    import java.io.FileInputStream;
    public class ParClaves {
         public KeyPairGenerator keyPairGenerator;
         public KeyPair keyPair;
         public PrivateKey privateKey;
         public PublicKey publicKey;
         public String algoritmo = "DSA"; // DSA o RSA
         public String proveedor = null;
         public int keysize = 1024;
         public SecureRandom random = null;
         public void guardarClaves(String fichClavePublica, String fichClavePrivada) throws Exception {
              byte[] key = this.publicKey.getEncoded();
              FileOutputStream keyfos = new FileOutputStream(fichClavePublica);
              keyfos.write(key);
              keyfos.close();               
              key = this.privateKey.getEncoded();
              keyfos = new FileOutputStream(fichClavePrivada);
              keyfos.write(key);
              keyfos.close();               
         } // fin de guardarClaves
         public void guardarClaves(String fichClavePublica, String fichClavePrivada, KeyPair keyPair) throws Exception {
              byte[] key = keyPair.getPublic().getEncoded();
              FileOutputStream keyfos = new FileOutputStream(fichClavePublica);
              keyfos.write(key);
              keyfos.close();               
              key = keyPair.getPrivate().getEncoded();
              keyfos = new FileOutputStream(fichClavePrivada);
              keyfos.write(key);
              keyfos.close();               
         } // fin de guardarClaves     
         public KeyPair recuperarClaves(String fichClavePublica, String fichClavePrivada) throws Exception {
              return new KeyPair(recuperarClavePublica(fichClavePublica), recuperarClavePrivada(fichClavePrivada));
         } // fin de recuperarClaves
         public PublicKey recuperarClavePublica(String fichClavePublica) throws Exception {
    // PENDIENTE: seguramente, para que esto fuera v�lido, habr�a que proporcionar el Proveedor ?�
    // probar generando clavePublica con otro proveedor distinto de SUN
              FileInputStream fis = new FileInputStream(fichClavePublica);
              byte[] encKey = new byte[fis.available()];
              fis.read(encKey);
              fis.close();
              KeyFactory keyFactory = null;
              try {
                   keyFactory = KeyFactory.getInstance("DSA");
              } catch (Exception e) {
                   keyFactory = KeyFactory.getInstance("RSA");
              } // fin del try
              X509EncodedKeySpec pubKeySpecX509 = new X509EncodedKeySpec(encKey);
              PublicKey publicKey = keyFactory.generatePublic(pubKeySpecX509);
              return publicKey;
         } // fin de recuperarClavePublica
         public PrivateKey recuperarClavePrivada(String fichClavePrivada) throws Exception {
    // PENDIENTE: seguramente, para que esto fuera v�lido, habr�a que proporcionar el Proveedor ?�
    // probar generando clavePrivada con otro proveedor distinto de SUN
              FileInputStream fis = new FileInputStream(fichClavePrivada);
              byte[] encKey = new byte[fis.available()];
              fis.read(encKey);
              fis.close();
              KeyFactory keyFactory = null;
              try {
                   keyFactory = KeyFactory.getInstance("DSA");
              } catch (Exception e) {
                   keyFactory = KeyFactory.getInstance("RSA");
              } // fin del try
              PKCS8EncodedKeySpec privKeySpecPKCS8 = new PKCS8EncodedKeySpec(encKey);
              PrivateKey privateKey = keyFactory.generatePrivate(privKeySpecPKCS8);
              return privateKey;
         } // fin de recuperarClavePrivada
         public KeyPair generarClaves() throws Exception {
              if (this.proveedor == null) {
                   this.keyPairGenerator = KeyPairGenerator.getInstance(this.algoritmo);
                   this.proveedor = this.keyPairGenerator.getProvider().getName();
              } else {
                   this.keyPairGenerator = KeyPairGenerator.getInstance(this.algoritmo, this.proveedor);
              } // fin del if
              if (this.random == null) {
                   this.keyPairGenerator.initialize(this.keysize);
              } else {
                   this.keyPairGenerator.initialize(this.keysize, this.random);
              } // fin del if
              this.keyPair = this.keyPairGenerator.generateKeyPair();
              this.privateKey = this.keyPair.getPrivate();
              this.publicKey = this.keyPair.getPublic();
              return this.keyPair;
         } // fin de generarClaves
         public KeyPair generarClaves(SecureRandom random) throws Exception {
              this.random = random;
              return generarClaves();
         } // fin de generarClaves
         public KeyPair generarClaves(int keysize) throws Exception {
              this.keysize = keysize;
              return generarClaves();
         } // fin de generarClaves
         public KeyPair generarClaves(int keysize, SecureRandom random) throws Exception {
              this.keysize = keysize;
              this.random = random;          
              return generarClaves();
         } // fin de generarClaves
         public KeyPair generarClaves(String algoritmoOproveedor) throws Exception {
              decidir(algoritmoOproveedor);
              return generarClaves();
         } // fin de generarClaves
         public KeyPair generarClaves(String algoritmoOproveedor, SecureRandom random) throws Exception {
              decidir(algoritmoOproveedor);
              this.random = random;          
              return generarClaves();
         } // fin de generarClaves
         public KeyPair generarClaves(String algoritmoOproveedor, int keysize) throws Exception {
              decidir(algoritmoOproveedor);
              this.keysize = keysize;          
              return generarClaves();
         } // fin de generarClaves
         public KeyPair generarClaves(String algoritmoOproveedor, int keysize, SecureRandom random) throws Exception {
              decidir(algoritmoOproveedor);
              this.keysize = keysize;          
              this.random = random;                    
              return generarClaves();
         } // fin de generarClaves
         public KeyPair generarClaves(String algoritmo, String proveedor) throws Exception {
              this.algoritmo = algoritmo;          
              this.proveedor = proveedor;                    
              return generarClaves();
         } // fin de generarClaves
         public KeyPair generarClaves(String algoritmo, String proveedor, SecureRandom random) throws Exception {
              this.algoritmo = algoritmo;          
              this.proveedor = proveedor;
              this.random = random;                              
              return generarClaves();
         } // fin de generarClaves
         public KeyPair generarClaves(String algoritmo, String proveedor, int keysize) throws Exception {
              this.algoritmo = algoritmo;          
              this.proveedor = proveedor;
              this.keysize = keysize;                              
              return generarClaves();
         } // fin de generarClaves
         public KeyPair generarClaves(String algoritmo, String proveedor, int keysize, SecureRandom random) throws Exception {
              this.algoritmo = algoritmo;          
              this.proveedor = proveedor;
              this.keysize = keysize;
              this.random = random;          
              return generarClaves();
         } // fin de generarClaves
         public String getInformacion() {
              StringBuffer sb = new StringBuffer();
              sb.append("Algoritmo: " + this.algoritmo + "\n");
              sb.append("Proveedor: " + this.proveedor + "\n");
              sb.append("Keysize: " + this.keysize + "\n");
              return sb.toString();
         } // fin de getInformacion
         public boolean esAlgoritmoValido(String algoritmo) {
              try {
                   KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance(algoritmo);
                   return true;
              } catch (Exception e) {
                   return false;
              } // fin del try
         } // fin de esAlgoritmoValido
         private void decidir(String algoritmoOproveedor) {
              if (esAlgoritmoValido(algoritmoOproveedor)) {
                   this.algoritmo = algoritmoOproveedor;
              } else {
                   this.proveedor = algoritmoOproveedor;
              } // fin del if
         } // fin de decidir
    } // fin de ParClaves

  • How to indetify key pair in Java?

    Hello
    I need only to know if some private and public key generating one key pair.
    I don't want to try it through encrypt/decrypt process and checking data.
    Thanks

    I have some private key and some public key and I need to detect if private key belongs to some public key. It shouldn't be possible to get into such a state in the first place. Key pairs should be stored in such a way that they are always together, e.g. in a java.security.KeyStore or an HSM, most probably associated with a Certificate.
    If true, then I can encrypt data by one of them and correctly decrypt by second.You can encrypt with the public key and decrypt with the private key.
    If false ,I will got incorrect data after decryption.No you won't, you'll get an exception.

  • "bad database" trying to export cert key pair with pk12util on WS7

    I'm trying to export the self-signed cert pair from my web servers.
    root@sasbews21 # ls -al
    total 450
    drwx------   2 webservd webservd    1024 Apr 16 14:54 .
    drwxr-xr-x  11 root     root         512 Apr 16 14:53 ..
    -rw-------   1 webservd webservd   65536 Apr 21 13:46 cert8.db
    -rw-------   1 webservd webservd    1527 Apr  7 15:00 certmap.conf
    -rw-------   1 webservd webservd   14732 Apr  7 15:00 default-web.xml
    -rw-------   1 webservd webservd     400 Apr  7 15:00 default.acl
    -rw-------   1 webservd webservd   32768 Apr 21 13:46 key3.db
    -rw-------   1 webservd webservd     160 Apr  7 15:00 keyfile
    -rw-------   1 webservd webservd    1710 Apr  7 15:00 loadbalancer.xml
    -rw-------   1 webservd webservd    1582 Apr  7 15:00 loadbalancer.xml.bak
    -rw-------   1 webservd webservd    1284 Apr  7 15:00 loadbalancer.xml.example
    -rw-------   1 webservd webservd     466 Apr  7 15:00 login.conf
    -rw-------   1 webservd webservd     500 Apr  7 15:00 magnus.conf
    -rw-------   1 webservd webservd     150 Apr  7 15:00 magnus.conf.orig
    -rw-------   1 webservd webservd    9153 Apr  7 15:00 mime.types
    -rw-------   1 webservd webservd    2069 Apr  7 15:00 obj.conf
    -rw-------   1 webservd webservd    1436 Apr  7 15:00 obj.conf.orig
    -rw-------   1 webservd webservd    2141 Apr  7 15:00 sasbews21.to.dot.state.fl.us-obj.conf
    -rw-------   1 webservd webservd   32768 Apr  7 15:00 secmod.db
    -rw-------   1 webservd webservd    2887 Apr  7 15:00 server.policy
    -rw-------   1 webservd webservd    2788 Apr 16 14:53 server.xml
    -rw-------   1 webservd webservd    5292 Apr  7 15:00 sun-loadbalancer_1_0.dtd
    -rw-------   1 webservd webservd    7530 Apr  7 15:00 sun-loadbalancer_1_1.dtd
    -rw-------   1 webservd webservd    7745 Apr  7 15:00 sun-loadbalancer_1_2.dtd
    -rw-------   1 webservd webservd    5913 Mar 26 11:05 sunpasssecure.com.pem
    -rw-------   1 webservd webservd    4241 Mar 25 16:18 sunpasssecure.com.pfx
    -rw-------   1 webservd webservd    3896 Mar 26 11:14 sunpasssecure.com.pk12
    -rw-------   1 webservd webservd    3292 Mar 26 11:53 sunpasssecure.com.v2.pem
    -rw-------   1 webservd webservd    2328 Mar 26 14:25 sunpasssecure.com.v2.pk12
    root@sasbews21 # certutil -L -d .
    s1as                                                         CTu,u,u
    s1as                                                         CTu,u,u
    cert-sasbews21.to.dot.state.fl.us                            u,u,u
    root@sasbews21 # pk12util -o cert-sasbews21.to.dot.state.fl.us.pk12 -n -d .
    pk12util: function failed: security library: bad database.Thanks for any thoughts.
    Steve Maring

    to export the cert, you will need to provide the cert nick name for example
    for example,
    [sriramn@chilidev1]'config'>/sun/webserver7/bin/certutil -L -d .
    cert-chilidev1.red.iplanet.com u,u,u
    [sriramn@chilidev1]'config'>/sun/webserver7/bin/pk12util -o /tmp/tmp.expo -d . -n cert-chilidev1.red.iplanet.com
    Enter password for PKCS12 file:
    Re-enter password:
    pk12util: PKCS12 EXPORT SUCCESSFUL
    in your case,
    cd /sun/webserver7/https-sasbews21.to.dot.state.fl.us/config
    /sun/webserver7/bin/certutil -L -d .
    /sun/webserver7/bin/pk12util -o <filename> -n cert-sasbews21.to.dot.state.fl.us -d .

  • JOptionPane.showConfirmDialog requires two key strokes with Java SE 6.

    I have been using the following line of code:
    rc = JOptionPane.showConfirmDialog( comp, objects, "Warning",
    JOptionPane.YES_NO_OPTION,
    JOptionPane.INFORMATION_MESSAGE);
    with no problems with plug-in 1.4 and 1.5. Now with 1.6, when I choose Yes/No/Cancel, the first time I press the button nothing happens, the second time I press the button the action takes place.
    I have been searching for information on this and have not found any known issues (yet). Does anyone have any ideas?

    further investigation shows that this only happens when the component is a JComboBox. I found a new bug that seems to be the same issue:
    http://bugs.sun.com./bugdatabase/view_bug.do?bug_id=6817939
    When calling JOptionPane.showConfirmDialog from an ActionListener called by a JComboBox, there is 2 issues:
    * the focus is not given to the confirm dialog

  • Xrpcc modeler error when trying to generate stub classes from a WSDL

    I'm trying to generate JAX-RPC stub classes (both client and server side) from a WSDL in which one of the message parts references a complexType element defined in the <types> section of the WSDL. Here is my little WSDL document:
    <?xml version="1.0" encoding="UTF-8"?>
    <definitions name="Book_Def"
    targetNamespace="myTypes"
    xmlns:tns="myTypes"
    xmlns:xsd1="myTypes"
    xmlns="http://schemas.xmlsoap.org/wsdl/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
    <types>
    <xsd:schema targetNameSpace="myTypes"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <xsd:element name="Book" type="xsd1:BookType"/>
    <xsd:complexType name="BookType">
    <xsd:all>
    <xsd:element name="authors" type="xsd:string" maxOccurs="10"/>
    <xsd:element name="preface" type="xsd:string"/>
    <xsd:element name="price" type="xsd:float"/>
    </xsd:all>
    </xsd:complexType>
    </xsd:schema>
    </types>
    <message name="runMyPgm">
    <part name="book" type="xsd1:Book"/>
    </message>
    <message name="getPgmResponse">
    <part name="result" type="xsd:string"/>
    </message>
    <portType name="MyPgmIFPortType">
    <operation name="runMyPgm">
    <input message="tns:runMyPgm"/>
    <output message="tns:getPgmResponse"/>
    </operation>
    </portType>
    ... Binding stuff
    </port>
    </service>
    </definitions>
    I've tried many combinations of defining my complex type and input message and whenever I run xrpcc using this WSDL as input, I get a Error: Modeler error: invalid entity name: Book (in namespace "myTypes"). Sorry if this is a dumb question, but what am I doing wrong in my <types> or <message> definitions to cause this error? I've had some luck generating stubs when the part types are all simple types, but I've not had any luck with getting a <complexType> definition accepted by xrpcc. Thanks in advance for any help you can offer.

    Yes you can specify type mapping in configuration file and probably this will solve the problem, but I've never tested this approach. Perhaps I'm not advanced user. Actually the serializerFactory and deserializerFactory are a little vague for me:(

  • Generate Separate New Time Pair (not split)

    Hi All-
    US SAP_HCm 4.7
    I am trying to generate a separate time pair (in schema TM04) for overtime (M), while keeping the planned working time (S) time pair untouched. I am basically trying to make a copy of a time pair (i.e. hours) except for changing the processing type (S to M).
    Example:
    TIP Table - IN
    0800-1400 --- 8 hours -
    (S) Planned Working Time Pair
    Operation in Time
    Some Clever idea ... or concept
    TIP Table- OUT
    0800-1400 --- 8 hours -
    (S) Planned Working Time Pair
    0800-1400 --- 8 hours -
    (M) Overtime Time Pair
    I have tried using the operation GENTG in a PCR .. but it seems very limited. Is there any SAP Time gurus out there with a clever idea?
    Any help is much appreciated.
    Thanks
    B-

    I can generate time types but the problem is that time type will be a generic time type and will be applicable to all absence classes with operation VARST or OUTTP.  Until I have a time pair on a non working day and if that time pair is generated then it can be read using RTIPA OR PTIPA variables. 
    Otherise for every absence type it will generate 8 hours but I want 8 hours to be generated wtih PL and CL only.  If i give LOP or LWP then also system is generating 8 hours time type which is wrong.  So until I generate a time type for the off day i cannot read 2001 or TIME PAIR TABLE. 
    Kindly guide.

  • Generating a Primary Key WITHOUT using a Sequence Number

    Hi Everyone:
    I am trying to generate a primary key without using a sequence number or row count. What the user wants is the maximum value of the highest primary key already in the row set plus 1.
    For example, this is a Oracle Table (eg. named BatchSubmit) used to initiate batch job submission, and the primary key is an integer named "Runcard_Number". If there are 4 rows in this table and the Runcard_Numbers are 2, 6, 8 & 12, then the next generated Runcard_Number would be 13.
    I have looked throughout this forum and see how to generate numbers using a DBSequence, but the user does not want that. The numbers mean something to them, and they don't want them randomly assigned other than the max in the rowset plus 1. To do it in SQL it would be - select max(Runcard_Number) + 1 from BatchSubmit;
    I have been looking at using a hasnext loop and moving the maximum value to the new Runcard_Number, but I am very new to JHeadstart/JDev and I do not know where to put this. I am assuming the BatchSubmitImpl.java, but I'm not sure where to put it or which method to utilize
    I would appreciate any assistance.
    Mary
    U o Windsor

    Mary you're in luck, 'cause, I've been playing with the same thing, these days and found that..
    You can do that in two ways (that I know):
    - by calling a stored function that does max+1 (you can look it up in Dev's guide for Forms&4GLDevs 10g chapter 25.5 Invoking Stored Procedures and Functions)
    - by calling hardcoded or dinamicaly written statement, that does the same
    public Number callStatement(String stmt)
    Number id = new Number(0);
    Row idRow = getDBTransaction().createViewObjectFromQueryStmt(stmt).next();
    if(idRow != null)
    Object o = idRow.getAttribute(0);
    if(o != null)
    if(o instanceof Number)
    id = (Number)o;
    else
    throw new JboException("Conversion error!");
    return id;
    You should call it in
    protected void doDML(int operation, TransactionEvent transactionEvent)
    switch (operation)
    case DML_INSERT:
    // call here
    super.doDML(operation, transactionEvent);
    break;
    case DML_UPDATE:
    super.doDML(operation, transactionEvent);
    break;
    case DML_DELETE:
    super.doDML(operation, transactionEvent);
    break;
    Enjoy!
    S. Julijan

  • MacBook not pairing with Bluetooth Audio Sink Typhoon

    I did not have success trying to get my MacBook to pair with a Typhoon Bluetooth Audio Receiver Set (http://www.typhoon.de/en/art.php?p=1523&pv=3 ).
    The Typhoon device claims to be a A2DP-SNK (stereo audio sink) .
    My MacBook (10.4.8 up to date, with a Bluetooth-MightyMouse) Bluetooth-Assistant finds it in "Search-all"-Mode and labels it as "BT Receiver", and also finds it if I search for Headsets alone.
    But after that, it just sits there and "collects additional information.", which "should take only seconds".
    There is no timeout on this, no error message is given either.
    Actually, with this Audio-Receiver came an Audio-Transmitter (a USB-BT-Dongle). Connecting this with a MacBook USB-Port does not result in any reaction of the machine.
    The BT-Dongle should be able to do most BT-profiles, including GAP,SPP,HSP,HID and A2DP.
    The System.log does not show anything, except for a "kernel[0]: (3795: ps)tfp: failed on 0:" happening every 3 seconds continually.
    I'm hoping for any ideas... Or should I dump this device?
    Did anyone of you get an audio-sink (with Line-Out) working with OSX?
    Thanks,
    visioneer7
    MacBook   Mac OS X (10.4.8)  

    I've just found out that my Macbook's Bluetooth spec is Bluetooth 2.0+EDR and my keyboard's Bluetooth is 3.0. Would this be of any issue?

  • Problem with Java and Windows (Mainly Vista and UAC)

    Hi all,
    I am having a problem with a program that I've devoloped. The program itself is packaged as a jar and I plan to deploy it across multiple platforms eventually however right now i am only concerned about windows based systems. I have made an installer for a windows baised systems using NSIS to install the software files. I made the installer as I need several java packages to be installed so the program would work (JAI, J3D, JAI ImageIO) and I also require the program to have fileassociations on windows.
    I know that this is not what java is about, however the majority of the users will be on windows baised systems so I've decided that OS specific installers is the best option.
    During the process I have noticed that there are several key problem with java for this type of application!
    The first issue that I have come across is getting file associations to work on java. As a .jar is not an excutable it is not possible to directly associate a filetype with it in java so to overcome this I currently run the program from a .bat files and also the program requires large memory so this also allows me to run the program with -xmx. The batch file that I use is :
    <code>
    cd PATH TO PROGRAM
    start javaw -Dsun.java2d.noddraw=true -Xmn100M -Xms500M -Xmx1000M -jar "PATH TO PROGRAM\program.jar" %1 -vram 134217728
    pause;
    </code>
    Ok so all this appears to work fine and allows windows to have file associations and start the program and thats all works perfectly but this is a non-ideal solution. Has anyone got any advice on improving this?
    The next problem that I have appears to be a problem with Vista and UAC (user access control). When a user installs the program and installs the program into the program files directory I found that the program did not work and kept saying that I did not have access to the files in the current directory. This is a problem as I read and write settings files during program execution.
    On a Vista system UAC prevents file write operations into the Program Files directory unless the program has requested elevated status even if the user is a full administrator. The probem is that there appears to be no real way to achieve this under java that I'm aware of...
    Has anyone else had this probem and has a suitable solution?
    Any advice on these issues would realy be appricated.
    Regards
    Joey

    Ok so i've kinda found a solution, its not ideal but its very good. I found this program called Elevate
    A link to the site I got it was
    http://www.wintellect.com/cs/blogs/jrobbins/archive/2007/03/27/elevate-a-process-at-the-command-line-in-vista.aspx
    This program allows you start java with a UAC dialog for high access using
    Elevate java -jar myjar.jar
    This then allows you to have full access using java... I guess it could be dangerous but it does the job.

  • Problem with drawing info from mysql on an image with java

    I'm trying to draw info on a jpg with java, the info is in a mysql database with columns for what I want to draw and 2 columns for the x,y. I would be glad for any pointers, help and advice.
    1. Strangely the program draws all the info on the same spot in the image. I have no idea what I'm doing wrong.
    2. is there a way to tell java to continue drawing until there are no more rows in the database?
    I deleted the database info.
    Thanks for any help
    import java.awt.*;
    import java.awt.image.*;
    import java.io.*;
    import javax.imageio.*;
    import java.util.*;
    import java.sql.*;
    import javax.sql.*;
    public class carte4 {
        public static void main(String[] args)throws IOException {
        try {
    Statement stmt;
    ResultSet rs;
    com.mysql.jdbc.jdbc2.optional.MysqlDataSource ds;
    Connection conn2;
    ds = new com.mysql.jdbc.jdbc2.optional.MysqlDataSource();
    ds.setServerName("");
    ds.setDatabaseName("");
    conn2 = ds.getConnection("", "");
    stmt = conn2.createStatement();
    rs = stmt.executeQuery( "select * from territoire");
    // process results
    while (rs.next()) {
    String nom = rs.getString("nomterritoire");
    String proprio = rs.getString("nomperso");
    int unites = rs.getInt("unites");
    int coordx = rs.getInt("coordonesX");
    int coordy = rs.getInt("coordonesY");
         BufferedImage image = ImageIO.read(new File(args[0]));
    //remplire les territoires
    Graphics graphics = image.getGraphics();
              graphics.setColor(Color.black);
              graphics.drawString("a" + proprio + unites, coordx, coordy);
            graphics.drawString("b" + proprio) + unites, coordx, coordy);
            graphics.drawString("c" + proprio + unites, coordx, coordy);
              // save modified image
              String format = "JPG";
              ImageIO.write(image, format, new File(args[1]));Message was edited by:
    retosteffen

    Bill,
    Another very helpful solution and I appreciate knowing how to fix it in both applications. Thanks!
    Wolf

  • Generating key pair on PKCS#11token and save it there

    Hello,
    again i'm completely lost in this PKCS11 jungle.
    What i want to do:
    Generating key pair on crypto pkcs11 token and store it there.
    In the moment i've tried eg:
    sun.security.pkcs11.SunPKCS11 p = new sun.security.pkcs11.SunPKCS11(configName);
    Security.addProvider(p);
    Builder builder = KeyStore.Builder.newInstance("PKCS11", p, new KeyStore.CallbackHandlerProtection(new UserInputDialog(new JDialog(),"test","test")));
    KeyStore ks = builder.getKeyStore();
    ks.load(null,null);
    KeyPairGenerator gen = KeyPairGenerator.getInstance("RSA", p);
    gen.initialize(1024);
    KeyPair kp = gen.generateKeyPair();
               Here access to token works. The callback PIN dialog comes up and i can login.
    But i'm not sure whether the key are generated on this PKCS11. And they are not stored there.
    How i can generate keys are stored there.
    (like with keytool -genkeys ). In keytool case a certificate is stored.
    ... every little hint, also to some documentation i've not seen, is very welcome ...
    Thank You !
    Regards
    Thomas
    .

    First, you need to get a KeyStore representation of the PKCS#11 token with code similar to this, I'm using NSS as the PKCS#11 token in this example:
    Provider nss = new sun.security.pkcs11.SunPKCS11(configFile);
    Security.insertProviderAt(nss, 1);  //you may not want it at highest priority
    KeyStore ks = KeyStore.getInstance("PKCS11", nss);
    ks.load(null, password);From the testing I've done in the past with various tokens, when you generate an asymmetric keypair (e.g. RSA like you are) specifying the PKCS11 provider, it creates it right on the token automatically and code like below is not needed.
    To store the key in the keystore, use code similar to this, I'm using NSS again and storing a symmetric key:
    KeyGenerator kg = KeyGenerator.getInstance("DESede",nss);
    SecretKey tripleDesKey = kg.generateKey();
    KeyStore.SecretKeyEntry skEntry = new KeyStore.SecretKeyEntry(tripleDesKey);
    ks.setEntry(randAlias, skEntry, new KeyStore.PasswordProtection(password));

  • I need help with Creating Key Pairs

    Hello,
    I need help with Creating Key Pairs, I generate key pais with aba provider, but the keys generated are not base 64.
    the class is :
    import java.io.*;
    import java.math.BigInteger;
    import java.security.*;
    import java.security.spec.*;
    import java.security.interfaces.*;
    import javax.crypto.*;
    import javax.crypto.spec.*;
    import au.net.aba.crypto.provider.ABAProvider;
    class CreateKeyPairs {
    private static KeyPair keyPair;
    private static KeyPairGenerator pairGenerator;
    private static PrivateKey privateKey;
    private static PublicKey publicKey;
    public static void main(String[] args) throws Exception {
    if (args.length != 2) {
    System.out.println("Usage: java CreateKeyParis public_key_file_name privete_key_file_name");
    return;
    createKeys();
    saveKey(args[0],publicKey);
    saveKey(args[1],privateKey);
    private static void createKeys() throws Exception {
    Security.addProvider(new ABAProvider());
    pairGenerator = KeyPairGenerator.getInstance("RSA","ABA");
    pairGenerator.initialize(1024, new SecureRandom());
    keyPair = pairGenerator.generateKeyPair();
    privateKey = keyPair.getPrivate();
    publicKey = keyPair.getPublic();
    private synchronized static void saveKey(String filename,PrivateKey key) throws Exception {
    ObjectOutputStream out= new ObjectOutputStream(new FileOutputStream(filename));
    out.writeObject(key);
    out.close();
    private synchronized static void saveKey(String filename,PublicKey key) throws Exception {
    ObjectOutputStream out= new ObjectOutputStream( new FileOutputStream(filename));
    out.writeObject(key);
    out.close();
    the public key is:
    �� sr com.sun.rsajca.JSA_RSAPublicKeyrC��� xr com.sun.rsajca.JS_PublicKey~5< ~��% L thePublicKeyt Lcom/sun/rsasign/p;xpsr com.sun.rsasign.anm����9�[ [ at [B[ bq ~ xr com.sun.rsasign.p��(!g�� L at Ljava/lang/String;[ bt [Ljava/lang/String;xr com.sun.rsasign.c�"dyU�|  xpt Javaur [Ljava.lang.String;��V��{G  xp   q ~ ur [B���T�  xp   ��ccR}o���[!#I����lo������
    ����^"`8�|���Z>������&
    d ����"B��
    ^5���a����jw9�����D���D�)�*3/h��7�|��I�d�$�4f�8_�|���yuq ~
    How i can generated the key pairs in base 64 or binary????
    Thanxs for help me
    Luis Navarro Nu�ez
    Santiago.
    Chile.
    South America.

    I don't use ABA but BouncyCastle
    this could help you :
    try
    java.security.Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
    java.security.KeyPairGenerator kg = java.security.KeyPairGenerator.getInstance("RSA","BC");
    java.security.KeyPair kp = kg.generateKeyPair();
    java.security.Key pub = kp.getPublic();
    java.security.Key pri = kp.getPrivate();
    System.out.println("pub: " + pub);
    System.out.println("pri: " + pri);
    byte[] pub_e = pub.getEncoded();
    byte[] pri_e = pri.getEncoded();
    java.io.PrintWriter o;
    java.io.DataInputStream i;
    java.io.File f;
    o = new java.io.PrintWriter(new java.io.FileOutputStream("d:/pub64"));
    o.println(new sun.misc.BASE64Encoder().encode(pub_e));
    o.close();
    o = new java.io.PrintWriter(new java.io.FileOutputStream("d:/pri64"));
    o.println(new sun.misc.BASE64Encoder().encode(pri_e));
    o.close();
    java.io.BufferedReader br = new java.io.BufferedReader(new java.io.FileReader("d:/pub64"));
    StringBuffer keyBase64 = new StringBuffer();
    String line = br.readLine ();
    while(line != null)
    keyBase64.append (line);
    line = br.readLine ();
    byte [] pubBytes = new sun.misc.BASE64Decoder().decodeBuffer(keyBase64.toString ());
    br = new java.io.BufferedReader(new java.io.FileReader("d:/pri64"));
    keyBase64 = new StringBuffer();
    line = br.readLine ();
    while(line != null)
    keyBase64.append (line);
    line = br.readLine ();
    byte [] priBytes = new sun.misc.BASE64Decoder().decodeBuffer(keyBase64.toString ());
    java.security.KeyFactory kf = java.security.KeyFactory.getInstance("RSA","BC");
    java.security.Key pubKey = kf.generatePublic(new java.security.spec.X509EncodedKeySpec(pubBytes));
    System.out.println("pub: " + pubKey);
    java.security.Key priKey = kf.generatePrivate(new java.security.spec.PKCS8EncodedKeySpec(priBytes));
    System.out.println("pri: " + priKey);
    catch(Exception e)
    e.printStackTrace ();
    }

Maybe you are looking for