<%@  page pageEncoding="utf-8" contentType="text/html;charset=utf-8" import="com.novell.webaccess.common.JSPConduit, 
																			 com.novell.emframe.dev.*,
																			 com.novell.admin.ns.AdminNamespace,
																			 com.novell.admin.ns.ObjectAttribute,
																			 com.novell.admin.ns.ValueComponent,
																			 com.novell.application.console.snapin.ObjectEntry,
																			 com.novell.nps.utils.Utils" %>
<%@ taglib uri="/WEB-INF/iman.tld" prefix="iman" %>
<%   JSPConduit c = JSPConduit.getJSPConduit(request);
   c.stringTable("DevResources");
   c.stringTable("BaseResources"); %>

<HTML>
<HEAD>
   <TITLE><%= c.string("ProductName") %></TITLE>

   <jsp:include page='<%= c.getPath("dev/eMFrameScripts_inc.jsp") %>' flush="true" />
   <jsp:include page='<%= c.getPath("dev/XmlScripts_inc.jsp") %>' flush="true" />
   <jsp:include page='<%= c.getPath("dev/ValidateIntegerScripts_inc.jsp") %>' flush="true" />

   <LINK rel='stylesheet' href='<%= c.getModulesUrl() + "/dev/css/hf_style.css" %>'>
   <jsp:include page='<%= c.getPath("dev/PageScripts_inc.jsp") %>' flush="true" />
   <jsp:include page='<%= c.getPath("dev/eMFrameScripts_inc.jsp") %>' flush="true" />
   <jsp:include page='<%= c.getPath("dev/OSScripts_inc.jsp") %>' flush="true" />
   
   <SCRIPT language="JavaScript">
	
      <%-- ---------------------------------------------------- --%>
      <%-- isPageValid                                          --%>
      <%-- called when user leaves this page or applys changes  --%>
      <%-- ---------------------------------------------------- --%>
      function isPageValid()
      {
          //nothing to do on this page
          return true;
      }
      
      <%-- Used to launch the set password task --%>
      function setPassword()
      {
         window.open("frameservice?NPService=fw.LaunchService&NPAction=Launch&launch=base%2eKeplerSetPassword&launcher=fw.LaunchService&lifecycle=new&targetNames=<%= c.urlEncode(c.var("eDir$target")) %>", "", "toolbar=no,location=no,directories=no,menubar=no,scrollbars=yes,resizable=yes,width=550,height=400");
      }               

   </SCRIPT>
</HEAD>

<BODY>
   <jsp:include page='<%= c.getPath("dev/Messagebar_inc.jsp") %>' flush="true" />
	<jsp:include page='<%= c.getPath("dev/BookVars_inc.jsp") %>' flush="true" />

         
   <TABLE class="marginleft1" border="0" bgcolor='#FFFFFF' cellpadding="0" cellspacing="0">

      <%-- ----------------------- --%>
      <%-- Password Quality Policy --%>
      <%-- ----------------------- --%>
      <%
		      MContext taskContext = eMFrameFactory.getMContext(request);
		   
		      ObjectEntry treeOE = (ObjectEntry) taskContext.getAuthenticationBroker().getProtocolObject(AuthenticationBroker.PROTOCOL_ADMINNAMESPACE);
		      AdminNamespace ns = (AdminNamespace) treeOE.getNamespace(); 
		      ObjectEntry objectEntry = null;
		      ObjectAttribute policyAttr = null;
		      ObjectAttribute[] PQPAttrs = null;
	      	  ValueComponent[] vc = null;
		      ObjectAttribute tempAttr;
		      String[] attrNames = {"pwdMinNumLowerCaseLetters",
									"pwdMinNumSpecialChars",
									"pwdMinNumNumbers",
									"pwdMinNumUpperCaseLetters",
									"pwdMinLength",
									"pwdMaxLength"};
		      try
		      {
		      	 //get the object entry of the current target
		         objectEntry = ns.getObjectEntry(eMFrameUtils.unpack(c.var("eDir$target"), taskContext)[0]);
		         
		         //now get the value of the login policy attribute
		         policyAttr = ns.getAttribute(objectEntry, "pwdQualPolicyAdministrativeArea");
		         vc = policyAttr.getBeginningComponents();
			     StringBuffer policyDN = new StringBuffer();
		         for(int iv=0; iv<vc.length; iv++)
		         {
		            policyDN.append(vc[iv].toString());
		         }
		         
		         //the password quality policy attribute contains a DN to a policy object
		         //now we need to get the actual policy object
		         objectEntry = ns.getObjectEntry(policyDN.toString());
		         
		         //finally, get the policy data from the policy object attributes
		         //specifically named in the attrNames array  and print them out
		         PQPAttrs = ns.getAttributes(objectEntry, attrNames);
		         for(int i=0; i<PQPAttrs.length; i++)
	             {
	                tempAttr = PQPAttrs[i];
	                out.println("<tr><td><div class='margintop1'>&nbsp;</div></td></tr>");
	                out.println("<tr><td class='mediumtext'>"+c.string("Password."+tempAttr.getName())+":&nbsp;&nbsp;</td>");
	                vc = tempAttr.getBeginningComponents();
	                out.print("<td class='mediumtext'>");
	                for(int j=0; j<vc.length; j++)
	                {
	            	   out.print(vc[j].toString());
	                } 
	                out.println("</td></tr>");
	             }
		      }
		      catch(Exception e)
		      {
		   	     D.log("Unable to find a password quality policy");
		   	     out.print(c.string("Password.noAppliedPolicy"));
		      }
            %>
      <TR>
         <TD>
            <div class='margintop1'>&nbsp;</div>
         </TD>
      </TR>
      <TR>
         <TD>
            <a href="javascript:setPassword()"><%= c.string("SetPassword") %></a>
         </TD>
      </TR>
   </TABLE>
   <IFRAME src="/nps/Empty.html" style="visibility: hidden" name="dateFrame" id="dateFrame" width="0" height="0" marginwidth="0" marginheight="0"></IFRAME>
    
</BODY>
</HTML>

