Android Open Source - AndroIUT Credential






From Project

Back to project page AndroIUT.

License

The source code is released under:

GNU General Public License

If you think the Android project AndroIUT listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.iutdijon.androiut2.iut.data;
/* w w  w .j a  v a  2 s. c  om*/
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.util.ArrayList;

import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.message.BasicNameValuePair;

import android.net.http.AndroidHttpClient;

import com.iutdijon.androiut2.iut.data.account.UserAccount;
import com.iutdijon.androiut2.util.adapters.UserAdapter;

/**
 * Credential g?re toute l'authentification de l'?tudiant sur le serveur d'authentification de l'IUT
 * Il cr?er {@link com.iutdijon.androiut2.iut.data.account.UserAccount} en fonction des donn?es renvoy?es par le serveur
 * Si la connexion est refus?e par le serveur un {@link com.iutdijon.androiut2.iut.data.account.UserAccount} null est renvoy?
 * @author Morgan Funtowicz
 *
 */
public class Credential {
  private final String login;
  private final String password;
  
  
  /**
   * Cr?e une tache d'authentification sur le serveur de l'IUT avec le login et password entr? par l'utilisateur
   * @param login Login entr? par l'utilisa"teur
   * @param password Password entr? par l'utilisateur
   */
  public Credential(String login, String password) {
    this.login = login;
    this.password = password;
  }
  
  /**
   * Renvoie le mot de passe entr? par l'utilisateur
   * @return Mot de passe de l'utilisateur
   */
  public String getPassword() {
    return password;
  }

  /**
   * Renvoie le login utilis? lors de la connexion
   * @return Login utilis? lors de la connexion
   */
  public String getLogin() {
    return login;
  }
  
  /**
   * V?rifie que l'utilisateur est bien un membre de l'IUT
   * @return Un {@link com.iutdijon.androiut2.iut.data.account.UserAccount} si l'utilisateur est reconnu, null si inconnu
   * @throws MalformedURLException
   * @throws IOException
   */
  public UserAccount checkCredential() throws Exception{

    HttpPost post_request = new HttpPost(AndroIUTConstantes.WEBAPI_URL);
    
    ArrayList<NameValuePair> params = new ArrayList<NameValuePair>();
    params.add(new BasicNameValuePair("function", "connect"));
    params.add(new BasicNameValuePair("login", login));
    params.add(new BasicNameValuePair("password", password));
    
    
    post_request.setEntity(new UrlEncodedFormEntity(params));
    
    //TODO : Optimisation compression GZIP des transaction client / serveur
//    String params = "function=connect&login="+login+"&password="+password;
//    
//    post_request.setEntity(AndroidHttpClient.getCompressedEntity(params.getBytes(), null)); 
    
    AndroidHttpClient.modifyRequestToAcceptGzipResponse(post_request);

    AndroidHttpClient client = AndroidHttpClient.newInstance("AndroIUT");
    HttpResponse response = client.execute(post_request);

    InputStream stream = AndroidHttpClient.getUngzippedContent(response.getEntity());
    UserAccount account = new UserAdapter().parse(stream);
    
    client.close();
    
    if(account != null){
      account.setLogin(login);
      account.setPassword(password);
    }
    return account;
  }

}




Java Source Code List

.ADEResourcesDataTree.java
com.iutdijon.androiut2.ade.activities.ADEActivity.java
com.iutdijon.androiut2.ade.activities.ADEListResourcesChooser.java
com.iutdijon.androiut2.ade.activities.OnImageDownloadedCallback.java
com.iutdijon.androiut2.ade.service.ADEICalendarDownloader.java
com.iutdijon.androiut2.ftp.activities.FTPActivity.java
com.iutdijon.androiut2.ftp.adapters.FTPFileListAdapter.java
com.iutdijon.androiut2.ftp.data.FTPCommandResult.java
com.iutdijon.androiut2.ftp.data.FTPCommandWrapper.java
com.iutdijon.androiut2.ftp.data.FTPCommand.java
com.iutdijon.androiut2.ftp.services.FTPDownloadMonitor.java
com.iutdijon.androiut2.ftp.services.FTPServiceCall.java
com.iutdijon.androiut2.ftp.services.ProgressDownload.java
com.iutdijon.androiut2.global.AndroIUTApplication.java
com.iutdijon.androiut2.iut.activities.HomeActivity.java
com.iutdijon.androiut2.iut.activities.LoginActivity.java
com.iutdijon.androiut2.iut.data.Credential.java
com.iutdijon.androiut2.iut.data.UserFactory.java
com.iutdijon.androiut2.iut.data.account.StudentAccount.java
com.iutdijon.androiut2.iut.data.account.TeacherAccount.java
com.iutdijon.androiut2.iut.data.account.UserAccount.java
com.iutdijon.androiut2.iut.services.IUTLoginServiceCall.java
com.iutdijon.androiut2.mail.activities.MailActivity.java
com.iutdijon.androiut2.mail.activities.MailReaderActivity.java
com.iutdijon.androiut2.mail.adapters.MailDisplayAdapter.java
com.iutdijon.androiut2.mail.adapters.MailsListAdapter.java
com.iutdijon.androiut2.mail.services.EmailUtils.java
com.iutdijon.androiut2.mail.services.MailReader.java
com.iutdijon.androiut2.mail.services.MailService.java
com.iutdijon.androiut2.schooling.activities.SchoolingActivity.java
com.iutdijon.androiut2.schooling.activities.SchoolingTabActivity.java
com.iutdijon.androiut2.schooling.adapters.SectionedAdapter.java
com.iutdijon.androiut2.schooling.data.Absence.java
com.iutdijon.androiut2.schooling.data.Mark.java
com.iutdijon.androiut2.schooling.data.SchoolingData.java
com.iutdijon.androiut2.schooling.service.SchoolingDataServiceCall.java
com.iutdijon.androiut2.util.AndroIUTLogger.java
com.iutdijon.androiut2.util.IOUtils.java
com.iutdijon.androiut2.util.PreferencesManager.java
com.iutdijon.androiut2.util.UIUtil.java
com.iutdijon.androiut2.util.adapters.AbsencesAdapter.java
com.iutdijon.androiut2.util.adapters.BitmapAdapter.java
com.iutdijon.androiut2.util.adapters.CalendarAdapter.java
com.iutdijon.androiut2.util.adapters.IAdapter.java
com.iutdijon.androiut2.util.adapters.MarksAdapter.java
com.iutdijon.androiut2.util.adapters.UserAdapter.java
com.iutdijon.androiut2.util.adapters.XmlAdapter.java
com.iutdijon.androiut2.util.bridge.BridgeFinder.java
com.iutdijon.androiut2.util.loaders.AndroIUTHTTPConnection.java
com.iutdijon.androiut2.util.loaders.AsyncServiceCall.java
com.iutdijon.androiut2.util.loaders.BitmapDownloaderTask.java
com.iutdijon.androiut2.util.loaders.GetAsyncServiceCall.java
com.iutdijon.androiut2.util.loaders.ImageDownloader.java
com.iutdijon.androiut2.util.loaders.PostAsyncServiceCall.java
com.iutdijon.androiut2.util.observers.Observable.java
com.iutdijon.androiut2.util.observers.Observer.java
com.iutdijon.androiut2.util.security.SecureCenter.java
com.iutdijon.androiut2.util.view.ImageZoomView.java
com.iutdijon.androiut2.util.zoom.AspectQuotient.java
com.iutdijon.androiut2.util.zoom.DynamicZoomControl.java
com.iutdijon.androiut2.util.zoom.LongPressZoomListener.java
com.iutdijon.androiut2.util.zoom.PinchZoomListener.java
com.iutdijon.androiut2.util.zoom.SimpleZoomListener.java
com.iutdijon.androiut2.util.zoom.ZoomState.java
com.iutdijon.androiut2.util.zoom.util.Dynamics.java
com.iutdijon.androiut2.util.zoom.util.SpringDynamics.java