/* * Facebook Login Servlet - Shiboleth Identity Provider integrator with Facebook * Copyright (C) 2012 Poznan Supercomputing and Networking Center - Application * Department * * contact: adamski@man.poznan.pl * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. You should have received a copy of the GNU General Public License * along with this program. If not, see . * * * Poznan Supercomputing and Networking Center - Application Department, * ul.Dąbrowskiego 79a, 60-529 Poznań, Poland. (+48 61) 858-20-72 * http://apps.man.poznan.pl/ * * This application was developed as a part of the SYNAT project * http://www.synat.pl/en * * Poznan Supercomputing and Networking Center, hereby disclaims all copyright * interest in the Facebook Login Servlet written by Jakub "Erwin" Aftowicz. * (erwin37@gmail.com) * * Marcin Adamski , 21 MAY 2012 (adamski@man.poznan.pl) */ package pl.psnc.synat.idp; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import org.codehaus.jackson.JsonParseException; import org.codehaus.jackson.map.JsonMappingException; import org.codehaus.jackson.map.ObjectMapper; public class FacebookAccount { private boolean isInDataBase = false; private HashMap fbAttributes; private List parameters = new ArrayList(); private List fbParameters = new ArrayList(); @SuppressWarnings("unchecked") public void getAttributesFromJson(String Json) { try { this.fbAttributes = new ObjectMapper().readValue(Json, HashMap.class); } catch (JsonParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (JsonMappingException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } public String getAttributesMap() { return this.fbAttributes.toString(); } public String getAttributesValue(String key) { return this.fbAttributes.get(key); } public boolean isInDataBase() { return isInDataBase; } public void setInDataBase(boolean isInDataBase) { this.isInDataBase = isInDataBase; } public void importParametersDefinitions(List list) { for (Parameter parameter : list) { this.parameters.add(new Parameter(parameter.getName())); } } public void importFbParametersDefinitions(List list) { for (FbParameter parameter : list) { FbParameter p = new FbParameter(parameter.getName(), parameter.isReturned()); if (parameter.isInStatement()) { p.setNumberInStatement(parameter.getNumberInStatement()); } this.fbParameters.add(p); } } public int getListSize() { return this.parameters.size(); } public void setParametersValues(int index, String value) { this.parameters.get(index).setDefaultValue(value); } public String getParametersValues() { String out = ""; for (Parameter param : this.parameters) { out = out + param.getDefaultValue() + ", "; } if (this.parameters.size() != 0) return out.substring(0, out.length() - 2); else return ""; } public List getParameters() { return parameters; } public void setParameters(List parameters) { this.parameters = parameters; } public List getFbParameters() { return fbParameters; } public void setFbParameters(List fbParameters) { this.fbParameters = fbParameters; } }