Showing posts with label Java. Show all posts
Showing posts with label Java. Show all posts

Wednesday, July 18, 2018

Enable TLS 1.1 & TLS 1.2 in Java JDK

Starting from Java JDK 1.8. XX versions TLS 1.1 & TLS 1.2 is enabled by default.

But, what if you are in JDK 1.7. XX versions you will have to go enable them explicitly.

How you do it? One way is that you can enable from Java Control panel console.

Windows

Navigate to JAVA_HOME\jre\bin folder and execute javacpl.exe from command prompt.

Linux:

 Navigate to JAVA_HOME\jre\bin folder and execute ./ControlPanel from terminal.

This will render Java control panel console. Click on Advanced tab and scroll down where you see Advanced Security settings section.

Select the check boxes associated with "Use TLS 1.1" & "Use TLS 1.2" then click Apply and OK.

Thanks
Siva Pokuri.

Wednesday, September 21, 2016

How to develop Oracle Virtual Directory 11g Custom Plugin

There are times where out-of-box OVD functionality is no sufficient for client requirements. We may need to write some custom plugins which will extend the OVD functionality.

I'm about to write a post on this but it seems like there is excellent post from Oracle A-team.

http://fusionsecurity.blogspot.com/2013/08/creating-custom-ovd-plugin.html

And

https://ranxing.wordpress.com/2015/05/14/how-to-write-ovd-custom-plugin/

Based on the requirement you may need to extend the BasePlugin class methods.

Example:

1. postSearchEntry() is the method implementation to manipulate any search results.

2. get() is the method if needed to manipulate the search criteria even before it talks to backend DS.

Hope this helps.

-- Siva Pokuri.


Sample code of OAAM 11g API code to get user challenge questions


import com.bharosa.client.BharosaHelper;
import com.bharosa.client.BharosaSession;
import com.bharosa.client.enums.BharosaEnumAuthStatus;
import com.bharosa.client.enums.BharosaEnumChallengeResult;
import com.bharosa.vcrypt.auth.impl.VCryptAuthSOAPImpl;
import com.bharosa.vcrypt.auth.intf.VCryptAuthResult;
import com.bharosa.vcrypt.auth.intf.VCryptAuthUser;
import com.bharosa.vcrypt.auth.intf.VCryptLocalizedString;
import com.bharosa.vcrypt.auth.intf.VCryptQuestion;
import com.bharosa.vcrypt.common.util.VCryptResponse;
import com.bharosa.vcrypt.tracker.util.CookieSet;
import com.bharosa.vcryptclient.proxy.intf.BharosaProxy;

public class OAAMCQuestions {

/**
* @param args
*/
public static void main(String[] args) {
OAAMCQuestions ocqv =  new OAAMCQuestions();
ocqv.getUserChallengeQuestions();

}
public void getUserChallengeQuestions(){
String username = "spokuri";
try {
            VCryptAuthSOAPImpl auth = new VCryptAuthSOAPImpl();

            VCryptAuthUser user = new VCryptAuthUser();

            BharosaProxy proxy = BharosaProxyImpl.getInstance();
           
            String customerID = proxy.getUserByLoginId(username).getCustomerId();
           
            System.out.println("customerID " + customerID);
           
            user = proxy.getUser(customerID);
           
           
            user = proxy.getUserByLoginId(customerID);
           
            VCryptQuestion secretQuestion = proxy.moveToNextSecretQuestion(customerID);
           
            System.out.println("Secret Question " + secretQuestion);
           
            VCryptQuestion[] secretQuestion1 = proxy.getAllMappedSignOnQuestions(customerID);
           
            String q1 = secretQuestion1[0].toString();
            System.out.println("Question 1" + q1);
            String q2 = secretQuestion1[1].toString();
            System.out.println("Question 2" + q2);
            String q3 = secretQuestion1[2].toString();
            System.out.println("Question 3" + q3);
                       
           
        } catch (Exception e) {
            e.printStackTrace();
        }
       
         
    }



}

Friday, July 1, 2016

OAAM 11g R2 PS3 Secondary email OTP configuration with custom challenge processor

Hello Readers,

Steps to configure secondary email as OTP:

Demo video: http://www.idmfun.com/2016/07/oaam-11g-r2-ps3-secondary-email-otp_1.html

1. Create custom challenge processor.

2. Create a class which extends "AbstractUMSOTPChallengeProcessor" as shown below.

import com.bharosa.uio.processor.challenge.AbstractUMSOTPChallengeProcessor;
import com.bharosa.uio.util.UIOSessionData;
import com.bharosa.uio.util.UIOUtil;
import java.util.ArrayList;
import java.util.List;
import oracle.ucs.messaging.ws.types.Address;
import oracle.ucs.messaging.ws.types.DeliveryType;

public class Email2ChallengeProcessor extends AbstractUMSOTPChallengeProcessor
{
   protected List<Address> getRecipients(UIOSessionData sessionData) 
   {
       String toAddress = UIOUtil.getContactInfo(sessionData, "email2");
       Address recipientAddr = getAddress(toAddress, DeliveryType.EMAIL);

       List<Address> retList = new ArrayList<Address>();
       retList.add(recipientAddr);

       return retList;
    }

}

3. Build jar file with the above java class file and place it in oracle.oaam.extensions.war lib folder.

4. Add below list of properties in oaam_custom.properties file in oracle.oaam.extensions.war

# Second Email Address Input Registration Field Properties Example
bharosa.uio.default.userinfo.inputs.enum.email2=2002
bharosa.uio.default.userinfo.inputs.enum.email2.name=Email Address 2
bharosa.uio.default.userinfo.inputs.enum.email2.description=Email Address 2
bharosa.uio.default.userinfo.inputs.enum.email2.inputname=email2
bharosa.uio.default.userinfo.inputs.enum.email2.inputtype=text
bharosa.uio.default.userinfo.inputs.enum.email2.maxlength=40
bharosa.uio.default.userinfo.inputs.enum.email2.required=true
bharosa.uio.default.userinfo.inputs.enum.email2.order=2
bharosa.uio.default.userinfo.inputs.enum.email2.enabled=true
bharosa.uio.default.userinfo.inputs.enum.email2.regex=.+@[a-zA-Z_]+?\.[a-zA-Z.]+
bharosa.uio.default.userinfo.inputs.enum.email2.errorCode=otp.invalid.email
bharosa.uio.default.userinfo.inputs.enum.email2.managerClass=com.bharosa.uio.manager.user.DefaultContactInfoManager
bharosa.uio.default.userinfo.inputs.enum.email2.verify=true
#bharosa.uio.default.userinfo.inputs.enum.email2.displaymask=.{1,2}(.*)@([a-zA-Z_]+)?\.[a-zA-Z]{2,3}

# Second Email Address Challenge OTP Field Properties Example
bharosa.uio.default.challenge.type.enum.ChallengeEmail2=2003
bharosa.uio.default.challenge.type.enum.ChallengeEmail2.available=true
bharosa.uio.default.challenge.type.enum.ChallengeEmail2.description=Challenge Email 2
bharosa.uio.default.challenge.type.enum.ChallengeEmail2.displayedInfo=email2
bharosa.uio.default.challenge.type.enum.ChallengeEmail2.enabled=true
bharosa.uio.default.challenge.type.enum.ChallengeEmail2.htmlInputType=text
bharosa.uio.default.challenge.type.enum.ChallengeEmail2.htmlLabel=Email Code
bharosa.uio.default.challenge.type.enum.ChallengeEmail2.name=Email Challenge2
bharosa.uio.default.challenge.type.enum.ChallengeEmail2.otp=true
bharosa.uio.default.challenge.type.enum.ChallengeEmail2.otpexpirytimeMs=400000
bharosa.uio.default.challenge.type.enum.ChallengeEmail2.processor=Email2ChallengeProcessor
bharosa.uio.default.challenge.type.enum.ChallengeEmail2.requiredInfo=email

# Rule action for ChallengeEmail2
rule.action.enum.ChallengeEmail2=1091
rule.action.enum.ChallengeEmail2.name=Challenge Email 2
rule.action.enum.ChallengeEmail2.description=Challenge the user using Email

rule.action.enum.ChallengeEmail2.otp=true

5. Redeploy oracle.oaam.extensions.war file in both oaam admin & oaam server managed servers.

6. Login to OAAM admin console

7. Navigate to Groups and click on "OAAM Challenge Choice" and click on "Actions" tab.

8. Add newly created action called "Challenge Email 2".

9. Now, login to TAP protected application by registering new user with 2 OTP email addresses.

10. Test login with user account who registered primary & secondary email address.

-- Siva Pokuri.

Tuesday, September 15, 2015

OAAM 11g API code to create & configure security questions for user


import java.util.ArrayList;
import java.util.List;

import com.bharosa.vcrypt.auth.intf.*;
import com.bharosa.vcrypt.auth.util.VCryptAuthUtil;
import com.bharosa.vcrypt.common.util.VCryptResponse;

import com.bharosa.vcryptclient.proxy.exception.BharosaProxyException;
import com.bharosa.vcryptclient.proxy.intf.BharosaProxy;

/**
 * @author pokuri
 *
 */
public class CreateUser {

private BharosaProxy proxy = null;

public static void main(String[] args)
{
CreateUser cu = new CreateUser();
String response = null;
try
{
response = cu.createUser("pressi", "Default");
//response = cu.checkQuestionsStatus("siva.pokuri");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("RESPONSE " + response);
}
   
    public String checkQuestionsStatus(String userName)
    {
    VCryptAuthUser user = null;

    System.out.println("Checking user: " + userName);
    user = new VCryptAuthUser();

user.setLoginId(userName);

try {

System.out.println("Questions Status " + user.getRegistrationStatus());

} catch (Exception e) {
System.out.println("Exception " +e);
return "QA_STATUS_CHECK_FAILED";
}
return "CHECKED_QA_STATUS";
    }
   
public String createUser(String userName, String primaryGroupName)
{
proxy = BharosaProxySingleton.getProxyInstance();

// try to find the user record in OAAM
   VCryptAuthUser user = null;

   System.out.println("Creating user: " + userName);
   user = new VCryptAuthUser();
   
   try{
    user.setLoginId(userName.trim());
   }
   catch (Exception e) {
System.out.println("Exception " + e);
}
   user.setCustomerId(userName.trim());

   user.setCustomerGroupId(primaryGroupName.trim());
   try
   {
    user = proxy.createUser(user);
   }
catch (Exception e)
{
System.out.println("Exception " +e);
return "CREATE_USER_FAILED";
}
proxy.setUser(user);

int status = proxy.getUserStatus(userName.trim());

System.out.println("User Status  before Security Questions ---- >> " + status);

String questionId1 = "41";
String questionText1 = "Who was your childhood hero?";
String answer1 = "pilot1";
String questionId2 = "42";
String questionText2 = "What is the name of your favourite childhood teacher?";
String answer2 = "pilot2";
String questionId3 = "43";
String questionText3 = "What was your dream job as a child?";
String answer3 = "pilot";
     
VCryptQuestion question1 = new VCryptQuestion();
VCryptQuestion question2 = new VCryptQuestion();
VCryptQuestion question3 = new VCryptQuestion();

List<String> answerList = new ArrayList<String>();
List<String> answerList1 = new ArrayList<String>();
List<String> answerList2 = new ArrayList<String>();

question1.setQuestionId(new Long(questionId1.trim()));
question1.setQuestion(questionText1.trim());
answerList.add(answer1.trim());
question1.setAnswerList(answerList);

question2.setQuestionId(new Long(questionId2.trim()));
question2.setQuestion(questionText2.trim());
answerList1.add(answer2.trim());
question2.setAnswerList(answerList1);
     
question3.setQuestionId(new Long(questionId3.trim()));
question3.setQuestion(questionText3.trim());
answerList2.add(answer3.trim());
question3.setAnswerList(answerList2);
     
try
{
VCryptAuth auth = VCryptAuthUtil.getVCryptAuthInstance();
VCryptAuth auth1 = VCryptAuthUtil.getVCryptAuthInstance();
VCryptAuth auth2 = VCryptAuthUtil.getVCryptAuthInstance();

VCryptResponse vr = null;
VCryptResponse vr1 = null;
VCryptResponse vr2 = null;

vr = auth.addQuestion(userName.trim(), question1);
vr1 = auth1.addQuestion(userName.trim(), question2);
vr2 = auth2.addQuestion(userName.trim(), question3);

System.out.println("Response Code " + vr.getResponseCode());
System.out.println("Response Code " + vr1.getResponseCode());
System.out.println("Response Code " + vr2.getResponseCode());

System.out.println("Successfully Created User & configured Sequrity questions");

proxy.setUserStatus(userName.trim(), 2);

System.out.println("User "+userName+" Status -->>"+proxy.getUserStatus(userName.trim()));

}
catch (Exception e)
{
System.out.println("Create user failed!!!! " + e);
}
return "CREATE_USER_SUCCESS";
}


}

-- Siva Pokuri