Sunday, March 22, 2015

How to enable SSL debug tracing in Weblogic Server?

How to enable SSL debug tracing in Weblogic Server?

Add the following start up options to the start up file startWebLogic.cmd/startWebLogic.sh or startManagedWebLogic.cmd/startManagedWebLogic.sh based on which file is used to start the server to enable SSL debug tracing in Weblogic Server.

JAVA_OPTIONS="${JAVA_OPTIONS} -Dweblogic.debug.DebugSecuritySSL=true -Dweblogic.debug.DebugSSL=true -Dweblogic.StdoutDebugEnabled=true -Dweblogic.log.StdoutSeverityLevel=Debug -Dweblogic.log.LogSeverity=Debug"



Invocation of https/SSL service is not working from OSB

Invocation of https/SSL service is not working from OSB

We were trying to install the wildcard certificate to enable the communication from OSB to end system, but the following exception was displayed in the log file and also the communication to the end system is failing even though the certificate installation was successful;

<Jan 23, 2015 10:45:05 PM PST> <Notice> <Security> <localhost> <AdminServer> <[ACTIVE] ExecuteThread: '12' for queue: 'weblogic.kernel.Default (self-tuning)'> <<anonymous>> <> <bac54c313ca42523:46f5522b:14b61066510:-7ffd-000000000008b798> <1423456801909> <BEA-090898> <Ignoring the trusted CA certificate "CN=*.sample.com,O=Sample,L=Sample,ST=Sample,C=US". The loading of the trusted certificate list raised a certificate parsing exception PKIX: Unsupported OID in the AlgorithmIdentifier object: 1.2.840.113549.1.1.11.> 
After analysis, we found that JSSE flag should be enabled along with Custom Host Name Verification (weblogic.security.utils.SSLWLSWildcardHostnameVerifier) to support wildcard certificate.

ssl_config

 After enabling the JSSE flag, none of the https communication from OSB is working but https communication from BPEL is working fine even with the wildcard certificate(BPEL and OSB is running in the same server).

The following exception is thrown while invoking the https service from OSB.

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<soapenv:Fault>
<faultcode>soapenv:Server</faultcode>
<faultstring>
BEA-380000: General runtime error: java.lang.NullPointerException
</faultstring>
<detail>
<con:fault xmlns:con="http://www.bea.com/wli/sb/context">
<con:errorCode>BEA-380000</con:errorCode>
<con:reason>
General runtime error: java.lang.NullPointerException
</con:reason>
<con:location>
<con:node>RouteToSFDC_SearchService_BS</con:node>
<con:path>request-pipeline</con:path>
</con:location>
</con:fault>
</detail>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>

This is the internal OSB server issue; the cause of the issue is that the AsyncResponseHandler does not properly register JSSEFilter for JSSE SSL.
The Weblogic patch 11866509 based on the Weblogic server version (this issues is identified in Weblogic server version 10.3.4 and 10.3.5) should be installed to resolve the issue.


Saturday, March 14, 2015

How to get the UserInfo through Java API in AEM/Adobe CQ5

How to get the UserInfo through Java API in AEM/Adobe CQ5

The below Java API helps to get the UserInfo details in Adobe Experience Manager(AEM)
@Reference
ResourceResolverFactory resolverFactory;

ResourceResolver adminResolver = null;
try {
       adminResolver = resolverFactory.getAdministrativeResourceResolver(null);
       final Session adminSession = adminResolver.adaptTo(Session.class);
       final UserManager userManager = adminResolver.adaptTo(UserManager.class);
       final User user = (User) userManager.getAuthorizable(adminSession.getUserID());
         
       logger.info("user.getID().."+user.getID());
       logger.info("user.isAdmin().."+user.isAdmin());
       logger.info("user.getPrincipal().getName().."+user.getPrincipal().getName());

       String lastName=user.getProperty("./profile/familyName")!=null?user.getProperty("./profile/familyName")[0].getString():null;
     String firstName=user.getProperty("./profile/givenName")!=null?user.getProperty("./profile/givenName")[0].getString():null;
     String aboutMe=user.getProperty("./profile/aboutMe")!=null?user.getProperty("./profile/aboutMe")[0].getString():null;
     String email=user.getProperty("./profile/email")!=null?user.getProperty("./profile/email")[0].getString():null;
   
     logger.info("lastName.."+lastName);
     logger.info("firstName.."+firstName);
     logger.info("aboutMe.."+aboutMe);
     logger.info("email.."+email);
         
       Iterator<Group> itr=user.memberOf();
       while(itr.hasNext())
       {
         Group group=(Group)itr.next();
          logger.info("group.getID().."+group.getID());
           logger.info("group.getPrincipal().getName().."+group.getPrincipal().getName());
        }        
                             
} catch (Exception e) {
        e.printStackTrace();
} finally {
       if (adminResolver != null) adminResolver.close();
}


Thursday, March 12, 2015

Browser cookie values are not setting in IE10 and IE11

Browser cookie values are not setting in IE10 and IE11

While trying to set the cookies in IE10 and IE11 through Java, the values are not stetting in the browser.

The code snippet used to set the cookie is

cookie = new javax.servlet.http.Cookie(cookieHeaderName,"Sample Cookie");
cookie.setPath("/");
ookie.setMaxAge(365*24*60*60);
cookie.setSecure(false);
cookie.setVersion(0);
response.addCookie(cookie);

After long struggle we found the issue might be with the value of Expires is not set, IE10 and IE11 expecting the value for Expires and it is not considering the value set in Max-Age.

Fix for the issue - Use the below code to set the cookie value

int expiration = 365*24*60*60;
StringBuilder cookieString = new StringBuilder("TestCookie=Test; ");

DateFormat df = new SimpleDateFormat("EEE, dd-MMM-yyyy HH:mm:ss 'GMT'", Locale.US);
Calendar cal = Calendar.getInstance();
cal.add(Calendar.SECOND, expiration);
cookieString.append("Expires=" + df.format(cal.getTime()) + "; ");
//cookieString.append("Domain="+request.getServerName()+"; ");
cookieString.append("Version=0; ");
cookieString.append("Path=/; ");
cookieString.append("Max-Age=" + expiration + "; ");
cookieString.append("HttpOnly");
response.addHeader("Set-Cookie", cookieString.toString());



Sunday, March 8, 2015

How to connect to oracle database using datasource pool from OSGI- Adobe Experience Manager(AEM)

How to connect to oracle database using datasource pool from OSGI- Adobe Experience Manager(AEM)

This post will explain how to connect to oracle database using datasource pool from Adobe Experience Manager(AEM)

Convert the JDBC driver to OSGI bundle:

In eclipse - File-->New-->Plug-in Development-->Plug-in from Existing JAR Archives
Click on Add External and Select the JDBC jar file

osgi_bundle

Click Next and enter the required details

Project name - OracleDriver
Plug-in ID - com.jdbc.oracle
Plug-in vendor - Oracle
Select the Execute Environment
Select an OSGi framework and select standard
Un-Select Unzip the JAR archives into the project and select Update references to the JAR files.



Tuesday, March 3, 2015

How to Customize/Configure the 404 error handler for multi sites in AEM/Adobe CQ5?

How to Customize/Configure the 404 error handler for multi sites in AEM/Adobe CQ5?

This post will explain how to configure the 404 error handler in multi site scenario for Adobe Experience Manager(AEM) - This will configure different 404 pages for different sites..

If the error handler is configured for first time then copy /libs/sling/servlet/errorhandler to /apps/sling/servlet (create the folder structure before copying )

Modify /apps/sling/servlet/errorhandler/404.jsp file to modify the 404 error handling rules.

<%  
//setting response code as 404
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
try {
    String uri = request.getRequestURI();
         
    if(uri.matches("(/content/Sample/en/)(.*)"))
    {
        pageContext.include("/content/Sample/en/404.html");
    } else if(uri.matches("(/content/Sample/es/)(.*)"))
    {
        pageContext.include("/content/Sample/es/404.html");
    } else if(uri.matches("(/en/)(.*)"))
    {
        pageContext.include("/content/Sample/en/404.html");
    }
    else if(uri.matches("(/es/)(.*)"))
    {
        pageContext.include("/content/Sample/es/404.html");
    } else
    {
        pageContext.include("/content/Sample/en/404.html");
    }

} catch (Exception e) {

%>
        Page Not Found
<%
}

%>

The conditions can be added to handle different sites, if the sites are running on different virtual host names then get the server name from the request
(request.getServerName()) and add the condition based on the server name.

This will redirect the user to site specific 404 pages.


How to find the Email Group Id in Eloqua?

 How to find the Email Group Id in Eloqua? 

This post will explain  how to find the Email Group Id in Eloqua

There will be different approach to find the Email Group id. Here. This post explains the approach used by me.
Use any of the REST client(here i am using Advance Rest Client)

Provide the below URL - https://secure.p03.eloqua.com/API/REST/1.0/assets/email/groups

Select the Http Method as GET

Provide the Authorization header

Authorization: Basic xxxxxxxxxxx

Replace xxxxxxxxxxx with base64 encoded string of companyName\userName:password

Send the request

The response will have all the Email Group id details - id and name of the Emial group can be found in the response.

{
  elements: [2]
  0:  {
         type: "ContactEmailSubscription"
         contactId: "1"
         emailGroup: {
             type: "EmailGroup"
             id: "1"
            depth: "minimal"
            description: ""
            name: "Sample1"
            permissions: "fullControl"
            updatedAt: "1423758721"
           updatedBy: "1"
        }
       isSubscribed: "true"
       updatedAt: "1423219686"
   }
  1:  {
         type: "ContactEmailSubscription"
         contactId: "1"
         emailGroup: {
             type: "EmailGroup"
             id: "2"
            depth: "minimal"
            description: ""
            name: "Sample2"
            permissions: "fullControl"
            updatedAt: "1423758721"
           updatedBy: "1"
        }
       isSubscribed: "true"
       updatedAt: "1423219686"
   }
  page: 1
 pageSize: 1000
 total: 2
}