VirtualBox

Changeset 55505 in vbox


Ignore:
Timestamp:
Apr 29, 2015 8:26:44 AM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
99859
Message:

Main: Add method to return list of medium identifiers assoicated with a given password ID. Required by the GUI to verify entered passwords during appliance export

Location:
trunk/src/VBox/Main
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r55437 r55505  
    29932993  <interface
    29942994    name="IAppliance" extends="$unknown"
    2995     uuid="d9432012-2740-499f-b3b3-0991da3679f3"
     2995    uuid="a529d52c-cf23-4936-9150-e8a6ce77fdad"
    29962996    wsmap="managed"
    29972997    >
     
    32563256
    32573257      <param name="identifiers" type="wstring" dir="return" safearray="yes">
    3258         The list of password identifiers required on success.
     3258        The list of password identifiers required for export on success.
     3259      </param>
     3260    </method>
     3261
     3262    <method name="getMediumIdsForPasswordId">
     3263      <desc>
     3264        Returns a list of medium identifiers which use the given password identifier.
     3265      </desc>
     3266
     3267      <param name="passwordId" type="wstring" dir="in">
     3268        The password identifier to get the medium identifiers for.
     3269      </param>
     3270      <param name="identifiers" type="uuid" mod="string" dir="return" safearray="yes">
     3271        The list of medium identifiers returned on success.
    32593272      </param>
    32603273    </method>
     
    1468114694      <param name="currentPassword" type="wstring" dir="in">
    1468214695        <desc>
    14683           The olcurrentd password the medium is protected with. Use an empty string to indicate
     14696          The current password the medium is protected with. Use an empty string to indicate
    1468414697          that the medium isn't encrypted.
    1468514698        </desc>
  • trunk/src/VBox/Main/include/ApplianceImpl.h

    r55184 r55505  
    106106    HRESULT getWarnings(std::vector<com::Utf8Str> &aWarnings);
    107107    HRESULT getPasswordIds(std::vector<com::Utf8Str> &aIdentifiers);
     108    HRESULT getMediumIdsForPasswordId(const com::Utf8Str &aPasswordId, std::vector<com::Guid> &aIdentifiers);
    108109    HRESULT addPasswords(const std::vector<com::Utf8Str> &aIdentifiers,
    109110                         const std::vector<com::Utf8Str> &aPasswords);
  • trunk/src/VBox/Main/include/ApplianceImplPrivate.h

    r55401 r55505  
    3535typedef std::pair<Utf8Str, Utf8Str> STRPAIR;
    3636
     37typedef std::vector<com::Guid> GUIDVEC;
     38
    3739/* Describe a location for the import/export. The location could be a file on a
    3840 * local hard disk or a remote target based on the supported inet protocols. */
     
    106108    /** Sequence of password identifiers to encrypt disk images during export. */
    107109    std::vector<com::Utf8Str> m_vecPasswordIdentifiers;
     110    /** Map to get all medium identifiers assoicated with a given password identifier. */
     111    std::map<com::Utf8Str, GUIDVEC> m_mapPwIdToMediumIds;
    108112    /** Secret key store used to hold the passwords during export. */
    109113    SecretKeyStore            *m_pSecretKeyStore;
  • trunk/src/VBox/Main/src-server/ApplianceImpl.cpp

    r55182 r55505  
    614614}
    615615
     616HRESULT Appliance::getMediumIdsForPasswordId(const com::Utf8Str &aPasswordId, std::vector<com::Guid> &aIdentifiers)
     617{
     618    HRESULT hrc = S_OK;
     619    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     620
     621    std::map<com::Utf8Str, GUIDVEC>::const_iterator it = m->m_mapPwIdToMediumIds.find(aPasswordId);
     622    if (it != m->m_mapPwIdToMediumIds.end())
     623        aIdentifiers = it->second;
     624    else
     625        hrc = setError(E_FAIL, tr("The given password identifier is not associated with any medium"));
     626
     627    return hrc;
     628}
     629
    616630HRESULT Appliance::addPasswords(const std::vector<com::Utf8Str> &aIdentifiers,
    617631                                const std::vector<com::Utf8Str> &aPasswords)
  • trunk/src/VBox/Main/src-server/ApplianceImplExport.cpp

    r55182 r55505  
    359359                if (FAILED(rc)) throw rc;
    360360
    361                 /* If the medium is encrypted add the key identifier to the */
     361                /* If the medium is encrypted add the key identifier to the list. */
    362362                IMedium *iBaseMedium = pBaseMedium;
    363363                Medium *pBase = static_cast<Medium*>(iBaseMedium);
     
    365365                if (!strKeyId.isEmpty())
    366366                {
     367                    IMedium *iMedium = pMedium;
     368                    Medium *pMed = static_cast<Medium*>(iMedium);
     369                    com::Guid mediumUuid = pMed->i_getId();
    367370                    bool fKnown = false;
    368371
     
    378381
    379382                    if (!fKnown)
     383                    {
     384                        GUIDVEC vecMediumIds;
     385
     386                        vecMediumIds.push_back(mediumUuid);
    380387                        pAppliance->m->m_vecPasswordIdentifiers.push_back(strKeyId);
     388                        pAppliance->m->m_mapPwIdToMediumIds.insert(std::pair<com::Utf8Str, GUIDVEC>(strKeyId, vecMediumIds));
     389                    }
     390                    else
     391                    {
     392                        std::map<com::Utf8Str, GUIDVEC>::iterator it = pAppliance->m->m_mapPwIdToMediumIds.find(strKeyId);
     393                        if (it == pAppliance->m->m_mapPwIdToMediumIds.end())
     394                            throw setError(E_FAIL, tr("Internal error adding a medium UUID to the map"));
     395                        it->second.push_back(mediumUuid);
     396                    }
    381397                }
    382398            }
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette