InputStream file = null;  boolean buttoncancel = false;
boolean buttoncancel = false;
    public String parseRequest(HttpServletRequest request) throws AuthorizationDeniedException{      String includefile = "publisherspage.jsp"; 	  String publisher = null;	  PublisherDataHandler handler  = cabean.getPublisherDataHandler();	          String action = null;	  InputStream file = null;	  	        boolean buttoncancel = false;              	  action = request.getParameter(ACTION);	  if( action != null){		if( action.equals(ACTION_EDIT_PUBLISHERS)){								  if( request.getParameter(BUTTON_EDIT_PUBLISHER) != null){			 publisher = request.getParameter(SELECT_PUBLISHER);			 if(publisher != null){			   if(!publisher.trim().equals("")){				   includefile="publisherpage.jsp";				   this.publishername = publisher;				   this.publisherdata = handler.getPublisher(publishername);			   } 			   else{ 				publisher= null;			  } 			}			if(publisher == null){   			  includefile="publisherspage.jsp";     			}		  }		  if( request.getParameter(BUTTON_DELETE_PUBLISHER) != null) { 			  publisher = request.getParameter(SELECT_PUBLISHER);			  if(publisher != null){				if(!publisher.trim().equals("")){      					        					publisherdeletefailed = handler.removePublisher(publisher);          				}			  }			  includefile="publisherspage.jsp";             		  }		  if( request.getParameter(BUTTON_RENAME_PUBLISHER) != null){ 			 // Rename selected publisher and display profilespage.		   String newpublishername = request.getParameter(TEXTFIELD_PUBLISHERNAME);		   String oldpublishername = request.getParameter(SELECT_PUBLISHER);		   if(oldpublishername != null && newpublishername != null){			 if(!newpublishername.trim().equals("") && !oldpublishername.trim().equals("")){			   try{				 handler.renamePublisher(oldpublishername.trim(),newpublishername.trim());			   }catch( PublisherExistsException e){				  publisherexists=true;			   }			 }		   }      		   includefile="publisherspage.jsp"; 		  }		  if( request.getParameter(BUTTON_ADD_PUBLISHER) != null){			 publisher = request.getParameter(TEXTFIELD_PUBLISHERNAME);			 if(publisher != null){			   if(!publisher.trim().equals("")){          				 try{				   handler.addPublisher(publisher.trim(), new LdapPublisher());				 }catch( PublisherExistsException e){				   publisherexists=true;				 }             			   }      			 }			 includefile="publisherspage.jsp"; 		  }		  if( request.getParameter(BUTTON_CLONE_PUBLISHER) != null){		   String newpublishername = request.getParameter(TEXTFIELD_PUBLISHERNAME);		   String oldpublishername = request.getParameter(SELECT_PUBLISHER);		   if(oldpublishername != null && newpublishername != null){			 if(!newpublishername.trim().equals("") && !oldpublishername.trim().equals("")){            			   try{ 				 handler.clonePublisher(oldpublishername.trim(),newpublishername.trim());			   }catch(PublisherExistsException e){				   publisherexists=true;			   }			 }		   }      			  includefile="publisherspage.jsp"; 		  }		}		if( action.equals(ACTION_EDIT_PUBLISHER)){			 // Display edit access rules page.		   publisher = request.getParameter(HIDDEN_PUBLISHERNAME);		   if(publisher != null){			 if(!publisher.trim().equals("")){			   if(request.getParameter(BUTTON_SAVE) != null ||			   	  request.getParameter(BUTTON_TESTCONNECTION) != null){		             				 if(publisherdata == null){               				   String tokentype = request.getParameter(HIDDEN_PUBLISHERTYPE);				   if(tokentype.equals(TYPE_CUSTOM))					 publisherdata = new CustomPublisherContainer();				   if(tokentype.equals(TYPE_LDAP))					 publisherdata = new LdapPublisher();				   if(tokentype.equals(TYPE_AD))				   	publisherdata = new ActiveDirectoryPublisher();				 }				 // Save changes.                    				 // General settings   				 String value = request.getParameter(TEXTAREA_DESCRIPTION);				 if(value != null){                              				   value = value.trim();				   publisherdata.setDescription(value); 				 }				 								 				 				 				 if(publisherdata instanceof CustomPublisherContainer){				   value = request.getParameter(TEXTFIELD_CUSTOMCLASSPATH);				   if(value != null){                              				 	 value = value.trim();				 	 ((CustomPublisherContainer) publisherdata).setClassPath(value); 				   }				   value = request.getParameter(TEXTAREA_CUSTOMPROPERTIES);				   if(value != null){                              				   	value = value.trim();				   	((CustomPublisherContainer) publisherdata).setPropertyData(value); 				   }				   				 }  				 if(publisherdata instanceof LdapPublisher){				 	LdapPublisher ldappublisher = (LdapPublisher) publisherdata;				 	value = request.getParameter(TEXTFIELD_LDAPHOSTNAME);				 	if(value != null){                              				 		value = value.trim();				 		ldappublisher.setHostname(value); 				 	}				 	value = request.getParameter(TEXTFIELD_LDAPPORT);				 	if(value != null){                              				 	  value = value.trim();				 	  ldappublisher.setPort(value); 				 	}				 	value = request.getParameter(TEXTFIELD_LDAPBASEDN);				 	if(value != null){                              				 		value = value.trim();				 		ldappublisher.setBaseDN(value); 				 	}				 	value = request.getParameter(TEXTFIELD_LDAPLOGINDN);				 	if(value != null){                              				 		value = value.trim();				 		ldappublisher.setLoginDN(value); 				 	}				 	value = request.getParameter(PASSWORD_LDAPLOGINPASSWORD);				 	if(value != null){                              				 		value = value.trim();				 		ldappublisher.setLoginPassword(value); 				 	}				 	value = request.getParameter(TEXTFIELD_LDAPUSEROBJECTCLASS);				 	if(value != null){                              				 		value = value.trim();				 		ldappublisher.setUserObjectClass(value); 				 	}				 	value = request.getParameter(TEXTFIELD_LDAPCAOBJECTCLASS);				 	if(value != null){                              				 		value = value.trim();				 		ldappublisher.setCAObjectClass(value); 				 	}				 	value = request.getParameter(TEXTFIELD_LDAPUSERCERTATTRIBUTE);				 	if(value != null){                              				 		value = value.trim();				 		ldappublisher.setUserCertAttribute(value); 				 	}				 	value = request.getParameter(TEXTFIELD_LDAPCACERTATTRIBUTE);				 	if(value != null){                              				 		value = value.trim();				 		ldappublisher.setCACertAttribute(value); 				 	}				 	value = request.getParameter(TEXTFIELD_LDAPCRLATTRIBUTE);				 	if(value != null){                              				 		value = value.trim();				 		ldappublisher.setCRLAttribute(value); 				 	}				 	value = request.getParameter(TEXTFIELD_LDAPARLATTRIBUTE);				 	if(value != null){                              				 		value = value.trim();				 		ldappublisher.setARLAttribute(value); 				 	}                    value = request.getParameter(CHECKBOX_LDAPUSESSL);					if(value != null)                              					  ldappublisher.setUseSSL(value.equals(CHECKBOX_VALUE));					else					  ldappublisher.setUseSSL(false);                    value = request.getParameter(CHECKBOX_LDAPCREATENONEXISTING);					if(value != null)                              					  ldappublisher.setCreateNonExisingUsers(value.equals(CHECKBOX_VALUE));					else					  ldappublisher.setCreateNonExisingUsers(false);                    value = request.getParameter(CHECKBOX_LDAPMODIFYEXISTING);					if(value != null)                              					  ldappublisher.setModifyExistingUsers(value.equals(CHECKBOX_VALUE));					else					  ldappublisher.setModifyExistingUsers(false); 			 	                        String[] values = request.getParameterValues(SELECT_LDAPUSEFIELDINLDAPDN);				    if(values != null){				 	  ArrayList usefields = new ArrayList();				 	  for(int i=0;i< values.length;i++){				 	    usefields.add(new Integer(values[i]));					 	  }				 						 					 	  ldappublisher.setUseFieldInLdapDN(usefields); 				    }				 }				 if(publisherdata instanceof ActiveDirectoryPublisher){                   ActiveDirectoryPublisher adpublisher = (ActiveDirectoryPublisher) publisherdata;				 	value = request.getParameter(SELECT_ADSAMACCOUNTNAME);				 	if(value != null){                              				 		value = value.trim();				 		adpublisher.setSAMAccountName(Integer.parseInt(value)); 				 	}				 	value = request.getParameter(TEXTFIELD_ADUSERDESCRIPTION);				 	if(value != null){                              				 		value = value.trim();				 		adpublisher.setUserDescription(value); 				 	}                    value = request.getParameter(CHECKBOX_ADUSEPASSWORD);					if(value != null)                              					  adpublisher.setUseUserPassword(value.equals(CHECKBOX_VALUE));					else					  adpublisher.setUseUserPassword(false);				 	value = request.getParameter(SELECT_ADUSERACCOUNTCONTROL);				 	if(value != null){                              				 		value = value.trim();				 		adpublisher.setUserAccountControl(Integer.parseInt(value)); 				 	}                                                          				 }             				 				 				 if(request.getParameter(BUTTON_SAVE) != null){				   handler.changePublisher(publisher,publisherdata);									   includefile="publisherspage.jsp";				 }				 if(request.getParameter(BUTTON_TESTCONNECTION)!= null){				 	connectionmessage = true;				 				 	handler.changePublisher(publisher,publisherdata);				 	try{				 	  handler.testConnection(publisher);				 	  connectionsuccessful = true;				 	}catch(PublisherConnectionException pce){				 	  connectionerrormessage = pce.getMessage();					 	}				 	includefile="publisherpage.jsp";				 }				 			   }			   if(request.getParameter(BUTTON_CANCEL) != null){				  // Don't save changes.				 includefile="publisherspage.jsp";			   }			 }		  }		}				if( action.equals(ACTION_CHANGE_PUBLISHERTYPE)){	      this.publishername = request.getParameter(HIDDEN_PUBLISHERNAME);		  String value = request.getParameter(SELECT_PUBLISHERTYPE);		  if(value!=null){        			int profiletype = Integer.parseInt(value);			switch(profiletype){          			  case CustomPublisherContainer.TYPE_CUSTOMPUBLISHERCONTAINER :				publisherdata = new CustomPublisherContainer();				break;			  case LdapPublisher.TYPE_LDAPPUBLISHER :				publisherdata =  new LdapPublisher();				      				break;  					  case ActiveDirectoryPublisher.TYPE_ADPUBLISHER :				publisherdata =  new ActiveDirectoryPublisher();				      				break;  					}   		  }		  includefile="publisherpage.jsp";		}							  }      	          return includefile;	    }