+/*
+ * Copyright (c) 2011-2014, JANET(UK)
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of JANET(UK) nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+*/
using Gee;
using Gtk;
private const int WINDOW_WIDTH = 400;
private const int WINDOW_HEIGHT = 500;
public void show() {
- if (view != null) view.show();
+ if (view != null) view.make_visible();
}
public IdentityManagerApp (bool headless, bool use_flat_file_store) {
+ use_flat_file_store |= UserForcesFlatFileStore();
#if GNOME_KEYRING
- bool keyring_available = GnomeKeyring.is_available();
+ bool keyring_available = (!use_flat_file_store) && GnomeKeyring.is_available();
#else
bool keyring_available = false;
#endif
view = new IdentityManagerView(this);
LinkedList<IdCard> card_list = model.get_card_list() ;
if (card_list.size > 0)
- this.default_id_card = card_list.first();
+ this.default_id_card = card_list.last();
init_ipc_server ();
bool has_nai = request.nai != null && request.nai != "";
bool has_srv = request.service != null && request.service != "";
bool confirm = false;
- IdCard nai_provided = null;
foreach (IdCard id in model.get_card_list())
{
- /* If NAI matches we add id card to the candidate list */
+ /* If NAI matches, use this id card */
if (has_nai && request.nai == id.nai)
{
- nai_provided = id;
- request.candidates.append (id);
- continue;
+ identity = id;
+ break;
}
/* If any service matches we add id card to the candidate list */
}
/* If more than one candidate we dissasociate service from all ids */
- if (has_srv && request.candidates.length() > 1)
+ if ((identity == null) && has_srv && request.candidates.length() > 1)
{
foreach (IdCard id in request.candidates)
{
}
}
-// model.store_id_cards ();
-
/* If there are no candidates we use the service matching rules */
- if (request.candidates.length () == 0)
+ if ((identity==null) && (request.candidates.length () == 0))
{
foreach (IdCard id in model.get_card_list())
{
}
}
- if (request.candidates.length () > 1)
- {
- if (has_nai && nai_provided != null)
- {
- identity = nai_provided;
- confirm = false;
- }
- else
- confirm = true;
- }
- if (identity == null)
- identity = request.candidates.nth_data (0);
- if ((identity != null) &&
- ((identity.password == null) || (identity.password == "")))
+ if ((identity == null) && has_nai) {
+ // create a temp identity
+ string[] components = request.nai.split("@", 2);
+ identity = new IdCard();
+ identity.display_name = request.nai;
+ identity.username = components[0];
+ if (components.length > 1)
+ identity.issuer = components[1];
identity.password = request.password;
+ identity.temporary = true;
+ }
if (identity == null) {
- if (has_nai) {
- // create a temp identity
- string[] components = request.nai.split("@", 2);
- identity = new IdCard();
- identity.display_name = request.nai;
- identity.username = components[0];
- if (components.length > 1)
- identity.issuer = components[1];
- identity.password = request.password;
- } else {
+ if (request.candidates.length () != 1) {
confirm = true;
+ } else {
+ identity = request.candidates.nth_data (0);
}
}
- /* TODO: If candidate list empty return fail */
-
if (confirm && (view != null))
{
if (!explicitly_launched)
}
// Send back the identity (we can't directly run the
// callback because we may be being called from a 'yield')
- Idle.add(
+ GLib.Idle.add(
() => {
if (view != null) {
- view.check_add_password(identity, request, model);
+ identity = view.check_add_password(identity, request, model);
}
request.return_identity (identity);
// The following occasionally causes the app to exit without sending the dbus