Commonly used ADF security expressions
and security APIs in the UI layer
The commonly used security expressions and corresponding ADF security APIs are
as follows:
Accessing logged in username: The following EL expression can be used for
accessing the authenticated username: #{securityContext.userName}.
The following code snippet illustrates how to use the ADF security API for
the purpose of accessing an authenticated username:
SecurityContext securityCtx = ADFContext.getCurrent().
getSecurityContext();
String loggedInUserName=securityCtx.getUserName();
Is the user authenticated: The following EL expression returns true if the
user is authenticated: #{securityContext.authenticated}.
The following is a code sample for the purpose of reading the authentication
status for the current user:
SecurityContext securityCtx = ADFContext.getCurrent().
getSecurityContext();
Boolean isUserAutheticated = securityCtx.isAuthenticated();
validation.jsp
<html>
<body>
<h2 align="center"> Validating UserName and Password </h2>
<%
String str1=request.getParameter("t1");
String str2=request.getParameter("t2");
if(str1.equalsIgnoreCase("sanjivani") && str2.equals("<password>") // can write extra code to fetch the password from backend
{
out.println("<h3>Welcome,Sanjivani!!!</h3>");
}
else
{
out.println("<h3>Sorry,You're Not Sanjivani</h3>")
}
%>
</body>
</html>
<html>
<body>
<h2 align="center"> Validating UserName and Password </h2>
<%
String str1=request.getParameter("t1");
String str2=request.getParameter("t2");
if(str1.equalsIgnoreCase("sanjivani") && str2.equals("<password>") // can write extra code to fetch the password from backend
{
out.println("<h3>Welcome,Sanjivani!!!</h3>");
}
else
{
out.println("<h3>Sorry,You're Not Sanjivani</h3>")
}
%>
</body>
</html>
No comments:
Post a Comment