How to create HTTPS or secure Socket objects in JDK 1.4?

I would like to see sample working code that shows creation
of Sockets objects that work with HTTPS using JDK 1.4. I am doing
a POST operation (form submission) on HTTPS URL. I must use Socket
objects and cannot use URLConnection (I know URLConnection solves the problem automatically in JDK 1.4).
Also sample code for POST operation would be appreciated.

I wrote this a little while ago to test out Secure Sockets in 1.4. I assume you are doing the client since you are trying talk to a website or something like that, anyway this test class is tested and works, but you will have to clean it up.
Pup
import java.io.*;
import java.security.*;
import javax.net.ssl.*;
public class HelloClientSSL {
    public static void main(String[] args) {
        try {
            int port = 8005;
            int tempport =0;
            if(args.length > 1) {
                try {
                    tempport = Integer.parseInt(args[1]);
                    port = tempport;
                catch (Exception e) {
                    System.out.println("Sorry this is not a valid number " + args[1]);
                    System.out.println("Using Default port 8005");
            Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());           
            SSLSocketFactory sslFact = (SSLSocketFactory)SSLSocketFactory.getDefault();
            SSLSocket s = (SSLSocket)sslFact.createSocket(args.length == 0 ? "127.0.0.1" : args[0], port);
            s.setEnabledCipherSuites(s.getSupportedCipherSuites());
            java.net.Socket n = (java.net.Socket) s;
            java.io.ObjectOutputStream OOS = new java.io.ObjectOutputStream(n.getOutputStream());
            BufferedReader in = new BufferedReader (new InputStreamReader(n.getInputStream()));
            String response = "";
            String temp = "This is reall cool and stuff\n";
            OOS.writeObject(temp);
            OOS.writeObject("Hello\n");
            while((response =in.readLine()) != null){
                System.out.println("Socket message: " + response);
            in.close();
        } catch (Exception e) {
            System.out.println("Exception" + e);
            e.printStackTrace();
}

Similar Messages

  • How to create Dialog Module[Screen,Menu,object navigator]

    Dear All,
                kindly give me. How to create Dialog Module[Object Navigator,Screen,Menu,] steps with code.

    please see this  link   it is with  screen shot from the scrach ...
    <b>creating  struture 
    creating screen
    writing logic 
    table control
    creating tcode</b>  ...etc
    <a href="http://">http://www.sapdevelopment.co.uk/dialog/tabcontrol/tc_basic.htm</a>
    reward  points if it is usefull ...
    Girish

  • How to create Database level Security in OBIEE

    Dear Experts,
    Can you kindly tell me the steps on how to create a database level security on OBIEE.
    Please can some one give me the scripts and tell me how to implement tht in the RPD.
    Thanks in advance,
    Anand

    If you are looking for Database Level security in OBIEE the only route to truly accomplishing this is using the Oracle Virtual Private Database concept.
    http://obieeblog.wordpress.com/2008/12/29/obiee-and-virtual-private-database-vpd/
    http://gerardnico.com/wiki/dat/obiee/vpd

  • Can anybody suggest me how to creat match code id and object

    hi Gurus,
    can any body suggest me how to create match code object and match code id..
    in my program i need specific values in search help..
    to avoid confusion in selecting the values.
    i need only selcted values..
    thanks in advance.
    vijay chavan

    Hi
    In Older SAP versions Match codes are used, now they are replaced by SEARCH HELPs
    there 2 types of search helps
    Elementary and Collective
    see the doc and create accordingly
    1) Elementary search helps describe a search path. The elementary search help must define where the data of the hit list should be read from (selection method), how the exchange of values between the screen template and selection method is implemented (interface of the search help) and how the online input help should be defined (online behavior of the search help).
    2) Collective search helps combine several elementary search helps. A collective search help thus can offer several alternative search paths.
    3)An elementary search help defines the standard flow of an input help.
    4) A collective search help combines several elementary search helps. The user can thus choose one of several alternative search paths with a collective search help.
    5)A collective search help comprises several elementary search helps. It combines all the search paths that are meaningful for a field.
    6)Both elementary search helps and other search helps can be included in a collective search help. If other collective search helps are contained in a collective search help, they are expanded to the level of the elementary search helps when the input help is called.
    CREATION:
    Go to SE11  Tcode
    select search help
    give the 'z' search help name and create
    select the selection method ur table name eg : 'mara'
    dialog module 'display value immediately'.
    add the field whatever u want and lpos = 1 and spos = 1 and check import and export parameter.
    where left position when displaying and spos = search position
    and then save and activate ..
    See the links:
    http://help.sap.com/saphelp_nw04/helpdata/en/cf/21ee38446011d189700000e8322d00/content.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/cf/21ee45446011d189700000e8322d00/content.htm
    https://forums.sdn.sap.com/click.jspa?searchID=3173469&messageID=2176485
    https://forums.sdn.sap.com/click.jspa?searchID=3173469&messageID=3601619
    pls go through this for search help creation
    http://help.sap.com/saphelp_nw2004s/helpdata/en/41/f6b237fec48c67e10000009b38f8cf/content.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/cf/21ee2b446011d189700000e8322d00/content.htm
    Search Help Exits:
    Re: dynamic values for search help
    Re: Dynamic search  help
    http://help.sap.com/saphelp_nw04/helpdata/en/cf/21ee52446011d189700000e8322d00/content.htm
    http://www.sapdevelopment.co.uk/dictionary/shelp/shelp_exit.htm
    https://forums.sdn.sap.com/click.jspa?searchID=4390517&messageID=1712818
    Collective search help Combine several elementary search helps. A collective search help thus can offer several alternative search paths.
    A Collective search help provides alternative search
    Paths by combining elementary search helps.
    Only one search help can be attached to a field, table or data element. Several search paths are therefore attached with a collective search help.
    A collective search help also has interface parameters like
    an elementary search help.
    Like an elementary search help, a collective search help has an interface of IMPORT and EXPORT parameters with which the search help exchanges data. Using this interface, the collective search help can be attached to fields, tables and data elements exactly like an elementary search help.
    Parameter assignment needs to be done for each of the
    Included search helps.
    When you define a collective search help, there are no components for describing the dialog behavior and data selection; instead the included search helps are listed here. You must assign the parameters of the collective search help to the interface parameters of the included search help for each inclusion.
    User may choose the tab and thus the elementary
    search maethod.
    When we execute the search help SCUSTOM, we are confronted with a dialog which gives us an option of either restricting
    By 1)Search for customer according to booking
    2)Search for customer according to name.
    These are effectively the elementary search helps (SCUSTOM_BOOK and SCUSTOM_NAME) which have been included in the collective search help SCUSTOM.
    HOT KEY
    The hot key is used to select the elementary search help from the collective search help and to enter the restrictions in the dialog box for restricting values directly from the entry field. If the user often searches for values using the same search help, this procedure can save time.
    Steps to create a Collective Search Help
    1)Enter the search help name and click on create.
    2)Choose Collective search help radio button option as the search help type.
    3)Enter the search help parameters.
    4)Instead of the selection method, we enter the included
    search helps for the collective search help.
    5)We need to assign parameters for each of the included
    search helps.
    6)Complete the parameter assignment by clicking on the push button
    7)Collective search help offers the user to obtain F4 help
    using any of the included search helps.
    Regards
    Anji

  • How to create event for BOR BUS2009 Object ?

    How to create a new event for BOR BUS2009 Object ?

    Hi,
    Please create a subtype for BOR BUS2009, say Z_BUS2009 and include your custom characteristic entities like Events, Methods, Key fields etc and finally do delegation. After delegation, all your custom changes reflects in BOR BUS2009.
    Regards,
    Prasanth

  • How to create XML string for an object matching the result of a marshal?

    I'm trying to create a XML string representation of an object which exactly matches the XML which results from marshalling the object into a request. I'm almost there except that the XML string I come up with is missing the attribute "standalone=\"yes\"" in the topmost xml element, and this attribute is present in the marshalled XML. I'm using the XML string to create a payload signature which must match exactly with the XML payload of the request, so the two XML representations of the object really do need to be identical.
    Here's what I'm doing to create the XML from the object:
       private String myObjectToXmlString (final MyObject myObject)
           throws Exception {
                 try {
               DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
               Document document = documentBuilder.newDocument();
               myObjectMarshaller.marshal(myObject, document);
               Source source = new DOMSource(document);
               StringWriter stringWriter = new StringWriter();
               Result result = new StreamResult(stringWriter);
               TransformerFactory factory = TransformerFactory.newInstance();
               Transformer transformer = factory.newTransformer();
               transformer.transform(source, result);
               return stringWriter.getBuffer().toString();
           } catch (Exception ex) {
               throw new Exception("Unable to convert a MyObject object to an XML String -- " + ex.toString(), ex);
       }The XML which is produced looks like this:
    <?xml version=\"1.0\" encoding=\"UTF-8\"?>
    <ns2:myObject xmlns:ns2=\"http://sunconnection.sun.com/xml\">
       <myObjectId>0</myObjectId>
       <objectType>1</objectType>
       <description>Test Object</description>
    </ns2:myObject>The payload object is marshalled to the request like so:
        // marshall the MyObject to the output stream
       OutputStream outputStream = myHttpUrlConnection.getOutputStream();
       myObjectMarshaller.marshal(myObject, outputStream);
       outputStream.flush();
       outputStream.close();When I view the XML payload of the request it looks like this:
    <?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>
    <ns2:myObject xmlns:ns2=\"http://sunconnection.sun.com/xml\">
       <myObjectId>0</myObjectId>
       <objectType>1</objectType>
       <description>Test Object</description>
    </ns2:myObject>As you can see the two XML representations of the object are identical except for the standalone attribute in the xml element.
    It'd be a hack to make the assumption that the standalone attribute will always be there in the marshalled object and to just hard code it into the XML string returned by my object to XML method. Since I'm using the same Marshaller to create the XML string as I am to perform the marshalling to the request I assume that there's some way to make it give the same XML in both cases, and that I'm doing something wrong in my method which converts the object to an XML string. If anyone can see where I'm going wrong in that method (myObjectToXmlString() above), or can suggest a better way of doing this, then I'll certainly appreciate the insight.
    --James                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    It turns out that I was taking the wrong approach in my object to XML string method. A cleaner/better way to do it, which gives the correct result, is this:
        private String myObjectToXmlString (final MyObject myObject)
            throws Exception {
            try {
                ByteArrayOutputStream stream = new ByteArrayOutputStream();
                myObjectMarshaller.marshal(myObject, stream);
                return stream.toString();
            } catch (Exception ex) {
                throw new Exception("Unable to convert a MyObject object to an XML String -- " + ex.toString(), ex);
        }--James                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How to create and instance of Java Object from an XML Document.

    Hi,
    How can we use a XML Document to create an instance of Java Object and do vice versa ie from the Java Object creating the XML Document.
    XML Document is available in the form of a String Object.
    Are there helper class available to achieve this.
    I need to do this in a Servlet.
    Regards
    Pramod.

    JAXB is part of JavaSE while Xmlbeans claims full schema support and full infoset fidelity.
    If the standard APIs do all that you need well then use them.

  • How to Create an XML using Abap Objects

    Hi there,
    who has an example how to create an XML Document from an internal table using abap objects
    e.g. Class CL_XML_DOCUMENT_BASE ?
    any feedback is welcome.
    thanks
    Johann

    Hi Johann,
    You don't need a class to do the job if you are on a 6.10 or higher system. Use command CALL TRANSFORMATION to create an XML from an internal table.
    Regards,
    John.

  • HTTPS support in socket object?

    Is there any support for HTTPS requests in the socket object? I know there is a BUNCH of data encryption that needs to go on and I'm not sure if indesign has anything built in to do so.

    Allan wrote:
    graysky wrote: Maybe Allan can do it in his spare time
    no need...  falconindy has already coded a switch from libfetch to libcurl.  https support will be there once that is finished.
    Oh man those pacman devs are so cool they just add features even if you don't want too 

  • How to create a listener for an Object.

    Can someone help me with creating a listener for an Object?
    What is the easiest way?
    For example... if I have the following class.... how could I set up a listener to know if "attribute1" value has changed?
    class MyObject {
    private int attribute1;
    private int attribute2;
    // Set the attribute
    public void setAttribute1(int num) {
    attribute1 = num;

    This can be done but depends on your situation. give me some more details about the program.
    In the worst scenario, u can set up a thread watching this variable to check for its previous value. if the value is different, u can get an alert.

  • How to create a universe in Business Object from BW

    Dear Memebers
    I need your help, I'm trying to create a report in business object using a cube as datasource, but when execute it does not appears the text, for example costumer 1000, his name is coca-cola.
    Does anyone help me?, maybe i does not set something
    Thanks a lot
    Ariel

    Hi Ariel,
    Not sure what BW is? If this is not related to using a SDK you may want to post your question in the Business Objects enterprise or Crystal Report Designer Forum.
    Thank you
    Don

  • How to create an array of an object,

    Hi,
    Trying this in Oracle 10.3 studio, I have to use a web service, I have re-catalogued the web service succesfully,
    I am getting compilation error whenI try to create an array of a object,
    Services.PackageTrackingService.PackageTrackingItem[] pkgTrackingItem = new Services.PackageTrackingService.PackageTrackingItem[2];
    I am giving the array size as 2,
    The comilation error is showing as
    Multiple markers at this line
    - statement is expected
    - Expecting ';' but 'pkgTrackingItem' was found
    - expression is expected
    Is there any other way to create the array?
    Thanks in advance.
    -Sree

    Hi,
    Please declare the array in following manner.
    Services.PackageTrackingService.PackageTrackingItem[] pkgTrackingItem;
    Now you can insert the element into the array by pkgTrackingItem[0], pkgTrackingItem[1] etc.
    Bibhu

  • How to create a Supplementary security domain

    Hi all, i am new to javaCard. i want to create a Supplementary security domain, but i have no idea.
    is it that i need to create an applet implements SecureChannel, then install the applet with the privileges 0x80(security domain)?
    is it right? Anybody any suggest? It would be really helpful.

    I've seen this if the database is down or in a funky state. Try shutting down BPEL, and restart the database, then bring BPEL back up. If you're using Oracle Lite just use the "Stop SOA Suite" GUI from the Start Menu.

  • How to create number range for custom object

    Hi all,
    I want to create number range for custom object or custom tables
    Thanks
    Hemalatha

    Hi,
       Thanks, I am able to create a number range for custom object through SNRO tcode.
    Thanks
    Hemalatha

  • How to create a new security group and assignments of rigths?

    Hi,
    In our current "Cisco Unified CM Administration System version: 7.0.1.11000-2" installation, we are a couple of administrators using the same user account to logon to the "https://10.10.x.x/ccmadmin/showHome.do" homepage.
    Where can I create a new user group and assign the appropriate rights to the group, and add users to the group? Or is it another approach that I need to follow instead of the way that security rights a made in a Microsoft Active Directory?
    Is there any place that I can read or view examples on how the setup can be done? I would like to have it in the way that everyone has their personal user account and use this to logon the administration-web page instead of an account that everyone uses.
    Kind regards,
    Carl-Marius

    why do you need to create a new business group? To implement HR? If so, linking a HR responsibility to your user, is one of the few steps to go anyway.
    How you did it on the test environment?
    Why not link a hr resp to your user temporarily, and disable it later.
    I'm always afraid to answer this kind of questions, since the real requirement is not described.

Maybe you are looking for

  • Parallel Ports vs. Trashing Printers

    Recently bought 3 new workstations:  2 w/Windows 7 - - 1 w/Windows XP Pro... Question is:  my old HP Laserjet 2100tn will not work with these computers due to their not being a paralel port on the back of the computer.   Do they make converters for t

  • Asset deletion

    Hi friends, i create an asset and it's value with AS91. now I need to delete it physically. When I delete it via AS06, the system disallowed it. But I found in the message "You may need to temporarily remove the setting of the indicator "recalculate

  • Automatic Workflow Customisation

    Hi, I have a question related to EHSM system configuration. I have read in a configuration document that during Automatic Workflow Customisation the following setting is required to be done. In SWU3 T Code, Under Maintain Defination Environment, ther

  • Build an ID CS4 project in snow leopard/lion

    Hi All, I got a new machine with leopard(10.6.7)  and xcode 3.2.5 installed when I tried to build a sample sdk project then it starts give me error of missing base sdk 10.4u I could change my SDK to 10.6 and GCC compiler to GCC 4.0 then it gives me e

  • HT4623 My IPad does not have the Airplay icon, can it be updated to get airplay or do I need to purchase a new IPad?

    My IPad does not have the Airplay icon.  Can it be updated to include this icon or do I need to buy a new IPad?