Salesforce API Login Authentication

package com.thysmichels;
import com.sforce.soap.enterprise.Connector;
import com.sforce.soap.enterprise.EnterpriseConnection;
import com.sforce.soap.partner.*;
import com.sforce.ws.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class SalesforceLogin {

	/**
	 * @param args
	 */
	

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		try
		{
			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			System.out.println("Enter Salesforce Username: ");
			String username = reader.readLine();
			System.out.println("Enter Salesforce Password: ");
			String password = reader.readLine();
			System.out.println("Enter Salesforce Security Token: ");
			String sectoken = reader.readLine();
			if (SFLogin(username, password, sectoken) == true)
			{
				System.out.println("*** Login Success ***");
			}
			else
			{
				System.out.println("*** Login Failure ***");
			}
		}
		catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
		}
		
	}
	public static boolean SFLogin(String username, String password, String sectoken)
	{
		
		try {
			
			ConnectorConfig sfconfig = new ConnectorConfig();
			//Use your salesforce username = email
		    sfconfig.setUsername(username);
		    //Use your saleforce password with your security token look like: passwordjeIzBAQKkR6FBW8bw5HbVkkkk
		    sfconfig.setPassword(password + sectoken);
		    EnterpriseConnection entercon = null;
		    sfconfig.setAuthEndpoint("https://login.salesforce.com/services/Soap/c/24.0");
		    entercon = new EnterpriseConnection(sfconfig);
		    if (entercon.login(username, password + sectoken).isPasswordExpired()== false)
		    {
		    	System.out.println("SessionID: " + sfconfig.getSessionId());
		    	System.out.println("Auth End Point: " + sfconfig.getAuthEndpoint());
		    	System.out.println("Service End Point: " + sfconfig.getServiceEndpoint());
		    	entercon.logout();
		    	return true;
		    }
		    else
		    {
		    	return false;
		    }
		   
		}
		   catch (ConnectionException ce) {

			      return false;
		   }
	}
}

Result

SessionID: 00DA0000000ao2F!ASAAQK5JbvhkfzbsYOG7_c9XFKauUzzw9HjB8IJ8r9W54IapCOmQk8AdK59u_O.Izd2hDtyXCDqbltlryV.MI3DKSagoIiUR
Auth End Point: https://login.salesforce.com/services/Soap/c/24.0
Service End Point: https://na10-api.salesforce.com/services/Soap/c/24.0/00DA0000000ao2F
*** Login Success ***

12 Comments on “Salesforce API Login Authentication”

  1. I getting error at import com.sforce.soap.enterprise
    Where to get jar file. I am not able to find exactly

  2. Golden, light and balanced, sunflower oil contains a lot more Vitamin E than any other vegetable oil. It is naturally extracted through sunflower seeds and has a subtle taste. Vegetable and plant based oils are cholesterol-free, low in saturated fats as well as rich in polyunsaturated fats. Sunflower oil, particularly, is rich in Vitamin E and omega 6 fats which makes it a healthy choice.
    Here are some incredible benefits of sunflower oil:

    1 . Promotes heart heath
    Sunflower oil has more than 80% of monounsaturated fats which makes it good for your personal heart. The impressive fatty acid content in sunflower acrylic helps in maintaining a balance within you. Furthermore, it does not contain any kind of saturated fats which help in governing the cholesterol levels in your body.

    2 . Good for your skin
    Sunflower oil is rich in Vitamin A new and Vitamin E which help in promoting skin health. These vitamin supplements act as antioxidants. They help in regenerating damaged skin tissues and getting rid of the acne breakouts causing bacteria. The oil is light and non-greasy and thus, it gets absorbed in the skin easily with no blocking the pores. Sunflower oil also acts as an organic moisturizer and helps in treating dry out, sensitive skin.

    3. Electricity booster
    While saturated fats can make you feel lethargic, unsaturated excess fat energize you. It helps the actual discharge of glycogen into the bloodstream from the liver. Glycogen is a type of sugar that delivers an extra boost of easy energy.

    4. Gives wonderful hair
    Sunflower oil really helps to soften dry, frizzy hair as well as adds a beautiful shine. Within the very light texture and also acts as a conditioner. You can massage it on your top of the head once a week for soft, smooth hair. Sunflower oil is likewise rich in gamma alpha linolenic acid (GLA) which stops hair loss and is often used for a treatment.

    5. Strengthens your current immune system
    Sunflower oil will be rich in antioxidants and also tones up the cell membrane boundaries which make it harder to get bacteria and viruses to enter the body. This increases the body’s ability to protect infections. Sunflower oil additionally contains protein that helps in building and repairing tissue and various enzymes needed for healthy functioning.

    6. Enhances digestion
    You may have not known but your cooking oil could be the cause of your digestive problems. A nutritious cooking oil is one which is rich in monounsaturated fats (MUFAs). Sunflower oil is extremely light source, easy to digest and considerably better absorbed in your digestive tract. Sunflower oil also has mild laxative properties which can help prevent obstipation.

    Read more https://kaissaoil.com/en/

  3. Это система вариаций была, но видно исказилась
    Существуетбольшое количество причин делать покупки в реальных магазинах. Это и оценка качества товара наглядно, и возможность примерки, и другие. Но если вопрос в сэкономить, заказать товар, которого нет в вашем регионе. Да что обсуждать, ассортимент в онлайн магазинах намного разнообразнее. Такжебольшинство из них дают возможность вернуть если товар не подошел. В общем сохраняют много времени на поездки по магазинам. Еще несколько аргументов в пользу интернет магазина можно прочитать в статье http://interesu.ru/index.php/vozmozhnosti-interneta/1161-pokupki-v-internete , Покупки в Интернете. А вы как считаете?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: