Maven: install jar into repository

install a jar into repository

	
		mvn install:install-file -Dfile={ORACLE_HOME}/jdbc/lib/ojdbc6.jar -Dpackaging=jar\ -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.1.0

Then in your pom.xml file just include the newly added jar:

	
		<dependency>
		 <groupId>com.oracle</groupId>
		 <artifactId>ojdbc6</artifactId>
		 <version>11.1.0</version>
		</dependency>

WebSphere Portal: Access Page Parameters from Portlet

I had a scenario where I wanted to retrieve certain WebSphere Page parameters that are setup on a page.
This occurred because we had a Portal Page and a Virtual Portal Page using the same Portlet, and
we wanted certain business logic to be applied depending upon the parameter setup via the admin console
for each of the respective pages.

I do not in any way admit to knowing exactly what is going on below here. It took a long time to
search the web and find this piece of information, and I hope someone else finds it here faster then
it took me to find it.

public Map retrieveStringsFromPageParameters(PortletRequest req, PortletResponse resp, List pageParamsToRetrieve){
Map toRet = null;
try{
Context ctx = new InitialContext();

PortletServiceHome psh = (PortletServiceHome) ctx.lookup("portletservice/" + NavigationSelectionModelProvider.class.getName());

if (psh != null) {
ContentMetaDataModelProvider cmdmProvider = (ContentMetaDataModelProvider) psh.getPortletService(ContentMetaDataModelProvider .class);
ContentMetaDataModel cmdm = cmdmProvider.getContentMetaDataModel(req, resp);
NavigationSelectionModelProvider provider = (NavigationSelectionModelProvider) psh.getPortletService(NavigationSelectionModelProvider.class);
NavigationSelectionModel model = provider.getNavigationSelectionModel(req, resp);
NavigationNode selectedNode = (NavigationNode) model.getSelectedNode();

if (selectedNode != null) {
MetaData md = cmdm.getMetaData(selectedNode);

if(md != null){
toRet = new HashMap();
for(Iterator itr = pageParamsToRetrieve.iterator(); itr.hasNext(); ){
String pageParamToGet = (String) itr.next();
String pageParamValue = (String)md.getValue(pageParamToGet);

toRet.put(pageParamToGet, pageParamValue);
}
}
}
}
}catch (Exception e){
logger.debug(e);
}
return toRet;
}

Get DistinguishedName from LTPA Cookie

This code will grab the DistinguishedName from the LTPA Cookie, but you can retrieve anything else you need as well.
I used this code within a Custom Tag that I created.


public static synchronized String getDistinguishedNameFromLtpaCookie(HttpServletRequest req){
Cookie[] cookies = req.getCookies();
String cookieVal = null;

if(null != cookies) {
for(int i = 0; i &amp;lt; cookies.length; i++) {
if(cookies[i].getName().equalsIgnoreCase(LTPA_TOKEN)) {
cookieVal = cookies[i].getValue();
break;
}
}
}

String uniqueId = null;
String distinguishedName = null;

try{
byte[] cookieBytes = com.ibm.websphere.security.WSSecurityHelper.convertCookieStringToBytes(cookieVal);
uniqueId = com.ibm.wsspi.security.token.WSSecurityPropagationHelper.validateLTPAToken(cookieBytes);
distinguishedName = com.ibm.wsspi.security.token.WSSecurityPropagationHelper.getUserFromUniqueID(uniqueId);
} catch(Exception e){
System.out.println(&quot;UserDomainLookupTag.doStartTag(): Exception occurred while retrieving LTPA cookie: &quot; + e);
}

return distinguishedName;
}

The required WebSphere jars:

– wssec.jar
– sas.jar


your code here

Websphere Portal: Reference Custom Tag in Theme

This is for WebSphere Portal v6.0

(do a google search if you do not know how to create a Tag)

Put your custom jar that contains the Tag classes in:
/opt/IBM/WebSphere/PortalServer/shared/app

Put your TLD files in:
/opt/IBM/WebSphere/AppServer/profiles/<profile>/installedApps/<node>/wps.ear/wps.war/WEB-INF/tld

What I do not understand is how the tld is read. I would have expected to have to register the TLD
in some web.xml file, but that is not the case here. So WebSphere has to be doing this in the background somewhere.

Restart your Portal server, and you can now reference your tag from within your theme.

One HUGE drawback of this solution is that you have to restart the Portal server
if you make an update to your TLD or Tag jar and push them out to their
respective locations.