Versiones comparadas

Clave

  • Se ha añadido esta línea.
  • Se ha eliminado esta línea.
  • El formato se ha cambiado.

...

Bloque de código
	private final String SSOAuthenticationMethods[] = {
			"SSO_CORREO( \"LdapAuthenticationHandler\", \"\", \"label.authentication.type.correoum\" )",
			"SSO_CLAVE( \"DelegatedClientAuthenticationHandler\", \"Cl@ve\", \"label.authentication.type.clave\" )",
			"SSO_CERT( \"DelegatedClientAuthenticationHandler\", \"Cert\", \"label.authentication.type.cert\" )",
			"SSO_CMN( \"DelegatedClientAuthenticationHandler\", \"CMN\", \"label.authentication.type.cmn\" )"
	};

	private static final String CLIENT_NAME_KEY = "clientName";
	private static final String AUTHENTICATION_METHOD_NAME_KEY = "authenticationMethod";
	private static final String CLAVE_CLIENT_NAME = "Cl@ve";
	private static final String CERT_CLIENT_NAME = "Cert";
	private static final String FIRST_NAME_KEY = "FirstName";
	private static final String FAMILY_NAME_KEY = "FamilyName";


	public void setupCasUser( javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res,
			javax.servlet.http.HttpSession session ) {
		setCasUser( req.getRemoteUser() );
		setReq( req );
	}

	public void setCasUser( String dniOrCorreo ) {
		if ( ( dniOrCorreo != null ) && ( !dniOrCorreo.equals( "" ) ) ) {
			if ( isValidEmailAddress( dniOrCorreo ) ) {
				correo = dniOrCorreo;
			} else {
				dni = dniOrCorreo;
			}
		}
	}

	public boolean isValidEmailAddress( String email ) {
		final String ePattern = "^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$";
		final java.util.regex.Pattern p = java.util.regex.Pattern.compile( ePattern );
		final java.util.regex.Matcher m = p.matcher( email );
		return m.matches();
	}

	public UsuarioIntercambio verificaUserSSO() {
		CallableStatement cs = null;
		String dnic = "";
		codigo = "011";
		ResultSet rs = null;
		try {
			if ( !correo.equals( "" ) ) {
				cs = conn.prepareCall( getQuery( "ObtieneDniCorreoBD" ) );
				cs.setString( 1, correo );
				cs.registerOutParameter( 2, java.sql.Types.VARCHAR );
				cs.setQueryTimeout( 4 );
				cs.execute();
				dnic = cs.getString( 2 );
			} else {
				// hay que eliminar la letra
				dnic = dni;
				dnic = dnic.substring( 0, 8 );
				cs = conn.prepareCall( getQuery( "ObtieneCorreoDniBD" ) );
				cs.setString( 1, dnic );
				cs.setString( 2, dnic );
				cs.registerOutParameter( 2, java.sql.Types.VARCHAR );
				cs.setQueryTimeout( 4 );
				rs = cs.executeQuery();
				if ( rs.next() ) {
					correo = rs.getString( 1 );
				}
			}

			if ( ( dnic != null ) && !dnic.equals( "" ) ) {
				user = new UsuarioIntercambio( conn, dnic, codigo, correo.toLowerCase() );
				user.setIPCliente( userIPCliente );
				user.setIPInternet( userIPInternet );
				return user;
			}
		}
		catch ( final Exception ex ) {
			LOG.error( "Error VerificaUserSSO: " + ex );
		}
		finally {
			try {
				if ( cs != null ) {
					cs.close();
				}
			}
			catch ( final SQLException e2 ) {}
		}
		return null;
	}


AuthenticationMethodNotSupportedException.java

Bloque de código
package intercambio.com.authentication.exceptions;

public class AuthenticationMethodNotSupportedException extends RuntimeException {

	private static final long serialVersionUID = -7140000370097499128L;

	private static final String MENSAJE = "Authentication method not supported: ";

	public AuthenticationMethodNotSupportedException( String message ) {
		super( MENSAJE + message );
	}

	public AuthenticationMethodNotSupportedException( Throwable cause ) {
		super( MENSAJE, cause );
	}

	public AuthenticationMethodNotSupportedException( String message, Throwable cause ) {
		super( MENSAJE + message, cause );
	}
}