How to set a default trust store just for DirContext not the whole JVM

I need to connect to a secure LDAP server ( URL is ldaps://..../). The Server certificate in this LDAP server is a self signed cert so I need to put this certificate in my Keystore as well for me to connect to it.
My code is something like :
  DirContext ctx=null;
    Properties prop = .... ;
    // I set URL etc. in this.
    KeyStore ks = some_function_call();
    // save this keystore to file
    java.io.FileOutputStream fos =  new java.io.FileOutputStream("/tmp/newKeyStoreName.jks");
    char[] password = .....
    ks.store(fos, password);
    fos.close();
    // set this keystore as the default Keystore.
    System.setProperty("javax.net.ssl.trustStore", "/tmp/newKeyStoreName.jks");
    System.setProperty("javax.net.ssl.trustStorePassword", ...);
    System.setProperty("javax.net.ssl.trustStoreType", "jks");
    ctx = new InitialDirContext(prop);My problem is when I do a System.setProperty it makes it the default trust store for the whole JVM. I want a solution that would use this trust store only for the DirContext as I do not want this keystore to be used for other parts of my code. And its an MT application so setting keystore back to default one after this LDAP query gets over won't work.
I tried changing System.setProperty to props.put() it doesn't work.
Any ideas?

I have the same problem. I have to make 2 different SSL calls to 2 different 2 servers and if I set to System truststore and keystore properties I have a problem, 'cause those are different for each server.
I you have found the solution in the meanwhile, maybe you can write it here.
thanks,
Mihai

Similar Messages

  • How to set iPhone Bluetooth to be just for phone calls?

    Is there a way to setup an iPhone 4s/5, iOS 6, to use the bluetooth only for phone calls?
    I don't want music, youtube, google maps, or any app to go thru my car speakers. Phone calls work fine because the car will switch to Bluetooth audio automatically for those. I usually have my car audio set to radio so no apps are audible in the car unless I manually switch the car to Bluetooth Audio but then I can't listen to the radio.

    The only way around this, depending on the car system,
    is connect the iPhone to the unit via USB.
    At least with my Ford SYNC system, I can pair via
    Bluetooth and connect the USB and select USB audio
    on the Ford unit and in the Music app on the iPhone.
    Doing this, all phoner functions go via Bluetooth and
    everything else is over USB.
    Perhaps your car system supports something similar
    or not.  If it doesn't, there is nothing you can do.

  • Lg vista how do i turn off notification sound just for email not for texts

    Can not select notification off just for email

    Go to your Email (Accounts, setup), and set the notification options for email there:  (Page 108 of the user manual, Verizon LG G Vista User Manual / Guide
    NOTIFICATIONS
      Notifications: Checkmark to display new email notifications.
      Notifications sound: Tap to set the sound when you receive a new email
    notification.
      Vibrate: Tap to set when the phone will vibrate for a new email
    notification.

  • How to disable a single cell in a table (and not the whole column)

    Hi there,
    I've got a webdynpro table with a few columns, rows can be created dynamically through a button in the table toolbar.
    Depending on the value of a certain cell I have to disable another cell (in the same row).
    I tried to manipulate the view in the modifyview but no joy. I also tried to manipulate the attribute property through the coding below:
      DATA lv_knttp TYPE knttp.
      lo_nd_kostl = wd_context->path_get_node( path = `MULTIVALUES.KOSTL` ).
      lo_el_kostl = lo_nd_kostl->get_element( ).
      lo_el_kostl->set_attribute_property(
      attribute_name = 'LTEXT'
              property       = lo_el_kostl->e_property-enabled
              value          = ''
    but it disables the whole column!!!! I just need the cell to be disabled (I thought the code above, through the lead selection, would affect a certain cell only - but I was wrong).
    Any ideas?
    Thanks!!!

    Hi,
    using cell variants you can do this.,
    check this article: [Cell Variants in WDA|http://wiki.sdn.sap.com/wiki/display/WDABAP/WebDynproforABAPCellVariants]
    Instead of binding the read only property of table as a whole , just bind the read only property of column group of table., You can do this bu drill down the table and select the required column and bind the read only column.,
    then In onAction Event of button .,
    loop the table, if condition satisfied set the read only property to true else false.,!!
    hope this helps u.,
    Thanks & regards,
    Kiran

  • Can I just setup my pages for just one page not the whole document?

    I want to change my page to landscape but just one page not all document how can I do it.
    thank you

    May you take time to search for the keyword 'landscape' in the existing threads ?
    This question was asked and responded many times.
    Yvan KOENIG (VALLAURIS, France) dimanche 20 juin 2010 20:39:31

  • How to delete one perticular message from a user and not the whole messages

    hi
    i would like to know how can i delete a single message sent by a person and not the complete list of message received by me from the same person also how can i forward a message received by me

    beesani
    Sorry. ;( You can"t delete part of a message. You can only delete the entire message from that person.
    will2b

  • How to have a button to reset a field and not the whole form?

    Hi,
    Can anyone help me with this dilemma please? All tutorials online demonstrates how to have a button to reset the whole form, but i only want the user to clear 1 field in the form.
    I have a form which has a field representing a persons name who has booked out a piece of equipment. I would like the administrator to be able to clear the field quickly without having to select the whole name and then delete it, ready to insert the name of another booker.
    Any help would be very much appreciated. (If it is using dreamweaver features than that is better.)
    Thank you!

    There's nothing in DW that will do this for you.
    This script from the internet seems to do the trick. Add this to the <head> section of your page...
    <script type='text/javascript' src='http://code.jquery.com/jquery-1.7.1.js'></script>
    <script type='text/javascript'>//<![CDATA[
    $(window).load(function(){
    function resetForm() {
      $(this.previousSibling).val(function() {
      return this.defaultValue;
    $( "input[type='button']" ).bind( "click", resetForm );
    });//]]> 
    </script>
    Then add your form in the <body>...
    <form>
      <label for="textfield1">Text Field:</label>
      <input type="text" name="textfield1" id="textfield1"><input type="button" value="reset" /><br />
      <label for="textfield2">Text Field:</label>
      <input type="text" name="textfield2" id="textfield2"><input type="button" value="reset" /><br />
      <label for="textfield3">Text Field:</label>
      <input type="text" name="textfield3" id="textfield3"><input type="button" value="reset" /><br />
      <label for="textfield4">Text Field:</label>
      <input type="text" name="textfield4" id="textfield4"><input type="button" value="reset" /><br />
    </form>
    EDIT: Ha! Same script as you found Nancy, posted originally at the exact same time too (I threw a couple modifications in)...
    Good times, good times.

  • Backing up just few albums, not the whole library

    Is there a way to create a backup DVD of just selected albums (like a playlist) and afterwards get them back to library with all the info remaining?
    I tried creating a Data DVD and some info (rating, play count..) burns to DVD, but play count resets when they're imported back to library. Artwork is also gone.

    Rich
    Yes there is. You want to use a back up utility that will do incremental back ups. Chronosync and DejaVu are two such, but there are others. Search on MacUpdate.
    Regards
    TD

  • Some of my macbook pro keys are getting dim, how can i fix these select keys because it is not the whole keyboard?

    It is mainly the "i, o, p, k, and l" keys.

    yes. Here: https://expresslane.apple.com/GetproductgroupList.do?PRKEYS=SG1

  • HT1351 Only want to see sync songs/artists/albums on iPod touch (not the whole library in iTunes). How to do it?

    I only want to see on iPod touch songs/artists/albums manually selected for sync (not the whole library in iTunes). How to do it? Not sync titles appear in grey colour...

    So if I understand you correctly, you want to be able to sync only certain songs, artists, and albums correct? If so you can configure this set up from under the iPod's Music configuration tab in iTunes as described in the Syncing Automatically section in the Apple support document you linked in at the top of the page.  Note that you cannot select only certain songs, but you can set it up to sync selected Artists, Genres, and Albums.
    If the tab and its configurations are grayed out, it is likely because your iPod is set up for manual management, meaning the manually manage music and videos option is enabled from under the iPod's Summary tab.
    B-rock

  • How to Set A Default Start Time For New Events In Calendar?

    How to Set A Default Start Time For New Events In Calendar?

    John,
    Thanks for that suggestion - could not get it to work. However, I did manage a different approach. I finally determined the sequence of events in terms of how the various events and listeners fire (I think).
    Basically, the CalendarActivityListener fires, followed by the listener associated with the Calendar object's Create facet, followed finally by the CalendarEventListener - the final is where the TriggerEvent is available and then finally, control is passed to the popup/dialog in the Create facet. So, my approach of trying to set/get the TriggerDate in the user's HTTP session was doomed to failure because it was being get before it had been set :(
    Anyway, I ended up adding a bit of code to the CalendarEvent listener - it grabs the current BindingContext, navigates through the DCBindingContainer to derive an Iterator for the ViewObject which drives the calendar and then grabs the currently active row. I then do a few tests to make sure we're working with a "new" row because I don't want to alter start & end dates associated with an existing calendar entry and then I define the Start and End dates to be the Trigger Date.
    Works just fine. Snippet from the listener follows
    BindingContext bindingContext = BindingContext.getCurrent();+
    *if ( bindingContext != null )    {*+
    DCBindingContainer dcBindings = (DCBindingContainer) bindingContext.getCurrentBindingsEntry();+
    DCIteratorBinding iterator = dcBindings.findIteratorBinding("EventsView1Iterator");+
    Row currentRow = iterator.getCurrentRow();+
    if ( currentRow.getAttribute("StartDate") == null)+
    currentRow.setAttribute("StartDate", calendarEvent.getTriggerDate());+
    if (currentRow.getAttribute("EndDate")==null)+
    currentRow.setAttribute("EndDate", calendarEvent.getTriggerDate());+
    *}*

  • How to set a Default Value in the drop down on Account Creation ?

    Hi,
    i have to set a default value in the drop down as soon as a User in a particular business role clicks on New Account. I have written the following code in do_prepare_output method. But this code is executed in the 2nd server round trip after entering some value or pressing enter. so i am not getting as soon as user clicks on the New Account.
    How to set that default value when user clicks on New Account ? and where should i code ?
      IF lv_icwc_profile = 'ZCSALESPRO' or lv_icwc_profile = 'Z_SALESPRO' .
      try.
                  lr_entity ?= me->typed_context->header->collection_wrapper->get_current( ).
                  lv_current = lr_entity->create_related_entity(
                                                  iv_relation_name = 'BuilRolesRel' ).
                                 lv_current->set_property(
                                    iv_attr_name = 'PARTNERROLE'
                                    iv_value     =  'BUP002' ).
                   CATCH cx_sy_ref_is_initial cx_sy_move_cast_error
                   cx_crm_genil_model_error.
                   return.
            ENDTRY.
    Thanks and Regards
    Raman Khurana

    Hi,
    I have some idea abt it, it is also used in account life cycle.
    Please refer SAP note 1097651, Defaulting a life cycle stage.
    Let me know if useful.
    rgds,
    Vinay

  • How  to set a Default Value  in Combobox

    Dear All,
    I want to set a default value in a combobox  when open the form. How can I set that?
    Default value : It is one of the options of the combobox.

    Im doing it as
      If BusinessObjectInfo.FormTypeEx = "150" And BusinessObjectInfo.BeforeAction = False And BusinessObjectInfo.EventType = SAPbouiCOM.BoEventTypes.et_FORM_DATA_LOAD Then
                oForm = SBO_Application.Forms.GetFormByTypeAndCount(BusinessObjectInfo.FormTypeEx, 1)
                Dim vepcombo As SAPbouiCOM.ComboBox
                Dim vepitem As SAPbouiCOM.Item
                vepitem = oForm.Items.Item("24")
                If vepitem.Enabled = True Then
                     vepcombo = vepitem.Specific
                    vepcombo.Select(10, SAPbouiCOM.BoSearchKey.psk_Index)
                End If
            End If

  • How to set a default value in Select one choice.

    Hi
    I'm using ADF BC, in that how to set a default value in select one choice.
    pls. help on this.
    regards

    set the default value on the underlying EO or VO attribute
    john

  • How to set a default value to t-list when creating t-list programmatically

    hi,
    I'm creating a t-list programmatically
    by calling
    n = populate_group('groupname');
    populate_list('form.list','groupname');
    In this case how to set a default value for the t-list
    thanks
    rani

    I am not sure how it works in Web Dynpro for ABAP, but in Web Dynpro for Java to set default drop down value you will have to set the value for particular attribute (which is linked to the dropdown element)  in the context
    like
    wdContext.currentContext<nodeName>Element.set<FieldName>(<defalut value>)
    This generally done in Initialization method of the controller.

Maybe you are looking for