How to connect to the specific app during Bluetooth connection

Hi  I am using the nrf51422_XXAC device. I want to make a connection with my app alone. other apps should not be able to connect. please help me with sample code. I am new to the device 

what I need is that only after opening the app I should connect to the device via Bluetooth that too to my app alone, like have a private key or so.

I have tried adding the code 
static ble_opt_t optS;

static uint8_t passw[]="123456";

optS.gap_opt.passkey.p_passkey=passw;

err_code =sd_ble_opt_set(BLE_GAP_OPT_PASSKEY, &optS);
APP_ERROR_CHECK(err_code);

and mode to "BLE_GAP_CONN_SEC_MODE_SET_ENC_WITH_MITM" . 

the problem is during paring, the device asks for a passkey. but connection inside app goes without a passkey