Professional Documents
Culture Documents
com.sun.rave.web.ui.appbase.AbstractPageBean;
java.sql.Date;
java.sql.Time;
com.sun.webui.jsf.component.Button;
com.sun.webui.jsf.component.PasswordField;
com.sun.webui.jsf.component.TextField;
consish.ConAuditoria;
consish.ConOpciones;
consish.ConRegModulos;
consish.ConRegPerfiles;
consish.ConUsuarios;
java.net.InetAddress;
java.net.UnknownHostException;
javax.faces.FacesException;
javax.faces.context.FacesContext;
javax.faces.event.ValueChangeEvent;
sish.Invopciones;
sish.Invregmodulos;
sish.Invregperfiles;
sish.Invusuarios;
sishweb.RequestBean1;
sishweb.SessionBean1;
sishweb.ApplicationBean1;
/**
* <p>Page bean that corresponds to a similarly named JSP page. This
* class contains component definitions (and initialization code) for
* all components that you have defined on this page, as well as
* lifecycle methods and event handlers where you may add behavior
* to respond to incoming events.</p>
*
* @version Login.java
* @version Created on 20/02/2012, 11:33:25 AM
* @author LC
*/
public class Login extends AbstractPageBean {
// <editor-fold defaultstate="collapsed" desc="Managed Component Definition"
>
/**
* <p>Automatically managed component initialization. <strong>WARNING:</str
ong>
* This method is automatically generated, so any user-specified code insert
ed
* here is subject to being replaced.</p>
*/
private void _init() throws Exception {
}
private Button btnIngresar = new Button();
public Button getBtnIngresar() {
return btnIngresar;
}
public void setBtnIngresar(Button b) {
this.btnIngresar = b;
}
private Button btnCancelar = new Button();
public Button getBtnCancelar() {
return btnCancelar;
}
public void setBtnCancelar(Button b) {
this.btnCancelar = b;
}
private PasswordField pswLogin = new PasswordField();
public PasswordField getPswLogin() {
return pswLogin;
}
public void setPswLogin(PasswordField pf) {
this.pswLogin = pf;
}
private TextField txtUsuario = new TextField();
public TextField getTxtUsuario() {
return txtUsuario;
}
public void setTxtUsuario(TextField tf) {
this.txtUsuario = tf;
}
// </editor-fold>
/**
* <p>Construct a new Page bean instance.</p>
*/
public Login() {
}
/**
* <p>Callback method that is called whenever a page is navigated to,
* either directly via a URL, or indirectly via page navigation.
* Customize this method to acquire resources that will be needed
* for event handlers and lifecycle methods, whether or not this
* page is performing post back processing.</p>
*
* <p>Note that, if the current request is a postback, the property
* values of the components do <strong>not</strong> represent any
* values submitted with this request. Instead, they represent the
* property values that were saved for this view when it was rendered.</p>
*/
@Override
public void init() {
// Perform initializations inherited from our superclass
super.init();
// Perform application initialization that must complete
// *before* managed components are initialized
// TODO - add your own initialiation code here
</editor-fold>
Perform application initialization that must complete
*after* managed components are initialized
TODO - add your own initialization code here
}
/**
* <p>Callback method that is called after the component tree has been
* restored, but before any event processing takes place. This method
* will <strong>only</strong> be called on a postback request that
* is processing a form submit. Customize this method to allocate
* resources that will be required in your event handlers.</p>
*/
@Override
public void preprocess() {
}
/**
* <p>Callback method that is called just before rendering takes place.
* This method will <strong>only</strong> be called for the page that
* will actually be rendered (and not, for example, on a page that
* handled a postback and then navigated to a different page). Customize
* this method to allocate resources that will be required for rendering
* this page.</p>
*/
@Override
public void prerender() {
}
/**
* <p>Callback method that is called after rendering is completed for
* this request, if <code>init()</code> was called (regardless of whether
* or not this was the page that was actually rendered). Customize this
* method to release resources acquired in the <code>init()</code>,
* <code>preprocess()</code>, or <code>prerender()</code> methods (or
* acquired during execution of an event handler).</p>
*/
@Override
public void destroy() {
}
/**
* <p>Return a reference to the scoped data bean.</p>
*
* @return reference to the scoped data bean
*/
protected RequestBean1 getRequestBean1() {
//
String claveEncriptada =new ConUsuarios().encriptar(this.pswLogin.getT
ext().toString());
ov = cov.listar();
System.out.println("tamao de usuarios:" + ov.length);
System.out.println(" ");
System.out.println(" ============================================= ");
if (ov.length > 0) {
int con = 0;
for (int i = 0; i < ov.length; ++i) {
//Invusuarios u = ov[i];
if (ov[i].getUsuusuario().equals(login) && ov[i].getUsuclave().e
quals(password)) {
Invusuarios usulogin = ov[i];
this.getSessionBean1().setUsuarioSesionLogin(usulogin);
con = 1;
System.out.println(" - Usuario Actual c es [ " + ov[i].getUs
uusuario() + " ]");
Invusuarios usuId[] = new ConUsuarios().listarUsuarioUnico(l
ogin, password);
if (usuId.length > 0) {
System.out.println(" > Total existen [ " + usuId.length
+ " ] usuarios");
System.out.println(" ===================================
========== ");
for (int k = 0; k < usuId.length; k++) {
System.out.println("- - - - - - - - - - - - - - - - - - - -");
System.out.println(" ==> N- " + (k + 1));
System.out.println(" - EL ID DEL USUARIO ES => " + u
suId[k].getUsuid() + " <= | El usuario es => " + usuId[k].getUsuusuario() + " <=
");
System.out.println("- - - - - - - - - - - - - - - - - - - -");
System.out.println(" ===============================
============== ");
System.out.println(" * Verifique el perfil del usuar
io - ");
this.getSessionBean1().setUsuarioActual(usuId[k]);
Invregperfiles usurpId[] = new ConRegPerfiles().busc
arUsu(this.getSessionBean1().getUsuarioActual());
if (usurpId.length > 0) {
System.out.println(" - Total existen [ " + usurp
Id.length + " ] Registros ");
System.out.println(" ===========================
================== ");
for (int h = 0; h < usuId.length; h++) {
System.out.println("- - - - - - - - - - - - - - - - - - - -");
System.out.println(" ==> N- " + (h + 1));
System.out.println(" - EL ID DEL PERFIL ES =
> " + usurpId[h].getPerfid() + " <= | El perfil es => " + usurpId[h].getPerfid()
.getPerfnonperfil() + " <= ");
System.out.println("- - - - - - - - - - - - - - - - - - - -");
System.out.println(" =======================
====================== ");
System.out.println(" - Verifique los modulos
del usuario - ");
}
}
} else {
System.out.println(" No existe ningun usuario con esos d
atos ");
return null;
}
} else {
//
this.getSessionBean1().setUsuarioActual(u);
this.getSessionBean1().setUsuarioSesion(this.getSessionBean1
().getUsuarioSesionLogin());
FacesContext.getCurrentInstance().getExternalContext().getSe
ssionMap().put("usr", this.getSessionBean1().getUsuarioSesionLogin().getUsuid())
;
Date fecha = new ConAuditoria().getFechaActual();
Time hora = new ConAuditoria().getHoraActual();
String ip = InetAddress.getLocalHost().getHostAddress();
String maq = InetAddress.getLocalHost().getHostName();
ConAuditoria a = new ConAuditoria();
String aud = a.insertar(this.getSessionBean1().getUsuarioSes
ionLogin(), fecha, hora, "Inv-Usuarios", 0, "Ingreso al Sistema", "LOGIN", ip, m
aq);
System.out.println(" - NO existen mas usuarios con esos dato
s - ");
}
}
System.out.println(" ");
System.out.println("-------------------------------------");
if (con == 0) {
info("ERROR: Usuario o Contrasea Incorrecta... Verifique...");
this.getSessionBean1().setUsuarioActual(null);
this.getSessionBean1().setUsuarioSesion(null);
return null;
}
//fin verificacion de login
} else {
info("ERROR: No Existen Usuarios Ingresados... Verifique...");
return null;
}
return "Prin";
}
public String btnCancelar_action() {
// TODO: Process the action. Return value is a navigation
// case name where null will return to the same page.
return null;
}
public void pswLogin_processValueChange(ValueChangeEvent event) {
}
}