Help with RSA Encryption using SATSA

Hello,
I am a new to writing code on J2ME . I am trying to encrypt data using
RSA public key on J2ME using SATSA.
I generated the public key using openssl in the PEM format and stored the
key (mypublickey) as a Base64 decoded byte array in my code.
Next, I did the following:
X509EncodedKeySpec test - new X509EncodedKeySpec(mypublickey);
KeyFactory kf = KeyFactory.getInstance("RSA");
PublicKey key = kf.generatePublic(test);
I used this key to encrypt as follows:
cipher c = Cipher.getInstance("RSA");
c.init(Cipher.ENCRYPT_MODE, key);
c.doFinal(data,0,data.length,ciphertext,0);
where byte[] data = "1234567890".getBytes();
I get no errors during this process.
Now, when I try to decrypt the string, I get a padding error as follows:
javax.crypto.BadPaddingException: Data must start with zero
The decode is done on a server.
I tried getting an instance of the cipher with RSA/ECB/NoPadding and this time the decrypt gives junk.
Question 2: The SATSA example online at http://java.sun.com/j2me/docs/satsa-dg/AppD.html
has a public key embedded as a byte array. They haven't explained how
this key is generated. Does someone know?
Question 3: Suppose, I can get the modulus and exponent of the public key is there any way I can convert it to X509EncodedKeySpec so that I can
use the APIs in SATSA?
Thanks in advance for your help. I have been trying to solve this for a lot of time and any help will be greatly appreciated.

Just wanted to add my code:
public class test2 {
     public static void main(String[] args) throws NoSuchAlgorithmException, InvalidKeySpecException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException, ShortBufferException {
          // TODO Auto-generated method stub
          byte [] data = "012345678901234567890123456789ab".getBytes();
          Base64 base64 = new Base64();
/*public key generated by
          byte [] mypublickey = base64.decode("publickey in PEM format");
          byte [] ciphertext = new byte[128];
          X509EncodedKeySpec test = new X509EncodedKeySpec(mypublickey);
          byte [] myprivatekey = base64.decode("privatekey in pkcs8format");
KeyFactory rsakeyfac = KeyFactory.getInstance("RSA");
          PublicKey pubkey = rsakeyfac.generatePublic(test);
          Cipher c1 = Cipher.getInstance("RSA");
          c1.init(Cipher.ENCRYPT_MODE, pubkey);
          c1.doFinal(data, 0,data.length, ciphertext);
          PKCS8EncodedKeySpec pks2 = new PKCS8EncodedKeySpec(myprivatekey);
          RSAPrivateCrtKey privkey = (RSAPrivateCrtKey)rsakeyfac.generatePrivate(pks2);
          Cipher c2 = Cipher.getInstance("RSA");
          c2.init(Cipher.DECRYPT_MODE, privkey);
          byte [] decrypteddata = c2.doFinal(ciphertext);
          System.out.println("Decrypted String is:"+new String(decrypteddata).trim());
Error that I get is:
Exception in thread "main" javax.crypto.BadPaddingException: Data must start with zero
     at sun.security.rsa.RSAPadding.unpadV15(Unknown Source)
     at sun.security.rsa.RSAPadding.unpad(Unknown Source)
     at com.sun.crypto.provider.RSACipher.a(DashoA13*..)
     at com.sun.crypto.provider.RSACipher.engineDoFinal(DashoA13*..)
     at javax.crypto.Cipher.doFinal(DashoA13*..)

Similar Messages

  • Can I encrypt a string with RSA encryption using DBMS_CRYPTO?

    We have an web application that does a redirect thru a database package to a 3rd party site. They would like us to encrypt the querystring that is passed using RSA encryption. The example that they've given us (below) uses the RSA cryptographic service available in .NET. Is it possible to do this using DBMS_CRYPTO or some other method in Oracle?
    Below are the steps outlined to use the key to generate the encrypted URL
    2.1 Initialize Service
    The RSA cryptographic service must be initialized with the provided public key. Below is sample code that can be used to initialize the service using the public key
    C#
    private void InitializeRSA( string keyFileName )
    CspParameters cspParams = new CspParameters( );
    cspParams.Flags = CspProviderFlags.UseMachineKeyStore;
    m_sp = new RSACryptoServiceProvider( cspParams );
    //Load the public key from the supplied XML file
    StreamReader reader = new StreamReader( keyFileName );
    string data = reader.ReadToEnd( );
    //Initializes the public key
    m_sp.FromXmlString( data );
    2.2 Encryption method
    Create a method that will encrypt a string using the cryptographic service that was initialized in step 2.1. The encryption method should convert the encryption method to Base64 to avoid special characters from being passed in the URL. Below is sample code that uses the method created in step 2.1 that can be used to encrypt a string.
    C#
    private string RSAEncrypt( string plainText )
    ASCIIEncoding enc = new ASCIIEncoding( );
    int numOfChars = enc.GetByteCount( plainText );
    byte[ ] tempArray = enc.GetBytes( plainText );
    byte[ ] result = m_sp.Encrypt( tempArray, false );
    //Use Base64 encoding since the encrypted string will be used in an URL
    return Convert.ToBase64String( result );
    2.3 Generate URL
    The query string must contain the necessary data elements configured for you school in Step 1. This will always include the Client Number and the Student ID of the student clicking on the link.
    1.     Build the query string with Client Number and Student ID
    C#
    string queryString = “schoolId=1234&studentId=1234”;
    The StudentCenter website will validate that the query string was generated within 3 minutes of the request being received on our server. A time stamp in UTC universal time (to prevent time zone inconsistencies) will need to be attached to the query string.
    2.     Get the current UTC timestamp, and add the timestamp to the query string
    C#
    string dateTime = DateTime.UtcNow.ToString(“yyyy-MM-dd HH:mm:ss”);
    queryString += “&currentDT=” + dateTime;
    Now that the query string has all of the necessary parameters, use the RSAEncrypt (Step 2.2) method created early to encrypt the string. The encrypted string must also be url encoded to escape any special characters.
    3.     Encrypt and Url Encode the query string
    C#
    string rsa = RSAEncrypt(querystring);
    string eqs = Server.UrlEncode(rsa);
    The encrypted query string is now appended to the Url (https://studentcenter.uhcsr.com), and is now ready for navigation.
    4.     Build the URL
    C#
    string url = “https://studentcenter.uhcsr.com/custom.aspx?eqs=” + eqs

    The documentation lists all the encyrption types:
    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_crypto.htm#ARPLS664

  • Help With ASE Encryption

    Hello friends,
    Can anyone out there tell me or point me to information on how to set up the ASE_ENCRYPTION option for version 15.7?
    I have an existing ASE installation for testing purposes. I want to install the encryption option there but I cannot locate any
    step-by-step documentation on how to do that. The ASE 15.7 Encrypted Columns Users Guide simply states:
    "Install the license option ASE_ENCRYPTION. See the Adaptive Server Enterprise Installation Guide."
    and when I go to the ASE Installation Guide it refers me to the SySam User's Guide...
    and when I go to the SySam User's Guide it gives no instructions on *how* to install the encryption option.
    So, to summarize:
    1.) Do I need to generate a license file that includes the ASE_ENCRYPTION option and start ASE with this license file? I was
    told by someone at SAP that there should be a way to get and use this option for thirty days (grace license) while we test
    and evaluate.
    2.) If above is true, will this work with the Developer's Edition of ASE or do I have to get a Enterprise Edition SR or SV
    license? (By the way, I do have an available SV license for Enterprise. I generated the license file and it shows that this license includes
    a package of Components= ASE_CORE  Options=SUITE)
    Any help with this will be appreciated.

    Thanks for your help Ajit,
    I believe you are correct. I was told that the ASE_ENCRYPTION option was already packaged with the software so all I had to do was "turn it on". For some reason I was thinking it had to be installed via a script or something.
    Anyway, I have successfully "turned on" the option using :
    sp_configure "enable encrypted columns", 1
    go
    I will now attempt to create an encryption key and go forward with data encryption.
    Thanks again for your input

  • Help with Photo Gallery using XML file

    I am creating a photo gallery using Spry.  I used the Photo Gallery Demo (Photo Gallery Version 2) on the labs.adobe.com website.  I was successful in creating my site, and having the layout I want.  However I would like to display a caption with each photo that is in the large view.
    As this example uses XML, I updated my file to look like this:
    <photos id="images">
                <photo path="aff2010_01.jpg" width="263" height="350" thumbpath="aff2010_01.jpg" thumbwidth="56"
                   thumbheight="75" pcaption="CaptionHere01"></photo>
                <photo path="aff2010_02.jpg" width="350" height="263" thumbpath="aff2010_02.jpg" thumbwidth="75"
                   thumbheight="56" pcaption="CaptionHere02"></photo>
                <photo path="aff2010_03.jpg" width="350" height="263" thumbpath="aff2010_03.jpg" thumbwidth="75"
                   thumbheight="56" pcaption="CaptionHere03"></photo>
    </photos>
    The images when read into the main file (index.asp) show the images in the thumbnail area and display the correct image in the picture pain.  Since I added the pcaption field to the XML file, how do I get it to display?  The code in my index.html file looks like this:

    rest of the code here:
            <div id="previews">
                <div id="controls">
                    <ul id="transport">
                        <li><a href="#" class="previousBtn" title="Previous">Previous</a></li>
                        <li><a href="#" class="playBtn" title="Play/Pause" id="playLabel"><span class="playLabel">Play</span><span class="pauseLabel">Pause</span></a></li>
                        <li><a href="#" class="nextBtn" title="Next">Next</a></li>
                    </ul>
                </div>
                <div id="thumbnails" spry:region="dsPhotos" class="SpryHiddenRegion">
                    <div class="thumbnail" spry:repeat="dsPhotos"><a href="{path}"><img alt="" src="{thumbpath}"/></a><br /></div>
                    <p class="ClearAll"></p>
                </div>
            </div>
            <div id="picture">
                <div id="mainImageOutline"><img id="mainImage" alt="main image" src=""/><br /> Caption:  {pcaption}</div>
            </div>
            <p class="clear"></p>
        </div>
    Any help with getting the caption to display would be greatly appreciated.  The Caption {pcaption} does not work,

  • Help with swap images using rollovers

    I have a website created using DW CS5. Recently purchased FW CS5 to help with web graphics and design. I am trying to create a list of numbers that will swap with images. The intial page would simply be a list of numbers and 1 static image. Each number, when hovered will change the image with another. I've attempted this by first using DW and not having much success with FW either.
    If able to complete this using FW, is it possible to export the file for use in DW? Then insert into an AP Div?

    You're over-complicating it.
    Simply hit File>Save once you're done in photoshop.
    ian

  • Need Help With Military DTD Using FrameMaker 8

    Fellow Forum Members,
    I hope someone out there with experience in using Department of Defense DTDs with FrameMaker can contribute to this thread.
    Attached is the MIL STD 400051-2 DTD that needs to play with FrameMaker. Does anyone out there know where I could find FrameMaker templates already setup that comply and play with the MIL STD 400051-2 DTD standard? If the Department of Defense is freely distributing the MIL STD 400051-2 DTD, shouldn't somebody in the Department of Defense also be providing MIL STD 400051-2 FrameMaker Templates for free that are already setup?  I would greatly appreciate if anyone out there could provide an online source where I could download MIL STD 400051-2 FrameMaker templates.
    Lastly, can anyone out there clarify what the purpose of the entities are inside the "Charant" and "Boilerplate" folders?  The Department of Defense does not provide a readme file that define what the "Charant" and "Boilerplate" folders are about.
    Any info will be greatly appreciated. Thanks.

    I'll answer the specifics that I know about your questions, but please look at the post from Srini for additional info:
    1) Do i need to do full export using SYS/SYSTEM user.
    exp80 system/manager file=c:full.dmp log=c:\full.txt full=y consistent=yA full export will move as much information (metadata/data) as possible. In order to do a full export/import, you need to do this from a
    privileged account. A privileged account is one with EXP_FULL_DATABASE for export and IMP_FULL_DATABASE for import.
    2) Will there be any data corruption while export.The data in the objects that you are exporting is being read, nothing is written to user data. I'm not sure what this is available in 8.0.6,
    but if you need a consistent export, look to see if consistent=y is available in 8.0.6. All this means is that the dump file created will have
    consistent data in it.
    3) Is export/import the only method of migration/upgradation.If you are changing hardware, the only supported way from 8.0 to 10.2.0.4, that I know of, is using exp/imp.
    Hope this helps.
    Dean

  • Help with Switch statements using Enums?

    Hello, i need help with writing switch statements involving enums. Researched a lot but still cant find desired answer so going to ask here. Ok i'll cut story short.
    Im writing a calculator program. The main problem is writing code for controlling the engine of calculator which sequences of sum actions.
    I have enum class on itself. Atm i think thats ok. I have another class - the engine which does the work.
    I planned to have a switch statement which takes in parameter of a string n. This string n is received from the user interface when users press a button say; "1 + 2 = " which each time n should be "1", "+", "2" and "=" respectively.
    My algorithm would be as follows checking if its a operator(+) a case carry out adding etc.. each case producing its own task. ( I know i can do it with many simple if..else but that is bad programming technique hence im not going down that route) So here the problem arises - i cant get the switch to successfully complete its task... How about look at my code to understand it better.
    I have posted below all the relevant code i got so far, not including the swing codes because they are not needed here...
    ValidOperators v;
    public Calculator_Engine(ValidOperators v){
              stack = new Stack(20);
              //The creation of the stack...
              this.v = v;          
    public void main_Engine(String n){
           ValidOperators v = ValidOperators.numbers;
                    *vo = vo.valueOf(n);*
         switch(v){
         case Add: add();  break;
         case Sub: sub(); break;
         case Mul: Mul(); break;
         case Div: Div(); break;
         case Eq:sum = stack.sPop(); System.out.println("Sum= " + sum);
         default: double number = Integer.parseInt(n);
                       numberPressed(number);
                       break;
                      //default meaning its number so pass it to a method to do a job
    public enum ValidOperators {
         Add("+"), Sub("-"), Mul("X"), Div("/"),
         Eq("="), Numbers("?"); }
         Notes*
    It gives out error: "No enum const class ValidOperators.+" when i press button +.
    It has nothing to do with listeners as it highlighted the error is coming from the line:switch(v){
    I think i know where the problem is.. the line "vo = vo.valueOf(n);"
    This line gets the string and store the enum as that value instead of Add, Sub etc... So how would i solve the problem?
    But.. I dont know how to fix it. ANy help would be good
    Need more info please ask!
    Thanks in advance.

    demo:
    import java.util.*;
    public class EnumExample {
        enum E {
            STAR("*"), HASH("#");
            private String symbol;
            private static Map<String, E> map = new HashMap<String, E>();
            static {
                put(STAR);
                put(HASH);
            public String getSymbol() {
                return symbol;
            private E(String symbol) {
                this.symbol = symbol;
            private static void put(E e) {
                map.put(e.getSymbol(), e);
            public static E parse(String symbol) {
                return map.get(symbol);
        public static void main(String[] args) {
            System.out.println(E.valueOf("STAR")); //succeeds
            System.out.println(E.parse("*")); //succeeds
            System.out.println(E.parse("STAR")); //fails: null
            System.out.println(E.valueOf("*")); //fails: IllegalArgumentException
    }

  • Help with sending string using setRequestProperty to servlet

    I have a string that is encrpyted so it uses some wierd characters. An
    example of the integer representation of the characters for a string that is
    not working is:
    26,162,91,52,153,136,227,53,190,0
    When I recieve it on the servlet end and go to use it the integer
    representation of the characters is all messed up therefore I can't decrypt
    it properly. The servlet recieved:
    26,162,91,52, 63 , 63 ,227,53,190,0
    Where did the 63's come form??????? That is a "?" character and was not
    part of the original string. I think it has something to do with when the
    characters are converted to bytes or something but I can't seem to figure
    out a way to fix it so that I get the original characters...
    Please, any help would be very much appreciated. Thanks.

    Hmmm....my last post doesn't appear to make a whole lot of sense. I've got to start getting to bed earlier.
    I guess I was a little excited when I realized what URLEncoder and URLDecoder were doing (by looking at the source, of course) which involves a lot of char conversion on the individual portions of your String. These classes are for US-ASCII text and really don't handle non-printable characters very well.
    The passing of the characters across the connection remains a problem, and (without looking at source code) I believe the same problem is at the root; there is a basic encoding of your String into a format that doesn't support characters that aren't in the code page, and the question marks are substituted.
    I haven't tried, but can suggest, using the encode/decode methods in the javax.mail.internet.MimeUtility class. This class comes with the J2EE download, but I'm afraid it may have some of the same shortcomings when it comes to characters it doesn't like (its methods appear to be mostly for mail HEADERS.)
    You basically need either a UUEncode or Base64 encoder/decoder to translate your String into plaintext before it gets sent to the Servlet. The Java Commerce API (Java Wallet) contains a Base64Encoder/Base64Decoder but it is not licensed for reuse.
    There might be other options (I don't know the full scope of your setup), but if all else fails, I can post a UUEncode class that will convert your encrypted string into plaintext for transmission.

  • Help with InDesign and using MacBook Pro with 2.4 GHz Intel Core 2 Duo with 2GB

    Have a Mac Book Pro running 2.4 GHz Intel Core 2 Duo with 2GB RAM is there anyway to use InDesign and if so what version would run on this machine and would I still be able to interface with a printer to produce a magazine?  Or is it possible to upgrade/gut this machine for a new processor and RAM, if that is even possible, and could I then run a CS program say 5.5?

    Thanks for all the help - it is confusing though. I tried to download the trial version of CS5.5 to explore before buying the student version and the program download froze. I have deleted the doadload assistant and spoke with Adobe who told me my machine would not be compatible unless I upgraded - maybe the RAM to 4GB.
    You got bad (wrong) advice.
    If the download didn't work, it has nothing to do with the performance characteristics of your machine. You could download CS5.5 on a low-end PC from 10 years ago, it doesn't take much.
    Unfortunately Adobe's download manager is a bit flakey. Best advice is to use Firefox and try the download again.
    It doesn't have anything to do with the power of your computer, be it speed, processor type, or RAM.
    Make sure you're using FIrefox (if not, download and install it first), and then try the download again.
    Also, the download manager depends on Java. Make sure you have Java installed (but I think you must, because otherwise the download would not have started?).
    If it still doesn't work, give us some more detail. Error message? Screenshot?

  • Need help with reading XML using File Adapter

    I have created a simple BPEL process that uses a file adapter to read files containing XML messages of a simple xsd schema. But when reading the xml, I get the following error message:
    [2010/03/01 23:43:13] Invalid data: The value for variable "Receive_1_Read_InputVariable", part "revision-report" does not match the schema definition for this part.The invalid xml document is shown below: More...
    [2010/03/01 23:43:13] "{http://schemas.oracle.com/bpel/extension}invalidVariables" has been thrown. less
    -<invalidVariables xmlns="http://schemas.oracle.com/bpel/extension">
    -<part name="code">
    <code>
    9710
    </code>
    </part>
    -<part name="summary">
    <summary>
    Invalid xml document.
    According to the xml schemas, the xml document is invalid. The reason is: Error::cvc-complex-type.4: Attribute 'doc' must appear on element 'revision-report'.
    Error::cvc-complex-type.4: Attribute 'model' must appear on element 'revision-report'.
    Error::cvc-complex-type.4: Attribute 'pubdate' must appear on element 'revision-report'.
    Error::cvc-complex-type.2.4.b: The content of element 'revision-report' is not complete. One of '{"http://xmlns.oracle.com/xmlfile":alternategroup}' is expected.
    Please make sure that the xml document is valid against your schemas.
    </summary>
    </part>
    </invalidVariables>
    It seems that there is some issue with the namespace, but even after trying out various combinations, I am not able to resolve this.
    Here the message schema (xsd):
    <?xml version="1.0" encoding="UTF-8" ?>
    <xs:schema elementFormDefault="qualified"
    targetNamespace="http://xmlns.oracle.com/xmlfile"
    xmlns:tns="http://xmlns.oracle.com/xmlfile"
    xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="revision-report">
    <xs:complexType>
    <xs:sequence maxOccurs="unbounded">
    <xs:element name="alternategroup">
    <xs:complexType>
    <xs:attribute name="name" use="required" type="xs:string"/>
    <xs:attribute name="Desc" use="required" type="xs:string"/>
    </xs:complexType>
    </xs:element>
    </xs:sequence>
    <xs:attribute name="doc" use="required" type="xs:string"/>
    <xs:attribute name="model" use="required" type="xs:string"/>
    <xs:attribute name="pubdate" use="required" type="xs:string"/>
    </xs:complexType>
    </xs:element>
    </xs:schema>
    And here is the xml file to be read by the file adapter:
    <?xml version="1.0" encoding="UTF-8" ?>
    <revision-report doc="doc2" model="model4" pubdate="pubdate5">
    <alternategroup Name="ABC" Desc="ABC-Desc">
    </alternategroup>
    <alternategroup Name="DEF" Desc="DEF-Desc">
    </alternategroup>
    <alternategroup Name="GHI" Desc="GHI-Desc">
    </alternategroup>
    </revision-report>
    Appreciate any help.
    Thanks in advance for your attention.
    Jay

    Thanks for your response.
    I am not sure if there is any easier way, but I tried out the following tool available on the net to check an xml against a xsd:
    http://tools.decisionsoft.com/schemaValidate/
    There were a few issues, that I corrected and finally had a xsd and xml that were matching and valid. I tried this out in my file reading BPEL process, but the error still remained the same!
    Here is my updated/simplified xsd and xml:
    <?xml version="1.0" encoding="UTF-8" ?>
    <xs:schema targetNamespace="http://xmlns.oracle.com/xmlfile"
    xmlns:tns="http://xmlns.oracle.com/xmlfile"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns="http://xmlns.oracle.com/xmlfile">
    <xs:element name="revision-report">
    <xs:complexType>
    <xs:sequence>
    <xs:element maxOccurs="unbounded" ref="alternategroup"/>
    </xs:sequence>
    <xs:attribute name="doc" use="required" type="xs:string"/>
    <xs:attribute name="model" use="required" type="xs:string"/>
    <xs:attribute name="pubdate" use="required" type="xs:string"/>
    </xs:complexType>
    </xs:element>
    <xs:element name="alternategroup">
    <xs:complexType>
    <xs:attribute name="Name" use="required" type="xs:string"/>
    <xs:attribute name="Desc" use="required" type="xs:string"/>
    </xs:complexType>
    </xs:element>
    </xs:schema>
    <?xml version="1.0" encoding="UTF-8" ?>
    <revision-report doc="doc2" model="model4" pubdate="pubdate5" xmlns="http://xmlns.oracle.com/xmlfile">
    <alternategroup Name="ABC" Desc="ABC-Desc"/>
    <alternategroup Name="DEF" Desc="DEF-Desc"/>
    <alternategroup Name="GHI" Desc="GHI-Desc"/>
    </revision-report>
    I even tried the option that is available in JDeveloper to generate a sample xml from a xsd (when in the context of a Transformation activity). The xml generated by this also seems exactly like the one above.
    So, I am not able to figure out why my BPEL process errors out with the message Invalid xml document.

  • Help with password encryption

    Hello I am trying to create a one way hash password encryption...here is what I have developed so far.....
    Login class (contains GUI)
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.io.*;
    import java.awt.image.*;
    import javax.imageio.*;
    public class Login implements ActionListener
      // declare class variables and objects
      // overall frame
      private FrameBase jf;
      // buttons
      private JButton btnNewUser,btnLogin;
      // data display labels
      private JLabel lblMessage, lblUser, lblPassword, lblTitle, lblCheck,lblNotes;
      // text fields for data entry
      private JTextField txtUser, txtPassword,txtCheck;
      // graphic object
      private BufferedImage eSay;
      // panels for organization
      private JPanel pnlTitle, pnlMain, pnlGraphic;
      // font objects
      private Font fntTitle, fntMain, fntControl,fntNotes;
      // user name for repeated set screen calls
      private String name;
      // store screen layout option code
      private int option;
      // option 1 - regular start-up
      // option 2 - new user screen
      // option 3 - user / password check
      public Login(String name)
        // set up the fonts
        fntTitle=new Font("Helvetica", Font.BOLD, 25);
        fntMain=new Font("Helvetica", Font.BOLD, 20);
        fntControl=new Font("Helvetica", Font.BOLD, 15);
        fntNotes=new Font("Helvetica", Font.BOLD, 16);
        // set the BufferedImage object to null;
        eSay=null;
        try
          // load the image from disk into a BufferedImage object
          eSay=ImageIO.read(new File("h:\\My documents\\ICS4M1\\Login\\eSay.jpg"));
          // set up the screen
          this.name=name;
          this.option=1;
          setScreen(name);
        catch (IOException e)
          // message if file not found
          System.out.println("Image not found");
      public void setScreen(String name)
        jf= new FrameBase(name);
        // set up the screen
        Container contentPane=jf.getContentPane();
        contentPane.setLayout(new BorderLayout());
        // set up the graphic
        pnlGraphic=new JPanel();
        pnlGraphic.setLayout(new BorderLayout());
        // load the BufferedImage into the ImageLabel
        ImageLabel il=new ImageLabel(eSay,"");
        // load the ImageLabel onto the panel
        pnlGraphic.add("Center",il);
        // set up the title section
        lblTitle=new JLabel("Welcome to eSay",0);
        lblTitle.setFont(fntTitle);
        lblMessage=new JLabel("Enter user name and password and click on Login or click on New User to set up a new account",0);
        lblMessage.setFont(fntControl);
        // set up the panel for the title area
        pnlTitle=new JPanel();
        pnlTitle.setLayout(new GridLayout(2,1));
        pnlTitle.add(lblTitle);
        pnlTitle.add(lblMessage);
        // set up the input section of the screen
        lblUser=new JLabel("User: ");
        lblUser.setFont(fntMain);
        lblPassword=new JLabel("Password: ");
        lblPassword.setFont(fntMain);
        lblCheck=new JLabel("Re-Type Password: ");
        lblCheck.setFont(fntMain);
        lblCheck.setEnabled(false);
        lblNotes=new JLabel("<html><font color=\"red\">User name 6 to 10 alphanumeric characters,  password 5 to 8 alphanumeric characters, </font></html>",0);
        lblNotes.setFont(fntNotes);
        txtUser=new JTextField(20);
        txtUser.setFont(fntMain);
        txtPassword=new JTextField(20);
        txtPassword.setFont(fntMain);
        txtCheck=new JTextField(20);
        txtCheck.setFont(fntMain);
        txtCheck.setEnabled(false);
        btnLogin=new JButton("Login");
        btnLogin.setFont(fntMain);
        btnNewUser=new JButton("New User");
        btnNewUser.setFont(fntMain);
        // make the button active
        btnLogin.addActionListener(this);
        btnNewUser.addActionListener(this);
        // assemble the input section panel
        pnlMain=new JPanel();
        pnlMain.setLayout(new GridLayout(5,2));
        pnlMain.add(lblUser);
        pnlMain.add(txtUser);
        pnlMain.add(lblPassword);
        pnlMain.add(txtPassword);
        pnlMain.add(btnNewUser);
        pnlMain.add(btnLogin);
        pnlMain.add(lblCheck);
        pnlMain.add(txtCheck);
        // add the panels to the screen
        contentPane.add(pnlTitle,"North");
        contentPane.add(pnlGraphic,"Center");
        contentPane.add(pnlMain,"East");
        contentPane.add(lblNotes,"South");
        // set up and show the frame
        jf.setSize(900,400);
        jf.show();
      } // end of setScreen()
      public void actionPerformed(ActionEvent e)
        if (e.getSource()==btnNewUser)
          if (option==1)
            lblCheck.setEnabled(true);
            txtCheck.setEnabled(true);
            lblMessage.setText("Create a login name and password, enter the password twice as indicated");
            btnLogin.setEnabled(false);
            option=2;
          else if (option==2)
            String tempUser=txtUser.getText();
            String tempPassword=txtPassword.getText();
            String tempCheck=txtCheck.getText();
            if (tempPassword.equals(tempCheck))
              ValidateUser vu=new ValidateUser(tempUser,tempPassword);
              if (vu.getEncryptedPassword()==null)
                lblMessage.setText("Please check guidelines for user name and password and re-enter");
              else
                lblMessage.setText("Login created - Welcome to eSay!");
            else
              lblMessage.setText("Passwords do not match, please re-enter login and password twice");
        else if (e.getSource()==btnLogin)
      }  // actionPerformed
      public static void main(String args[])
        Login l=new Login("eSay Message Board");
    }  // end class Login            User class
    public class User
      private String userName;
      private String password;
      private int numberLogins;
      public User(String userName, String password)
        this.userName=userName;
        this.password=password;
        this.numberLogins=0;
      // gets for surname, first name and number of logins
      public String getUserName()
        return userName;
      public int getNumberLogins()
        return numberLogins;
      public void resetLogins()
        this.numberLogins=0;
      public void login()
        this.numberLogins++;
      public static void main(String args [])
           // enter test statements here
    } // end of User classValidate User(validation)
              System.out.println ("A character is invalid");
              return false;   
        return true;        
         // create an encrypted password if user name and password are valid
        public void encryptPassword()
        // standard get for encrypted password
        public String getEncryptedPassword()
          return encryptedPassword;
    }PasswordService(One way hash conversion)
    package org.myorg.services;
    import java.io.UnsupportedEncodingException;
    import java.security.MessageDigest;
    import java.security.NoSuchAlgorithmException;
    import org.myorg.SystemUnavailableException;
    import sun.misc.BASE64Encoder;
    import sun.misc.CharacterEncoder;
    public final class PasswordService
      private static PasswordService instance;
      private PasswordService()
      public synchronized String encrypt(String plaintext) throws SystemUnavailableException
        MessageDigest md = null;
        try
          md = MessageDigest.getInstance("SHA");
        catch(NoSuchAlgorithmException e)
          throw new SystemUnavailableException(e.getMessage());
        try
          md.update(plaintext.getBytes("UTF-8"));
        catch(UnsupportedEncodingException e)
          throw new SystemUnavailableException(e.getMessage());
        byte raw[] = md.digest();
        String hash = (new BASE64Encoder()).encode(raw);
        return hash;
      public static synchronized PasswordService getInstance()
        if(instance == null)
          return new PasswordService();
        else   
          return instance;
    }

    I was wondering if someone could help me to incorporate some kind of one way hash into the encryptPassword method in Validate user...i am having problems trying to call on the PasswordService and incorporating everything. The reason i supplied all the code was so that the reader could understand how different programs correlate with one another

  • Please help with importing and using imovie and idvd

    Hi,
    Please forgive my lack of knowledge. I previously had a mini dv camcorder that was so easy to use with imovie hd. Now that I have switched to an HD Usb 2.0 camcorder that has built in 16gb memory and memory cards, I have had such a great deal of trouble. I really hope you can help and point me in the right directions.
    Importing movies are fine, but they take so long! Currently, when I import a movie, I set the camcorder to PC mode and import through imovie. But the camcorder stays on, and I'm not sure if this is the best way or healthiest for the camcorder. Do you have a better/faster way to import movies? Is there a way to drag the video from the memory onto the computer, and then from there import the movie? I think at least I wouldn't have to leave the camcorder on.
    Also, one major issue I have is that each movie is broken down into 100 or so clips. I coach basketball, and videotape the games. When there is stoppage, I pause the camcorder. I guess that creates so many clips, so that when the film is imported, there are over 100 clips for the entire movie. Is there a way of making that just 1 entire movie/clip?
    Once I have imported the entire movie, which is 100+ clips, I want to simply create a dvd of the game. I know I have to share it, but do you have a better suggestion as to how I should handle this?
    In the past, all I did was import the mini dv movie into imovie HD, share into idvd, and then that was it, dvd made. This process had become so time consuming.
    Please help!

    Yes, I recognized there would be a slight pause between clips - but after all - you paused the camera at those points.
    Putting them all in sequence in iMovie and then encoding in iDVD will take a lot of time.
    An old favorite saying of mine is "not every job worth doing, is worth doing well'. The meaning being sometimes 95% is good enough so you can go on to the next job.
    How much work do you want to put into each DVD? Can you live with the slight pauses?
    would you suggest using a memory card?
    Yes, but 16GB cards aren't cheap (yet).

  • Help with an epub using indesign cs6

    Hi there guys and gals I need some help trying to make an epub for my wives book. The problem is that my wifes book consist of pictures with the words in them. Im trying to make it so we can try and publish it. the problem is im not sure what the right formatting would be to use in indesign please feel free to message me on here with either videos or even links to information that possibly help.

    Video: http://tv.adobe.com/watch/creative-suite-podcast-designers/how-to-maintain-formatting-when -exporting-your-epub-from-indesign-cs6/
    Link: http://helpx.adobe.com/indesign/using/export-content-epub-cs6.html

  • Need Help With Redirect That Uses Session Variable

    I am new to dynamic sites, php, and developer toolbox, but I have been able to create a login site using the different form wizards fairly easily (in CS3 with Developers toolbox).
    <br />
    <br />I am trying to set a server behavior on a page that redirects the user to a new page if a session variable matches a recordset.
    <br />
    <br />I was using an extension (PHP Sessions - http://www.adobe.com/cfusion/exchange/index.cfm?event=extensionDetail&amp;extid=681308 ) that worked great, but when I installed developers toolbox, it stopped working (get error message about runtime/MX environment).
    <br />
    <br />Ive been struggling for days and this is what Ive come up with so far:
    <br />------------------------------------
    <br />session_start();
    <br />if (!isset($HTTP_SESSION_VARS[$_SESSION['kt_firstname']]) || $HTTP_SESSION_VARS[$_SESSION['kt_firstname']] = $row_Recordsetfname['firstname']) {
    <br /> header ("Location: ../firstname/firstname1.php");
    <br />}
    <br />------------------------------------
    <br />
    <br />It redirects regardless of the match. Any ideas on what I can do to get this working? Here is all of the code (with block from above inserted) up until the doc type:
    <br />------------------------------------
    <br /><?php require_once('../Connections/project1.php'); ?>
    <br /><?php<br />// Load the tNG classes<br />require_once('../includes/tng/tNG.inc.php');<br /><br />// Make unified connection variable<br />$conn_project1 = new KT_connection($project1, $database_project1);<br /><br />//Start Restrict Access To Page<br />$restrict = new tNG_RestrictAccess($conn_project1, "../");<br />//Grand Levels: Any<br />$restrict->Execute();<br />//End Restrict Access To Page<br /><br />if (!function_exists("GetSQLValueString")) {<br />function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") <br />{<br />  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;<br /><br />  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);<br /><br />  switch ($theType) {<br />    case "text":<br />      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";<br />      break;    <br />    case "long":<br />    case "int":<br />      $theValue = ($theValue != "") ? intval($theValue) : "NULL";<br />      break;<br />    case "double":<br />      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";<br />      break;<br />    case "date":<br />      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";<br />      break;<br />    case "defined":<br />      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;<br />      break;<br />  }<br />  return $theValue;<br />}<br />}<br /><br />// FELIXONE - 2002   SB by Felice Di Stefano - www.felixone.it<br />session_start();<br />if (!isset($HTTP_SESSION_VARS[$_SESSION['kt_firstname']]) || $HTTP_SESSION_VARS[$_SESSION['kt_firstname']] = $row_Recordsetfname['firstname']) {<br />  header ("Location: ../firstname/firstname1.php");<br />}<br /><br />$colname_Recordsetfname = "-1";<br />if (isset($_SESSION['kt_user_name'])) {<br />  $colname_Recordsetfname = $_SESSION['kt_user_name'];<br />}<br />mysql_select_db($database_project1, $project1);<br />$query_Recordsetfname = sprintf("SELECT firstname FROM registration WHERE user_name = %s", GetSQLValueString($colname_Recordsetfname, "text"));<br />$Recordsetfname = mysql_query($query_Recordsetfname, $project1) or die(mysql_error());<br />$row_Recordsetfname = mysql_fetch_assoc($Recordsetfname);<br />$totalRows_Recordsetfname = mysql_num_rows($Recordsetfname);<br /><br />$colname_Recordset1 = "-1";<br />if (isset($_SESSION['kt_user_name'])) {<br />  $colname_Recordset1 = $_SESSION['kt_user_name'];<br />}<br />mysql_select_db($database_project1, $project1);<br />$query_Recordset1 = sprintf("SELECT `Date` FROM registration WHERE user_name = %s", GetSQLValueString($colname_Recordset1, "text"));<br />$Recordset1 = mysql_query($query_Recordset1, $project1) or die(mysql_error());<br />$row_Recordset1 = mysql_fetch_assoc($Recordset1);<br />$totalRows_Recordset1 = mysql_num_rows($Recordset1);<br />?>
    <br />
    <br />------------------------------

    I am new to adobe toolbox... I ve created a ligin page but not sure how to pass the session variable. I am trying to direct successful login to a page like... index.php?id=filter
    <br />
    <br />been struggling all day with this. Please help!!!
    <br />
    <br /><?php require_once('Connections/comm.php'); ?>
    <br /><?php<br />// Load the common classes<br />require_once('includes/common/KT_common.php');<br /><br />// Load the tNG classes<br />require_once('includes/tng/tNG.inc.php');<br /><br />// Make a transaction dispatcher instance<br />$tNGs = new tNG_dispatcher("");<br /><br />// Make unified connection variable<br />$conn_comm = new KT_connection($comm, $database_comm);<br /><br />// Start trigger<br />$formValidation = new tNG_FormValidation();<br />$formValidation->addField("kt_login_user", true, "text", "", "", "", "");<br />$formValidation->addField("kt_login_password", true, "text", "", "", "", "");<br />$tNGs->prepareValidation($formValidation);<br />// End trigger<br /><br />// Make a login transaction instance<br />$loginTransaction = new tNG_login($conn_comm);<br />$tNGs->addTransaction($loginTransaction);<br />// Register triggers<br />$loginTransaction->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "POST", "kt_login1");<br />$loginTransaction->registerTrigger("BEFORE", "Trigger_Default_FormValidation", 10, $formValidation);<br />$loginTransaction->registerTrigger("END", "Trigger_Default_Redirect", 99, "{kt_login_redirect}");<br />// Add columns<br />$loginTransaction->addColumn("kt_login_user", "STRING_TYPE", "POST", "kt_login_user");<br />$loginTransaction->addColumn("kt_login_password", "STRING_TYPE", "POST", "kt_login_password");<br />$loginTransaction->addColumn("kt_login_rememberme", "CHECKBOX_1_0_TYPE", "POST", "kt_login_rememberme", "0");<br />// End of login transaction instance<br /><br />// Execute all the registered transactions<br />$tNGs->executeTransactions();<br /><br />// Get the transaction recordset<br />$rscustom = $tNGs->getRecordset("custom");<br />$row_rscustom = mysql_fetch_assoc($rscustom);<br />$totalRows_rscustom = mysql_num_rows($rscustom);<br /><br />?>
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <script src="includes/common/js/base.js" type="text/javascript"></script>
    <br />
    <script src="includes/common/js/utility.js" type="text/javascript"></script>
    <br />
    <script src="includes/skins/style.js" type="text/javascript"></script>
    <br /><?php echo $tNGs->displayValidationRules();?>
    <br />
    <br />
    <br />
    <br /><?php<br /> echo $tNGs->getLoginMsg();<br />?>
    <br /><?php<br /> echo $tNGs->getErrorMsg();<br />?>
    <br />
    <form method="post" id="form1" class="KT_tngformerror" action="%3C?php%20echo%20KT_escapeAttribute(KT_getFullUri());%20?%3E">
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <table cellpadding="2" cellspacing="0" class="KT_tngtable">
    <tr>
    <td class="KT_th">
    <label for="kt_login_user">Username:</label>
    </td>
    <td>
    <input type="text" name="kt_login_user" id="kt_login_user" value="<?php echo KT_escapeAttribute($row_rscustom['kt_login_user']); ?>" size="32" />
    <br /> <?php echo $tNGs->displayFieldHint("kt_login_user");?> <?php echo $tNGs->displayFieldError("custom", "kt_login_user"); ?></td>
    </tr>
    <tr>
    <td class="KT_th">
    <label for="kt_login_password">Password:</label>
    </td>
    <td>
    <input type="password" name="kt_login_password" id="kt_login_password" value="" size="32" />
    <br /> <?php echo $tNGs->displayFieldHint("kt_login_password");?> <?php echo $tNGs->displayFieldError("custom", "kt_login_password"); ?></td>
    </tr>
    <tr>
    <td class="KT_th">
    <label for="kt_login_rememberme">Remember me:</label>
    </td>
    <td>
    <input <?php if (!(strcmp(KT_escapeAttribute($row_rscustom['kt_login_rememberme']),"1"))) {echo "checked";} ?> type="checkbox" name="kt_login_rememberme" id="kt_login_rememberme" value="1" />
    <br /> <?php echo $tNGs->displayFieldError("custom", "kt_login_rememberme"); ?></td>
    </tr>
    <tr class="KT_buttons">
    <td colspan="2">
    <input type="submit" name="kt_login1" id="kt_login1" value="Login" />
    <br /></td>
    </tr>
    </table>
    <br />
    <a href="forgot_password.php">Forgot your password?</a>
    <br /></form>
    <br />
    <p>&#160;</p>
    <br />
    <br />

  • Help with windows Prcesses  - using "com.jniwrapper.win32.process.Process"

    Hi everybody,
    I'm trying to get a list of running processes, and for each process I need its Process ID, Process Name, and the command line that run this process.
    I found a way to get everything but the command-line, by JNI wrappers (below are links to their documentation).
    com.jniwrapper.win32.process.CurrentProcess (has the method - getCOmmanLine() ) :
    http://www.teamdev.com/downloads/jniwrapper/winpack/javadoc/com/jniwrapper/win32/process/Process.html -
    com.jniwrapper.win32.process.Process
    http://www.teamdev.com/downloads/jniwrapper/winpack/javadoc/com/jniwrapper/win32/process/Process.html
    I wrote the following code :
    String a, b;
    List processes = Process.getProcesses();
    for (int i = 0; i < processes.size(); i++) {
    Process process = (Process)processes.get(i);
    a = "process: FileName = " process.getProcessImageFileName();
    b = "id = " process.getProcessID();
    But I need to create an object of "CurrentProcess" (that extends Process class) in order to get the command-line. However, this class only has an empty constructor:
    CurrentProcess() - Creates an instance that corresponds to currently running process.
    and I don't understand what does "corresponds to currently running process" means (Cause there are many running processes) , and how to use it in my code.
    I would appreciate you help very much!
    Thanks,
    Nofar.
    Edited by: Nofarb on Jul 11, 2010 2:38 AM
    Edited by: Nofarb on Jul 11, 2010 2:41 AM

    I'm trying that as well, :)
    I was hoping maybe one of you have some experience with that.
    Thanks anyway.

Maybe you are looking for

  • My iphone 5c turned off and won't turn back on. What do I do?

    My iphone 5c turned off and won't turn back on. What do I do?

  • XMLBean schematypeloaderexception

    While parsing xml documents using XMLBean, i am getting the following exception: Exception in thread "main" org.apache.xmlbeans.SchemaTypeLoaderException: Simple type does not have a recognized variety (schemaorg_apache_xmlbeans.system.s95F62DC2B46C2

  • Not display a workitem type in UWL in portal

    Hi to all. I need that a type of workitem (TS.........) doesn't display in Portal inbox and display in SAP inbox. Now these workitems display in SAP inbox and in Portal inbox (UWL). Can anybody helps me? Thanks a lot.

  • Help needed with Network UI Element

    Hi,        I am trying to implement Network UI element. I've given an xml file in the mimes folder of the WD project and have provided it as the source for the network ui element's data source. While i run the application am not able to view the char

  • Olympus E 620 Orf Files

    I just changed cameras to an Olympus E 620. When I download the ORF (raw) pictures I have taken, I can not see them in either iPoto or Aperture. It tells me it is an unecognizable format.