Showing posts with label JSP. Show all posts
Showing posts with label JSP. Show all posts

Wednesday, August 16, 2017

Github: unexpected news


It's a great day for me. It's turned out that someone uses my Github repositories.
While ago I've created an Oracle-free version of FOP servlet for Apex application reports. The reason why I've created the code was simple. Naturally, I've blogged all the details and it's one of the most visited publications of mine. At the same time, servlet repository has not been used at all or I used to think so. Now I know that at least one more person, who has found this project useful. Please meet Roger Pilkey, who is so kind that he has adopted my doodles and developed new servlet for the latest Apache FOP version.
After such unexpectable and invaluable input, I have to upgrade project itself.  The major changes are:
  • Project structure has been reconfigured to use with the Apache Maven 
  • JSP page uses the latest FOP code to generate PDF response
  • Lifted index.html (with a brief description and sample form to test application)
  • Updated README.md with some project information. 
I guess it's hard to find the Apex installation with no Oracle REST Database Services installed, but if you are the happy owner of such system - you may find it useful. 

Friday, January 16, 2015

OAM 11.1.2.2.0 Custom Login Form

Good afternoon to everyone,

Today I share fresh finding and hope it'd help you t save time and keep your mind (I've almost lost mine). 
It costs me couple days of hard harvesting and log analysis, I had  to create a simple application to check session status. 

After successful Oracle OAM and Tivoli Access Manager (TAM) integration (I'm going to post it sometimes) developement team faced next challenge. Due security reasons we have no access to TAM server so federation works only for external clients.  To provide access for both teams I used new OAM 11.1.2.2.0 feature - Advanced Authentication Policy Rules.  We decided to separate authentication schemes by browser type.  So if user's accessing protected resource with Google Chrome browser OAM uses local form-based authentication scheme otherwise request will be redirected to federation plug (TAM SSO). 
Screenshot below shows advanced rule edit form. 


Simple but effective way to build two factor or more sophisticated resource protection schemes. Detailed description and samples could be found in OAM documentation here.
So far so good,identity federation works, advanced rules works like a charm, custom forms appears and works as expected but result is very well known to everyone who deals with OAM/Webgates.


After log analyze and brainstorming I realized authentication doesn't match with authentication request. It means there is something wrong with login application. It's somewhat confused because the very same application works with OAM 11gR1. 
I'd skip logs mining, documentation sift and JSP analyze descriptions so   there is a gem:
For previous OAM versions  was quite enough to send request id with username and password. OAM 11.1.2.2.0 requires authentication token. Unfortunately our login page send request_id only and code below show how it has to be (additional lines in red).

 <!-- skipped JSP & HTML header -->  
 <%  
 String reqId = null;  
 String reqToken = null;  
 if( reqId == null && request.getAttribute( GenericConstants.REQUEST_ID ) != null )  
      {  
           reqId = ( String )request.getAttribute( GenericConstants.REQUEST_ID );  
      }  
      reqId = CSSUtil.escapeHtmlFull( reqId );  
     reqToken = request.getParameter(GenericConstants.AM_REQUEST_TOKEN_IDENTIFIER);  
 %>  
 <form id="loginData" action="/oam/server/auth_cred_submit" method="post" name="loginData" >  
 <!-- Skipped form declaration and decoration -->  
   <input name="<%=GenericConstants.REQUEST_ID%>" value="<%=reqId%>" type="hidden"/>  
   <input type="hidden" name="<%=GenericConstants.AM_REQUEST_TOKEN_IDENTIFIER%>" value="<%=reqToken%>" type="hidden"/>  
 </form>  
 <!-- skipped JSP & HTML footers -->  

Now it works  and if your have login form with token already you will never face this issue.
If not read my post and save time for upcoming l-o-o-o-ong beautiful weekend.

Enjoy and take care.


Friday, April 25, 2014

Gather session Information.

Hi there,

I will not be original, not share inventions or hot insider information. But this trinket could save your time.
There is a very simple yet nice looking servlet to show you full HTTP session state. Believe me, sometime  it's not easy when developer tools in Chrome or *Fox will not tell you truth show you encoded data only.
Personally, I use that for debug and troubleshoot identity management configurations.
It would be useful for any Single Sign-On protected resources.  Right now I'm using it to validate identity federation authentications.

There is a screenshot:
OAM headers visible only from inside session.
I hardly name this minimalist JSP page with couple standard java classes an application but there is a source code.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ page contentType="text/html;charset=windows-1252"%>
<%@ page import="javax.servlet.http.Cookie" %>
<%@ page import="java.util.Map" %>
<%@ page import="java.util.Enumeration" %>

<html>
 
<head>
   
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"/>
   
<title>index</title>
   
<style type="text/css" >
        #thdr {
           
background-color: rgb(32,48,255);font-weight: 600;
           
color: white;
           
font-family: sans-serif;
        }
        #content {
           
width: 70%;
           
margin: 0 auto;
           
background-color: rgb(236,236,236);
        }
       
th {
           
text-align: left;
           
font-size: small;
           
font-family: sans-serif;
           
background-color: Silver;
            word-wrap:break-word
        }
       
td {font-size: small; word-wrap:break-word}
       
table {
            
border-spacing: 0px;
            
border-width: 0px;
            
width: 99.5%;
            
table-layout: fixed;
        }
       
body {
           
background-color: rgb(158,158,158);
        }
   
</style>
 
</head>
 
<body>
   
<div align="center" id="content">
     
<h2><strong>Session information </strong></h2>
   
<hr/>
   
<h4>Session Cookies</h4>
   
<% Cookie[] ccs = request.getCookies(); %>
   
<table id="CookieTbl" cellspacing="2" cellpadding="3" border="1" width="100%">
     
<tr ><th width="268" id="thdr">Name</th><th width="872" id="thdr">Value</th></tr>
    
<% for (int i=0;i<ccs.length;i++) {%>
     
<tr><th width="268"><%= ccs[i].getName()%></th><td width="872"><%=ccs[i].getValue()%></td></tr>
    
<% }%>
   
</table>
   
<p/>
   
<h4>Request Headers</h4>
   
<% Enumeration hdrs = request.getHeaderNames(); %>
   
<table id="RequestHdr" cellspacing="2" cellpadding="3" border="1" width="100%">
     
<tr id="thdr"><th width="268" id="thdr">Name</th><th width="872" id="thdr">Value</th></tr>
     
<% String hdr=null;
        
while(hdrs.hasMoreElements()){ hdr=hdrs.nextElement().toString();%>
         
<tr>
             
<th width="268"><%=hdr%></th>
             
<td width="872"><%= request.getHeader(hdr)%></td>
         
</tr>
     
<%}%>
   
</table>
   
<p/>
   
<h4>Request Parameters</h4>
   
<% Map<String,String[]> params = request.getParameterMap(); %>
   
<table id="RequestPrm" cellspacing="2" cellpadding="3" border="1"
          
width="100%">
     
<tr id="thdr"><th width="268" id="thdr" height="26">Name</th><th width="872" id="thdr"
                                                                      
height="26">Value</th></tr>
     
<% for (Map.Entry<String,String[]> param : params.entrySet()){ %>
     
<tr><th width="268" rowspan="<%=param.getValue().length%>">
         
<%= param.getKey()%></th>
         
<td width="872"><%= param.getValue()[0]%></td></tr>
         
<% for (int i=1;i<param.getValue().length;i++) {%>
             
<tr><td width="872"><%=param.getValue()[i]%></td></tr>
         
<%}%>
     
<%} %>
   
</table>
   
<hr/>
   
</div>
 
</body>
</html>
And if you use JDeveloper there is ready to project.

Save time for life and have a good weekend,