/******************************************************************************* * Copyright 2018 A-SIT Plus GmbH * AT-specific eIDAS Connector has been developed in a cooperation between EGIZ, * A-SIT Plus GmbH, A-SIT, and Graz University of Technology. * * Licensed under the EUPL, Version 1.2 or - as soon they will be approved by * the European Commission - subsequent versions of the EUPL (the "License"); * You may not use this work except in compliance with the License. * You may obtain a copy of the License at: * https://joinup.ec.europa.eu/news/understanding-eupl-v12 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * This product combines work with different licenses. See the "NOTICE" text * file for details on the various modules and licenses. * The "NOTICE" text file is part of the distribution. Any derivative works * that you distribute must include a readable copy of the "NOTICE" text file. *******************************************************************************/ package at.asitplus.eidas.specific.modules.authmodule_eIDASv2.DAO; import java.util.ArrayList; import java.util.Collections; import java.util.List; import at.gv.egiz.eaaf.core.impl.data.Pair; @Deprecated public class eIDASPersonalIdStoreDAO { public static final String NAME = "foreigneIDMap"; //Enum with all cols of this table public enum COLS { timestamp, transactionId, eidasId, eidasSourceCountry, eidasDestinationCountry, ernbId } public enum T { ID("INTEGER"), BIGINT("VARCHAR(265)"), URI("VARCHAR(256)"), DATE("Long"), TEXT("TEXT"), Long("BIGINT"), Int("INTEGER"), BLOB("BLOB"), CC("CHAR(2)"), BOOL("INTEGER"); public String s_; private T(String s) { s_ = s; } @Override public String toString() { return s_; } } //define Cols of the table public static final List> TABLE_COLS; static { List> cols = new ArrayList>(); cols.add(Pair.newInstance(COLS.timestamp.name(), T.DATE)); cols.add(Pair.newInstance(COLS.transactionId.name(), T.TEXT)); cols.add(Pair.newInstance(COLS.eidasId.name(), T.TEXT)); cols.add(Pair.newInstance(COLS.eidasSourceCountry.name(), T.CC)); cols.add(Pair.newInstance(COLS.eidasDestinationCountry.name(), T.CC)); cols.add(Pair.newInstance(COLS.ernbId.name(), T.TEXT)); TABLE_COLS = Collections.unmodifiableList(cols); } public static final String CREATE = "CREATE TABLE " + NAME + " (" + "id" + " " + T.ID.toString() + " PRIMARY KEY AUTOINCREMENT, " + buildCreateTableQuery(TABLE_COLS) + ")"; public static final String INSERT = "INSERT INTO " + NAME + "(" + buildInsertQueryKeys(TABLE_COLS) + ")" + " VALUES (" + buildInsertQueryValues(TABLE_COLS) + ");"; public static final String SELECT_BY_ERNB_ID = "SELECT * FROM " + NAME + " WHERE " + COLS.ernbId.name() + "=?;"; public static final String SELECT_BY_EIDAS_RAW_ID = "SELECT * FROM " + NAME + " WHERE " + COLS.eidasId.name() + "=?" + " and " + COLS.eidasSourceCountry.name() + "=?" + ";"; /** * Build a part of a SQL query, which contains the cols of a table that should be created * * @param cols List of DB col definitions {@link Pair} * @return Part of a SQL query, which contains cols that should be created */ private static String buildCreateTableQuery(List> cols) { String sql = ""; for (Pair el : cols) { sql += el.getFirst() + " " + el.getSecond().toString() + ","; } return sql.substring(0, sql.length()-1); } /** * Build a part of a SQL query, which contains the cols keys of a table for insert operation * * @param cols List of DB col definitions {@link Pair} * @return Part of a SQL query, which contains cols that should be created */ protected static String buildInsertQueryKeys(List> cols) { String sql = ""; for (Pair el : cols) { sql += el.getFirst() + ","; } return sql.substring(0, sql.length()-1); } /** * Build a part of a SQL query, which contains the cols values of a table for insert operation * * @param cols List of DB col definitions {@link Pair} * @return Part of a SQL query, which contains cols that should be created */ protected static String buildInsertQueryValues(List> cols) { String sql = ""; for (Pair el : cols) { sql += "?,"; } return sql.substring(0, sql.length()-1); } }