All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.swiesend.secretservice.interfaces.Service Maven / Gradle / Ivy

Go to download

A Java library for storing secrets in the gnome-keyring over the DBus. Simply set and get passwords in a gnome linux system.

The newest version!
package de.swiesend.secretservice.interfaces;

import de.swiesend.secretservice.gnome.keyring.InternalUnsupportedGuiltRiddenInterface;
import org.freedesktop.dbus.DBusPath;
import org.freedesktop.dbus.ObjectPath;
import org.freedesktop.dbus.annotations.DBusInterfaceName;
import org.freedesktop.dbus.exceptions.DBusException;
import org.freedesktop.dbus.interfaces.DBusInterface;
import org.freedesktop.dbus.messages.DBusSignal;
import org.freedesktop.dbus.types.Variant;
import de.swiesend.secretservice.Pair;
import de.swiesend.secretservice.Secret;
import de.swiesend.secretservice.Static;

import java.util.List;
import java.util.Map;

@DBusInterfaceName(Static.Interfaces.SERVICE)
public interface Service extends DBusInterface {

    public static class CollectionCreated extends DBusSignal {
        public final DBusPath collection;

        /**
         * A collection was created.
         *
         * @param path          The path to the object this is emitted from.
         *
         * @param collection    Collection that was created.
         * 
         * @throws DBusException Could not communicate properly with the D-Bus.
         */
        public CollectionCreated(String path, DBusPath collection) throws DBusException {
            super(path, collection);
            this.collection = collection;
        }
    }

    public static class CollectionDeleted extends DBusSignal {
        public final DBusPath collection;

        /**
         * A collection was deleted.
         *
         * @param path          The path to the object this is emitted from.
         *
         * @param collection    Collection that was deleted.
         *
         * @throws DBusException Could not communicate properly with the D-Bus.
         */
        public CollectionDeleted(String path, DBusPath collection) throws DBusException {
            super(path, collection);
            this.collection = collection;
        }
    }

    public static class CollectionChanged extends DBusSignal {
        public final DBusPath collection;

        /**
         * A collection was changed.
         *
         * @param path          The path to the object this is emitted from.
         *
         * @param collection    Collection that was changed.
         *
         * @throws DBusException Could not communicate properly with the D-Bus.
         */
        public CollectionChanged(String path, DBusPath collection) throws DBusException {
            super(path, collection);
            this.collection = collection;
        }
    }

    /**
     * Open a unique session for the caller application.
     *
     * @param algorithm The algorithm the caller wishes to use.
     * @param input     Input arguments for the algorithm.
     * 
     * @return Pair<output, result>
*
* output — Output of the session algorithm negotiation.
*
* result — The object path of the session, if session was created.
* * @see Pair * @see Variant * @see ObjectPath */ abstract public Pair, ObjectPath> openSession(String algorithm, Variant input); /** * Create a new collection with the specified properties. * * @param properties Properties for the new collection. This allows setting the new collection's properties * upon its creation. All READWRITE properties are usable. Specify the property names in * full interface.Property form.
*
* Example for properties: *

* properties = { "org.freedesktop.Secret.Collection.Label": "MyCollection" } *

* * @param alias If creating this connection for a well known alias then a string like "default". * If an collection with this well-known alias already exists, then that collection will be * returned instead of creating a new collection. Any readwrite properties provided to this * function will be set on the collection.
*
* Set this to an empty string if the new collection should not be associated with a well * known alias. * * @return Pair<collection, prompt>
*
* collection — The new collection object, or '/' if prompting is necessary.
*
* prompt — A prompt object if prompting is necessary, or '/' if no prompt was needed.
* * @see Pair * @see Variant * @see ObjectPath */ abstract public Pair createCollection(Map properties, String alias); /** * Create a new collection with the specified properties. * * @param properties Properties for the new collection. This allows setting the new collection's properties * upon its creation. All READWRITE properties are usable. Specify the property names in * full interface.Property form.
*
* Example for properties: *

* properties = { "org.freedesktop.Secret.Collection.Label": "MyCollection" } *

* * @return Pair<collection, prompt>
*
* collection — The new collection object, or '/' if prompting is necessary.
*
* prompt — A prompt object if prompting is necessary, or '/' if no prompt was needed.
* * @see Pair * @see Variant * @see ObjectPath */ abstract public Pair createCollection(Map properties); /** * Find items in any collection. * * @param attributes Find secrets in any collection. * *

* Example: * { * "Attribute1": "Value1", * "Attribute2": "Value2" * } *

* *

* Note: * Please note that there is a distinction between the terms Property, which refers * to D-Bus properties of an object, and Attribute, which refers to one of a * secret item's string-valued attributes. *

* * @return Pair<unlocked, locked>
*
* unlocked — Items found.
*
* locked — Items found that require authentication.
* * @see Pair * @see ObjectPath */ abstract public Pair, List> searchItems(Map attributes); /** * Unlock the specified objects. * * @param objects Objects to unlock. * * @return Pair<unlocked, prompt>
*
* unlocked — Objects that were unlocked without a prompt.
*
* prompt — A prompt object which can be used to unlock the remaining objects, or the special value '/' when no prompt is necessary.
* * @see Pair * @see ObjectPath */ abstract public Pair, ObjectPath> unlock(List objects); /** * Lock the items. * * @param objects Objects to lock. * * @return Pair<locked, prompt>
*
* locked — Objects that were locked without a prompt.
*
* prompt — A prompt to lock the objects, or the special value '/' when no prompt is necessary.
* * @see Pair */ abstract public Pair, ObjectPath> lock(List objects); /** * Lock the entire Secret Service API. * *
* See Also:
* {@link #lock(List objects)}
* {@link #unlock(List objects)}
* {@link InternalUnsupportedGuiltRiddenInterface#unlockWithMasterPassword(DBusPath collection, Secret master)}
*/ abstract public void lockService(); /** * Toggle the lock for a collection with a prompt. * * @param collection Path of the collection. * * @return Path of the collection * *
* See Also:
* {@link InternalUnsupportedGuiltRiddenInterface#changeWithPrompt(DBusPath collection)}
*/ abstract public ObjectPath changeLock(ObjectPath collection); /** * Retrieve multiple secrets from different items. * * @param items Items to get secrets for. * * @param session The session to use to encode the secrets. * * @return secrets — Secrets for the items. * * @see Secret * @see ObjectPath */ abstract public Map getSecrets(List items, ObjectPath session); /** * Get the collection with the given alias. * * @param name An alias, such as 'default'. * * @return collection — The collection or the the path '/' if no such collection exists. * * @see Static.ObjectPaths * @see ObjectPath * @see Collection */ abstract public ObjectPath readAlias(String name); /** * Setup a collection alias. * @param name An alias, such as 'default'. * * @param collection The collection to make the alias point to. To remove an alias use the special value '/'. * * @see ObjectPath * @see Collection */ abstract public void setAlias(String name, ObjectPath collection); /** * @return A list of present collections. */ abstract public List getCollections(); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy