func (o *Command) ProfileExists(rw io.Writer, req io.Reader) command.Error {
	user := &WalletUser{}
	err := json.NewDecoder(req).Decode(&user)
	if err != nil {
		logutil.LogInfo(logger, CommandName, ProfileExistsMethod, err.Error())
		return command.NewValidationError(InvalidRequestErrorCode, err)
	}
	err = wallet.ProfileExists(user.ID, o.ctx)
	if err != nil {
		logutil.LogInfo(logger, CommandName, ProfileExistsMethod, err.Error())
		return command.NewExecuteError(ProfileExistsErrorCode, err)
	}
	logutil.LogDebug(logger, CommandName, ProfileExistsMethod, logSuccess,
		logutil.CreateKeyValueString(logUserIDKey, user.ID))
	return nil
}
ProfileExists checks if wallet profile exists for given wallet user.
package vcwallet
import (
	"encoding/json"
	"errors"
	"fmt"
	"io"
	"net/http"
	"time"
	"github.com/piprate/json-gold/ld"
	"github.com/hyperledger/aries-framework-go/component/storage/edv"
	"github.com/hyperledger/aries-framework-go/pkg/common/log"
	"github.com/hyperledger/aries-framework-go/pkg/controller/command"
	"github.com/hyperledger/aries-framework-go/pkg/controller/internal/cmdutil"
	"github.com/hyperledger/aries-framework-go/pkg/crypto"
	"github.com/hyperledger/aries-framework-go/pkg/framework/aries/api/vdr"
	"github.com/hyperledger/aries-framework-go/pkg/internal/logutil"
	"github.com/hyperledger/aries-framework-go/pkg/kms"
	"github.com/hyperledger/aries-framework-go/pkg/kms/webkms"
	"github.com/hyperledger/aries-framework-go/pkg/wallet"
	"github.com/hyperledger/aries-framework-go/spi/storage"
)
var logger = log.New("aries-framework/command/vcwallet")
const (
	InvalidRequestErrorCode = command.Code(iota + command.VCWallet)
	CreateProfileErrorCode
	UpdateProfileErrorCode
	OpenWalletErrorCode
	CloseWalletErrorCode
	AddToWalletErrorCode
	RemoveFromWalletErrorCode
	GetFromWalletErrorCode
	GetAllFromWalletErrorCode
	QueryWalletErrorCode
	IssueFromWalletErrorCode
	ProveFromWalletErrorCode
	VerifyFromWalletErrorCode
	DeriveFromWalletErrorCode
	CreateKeyPairFromWalletErrorCode
	ProfileExistsErrorCode
	DIDConnectErrorCode
	ProposePresentationErrorCode
	PresentProofErrorCode
)
const (
	CommandName = "vcwallet"
	CreateProfileMethod       = "CreateProfile"
	UpdateProfileMethod       = "UpdateProfile"
	ProfileExistsMethod       = "ProfileExists"
	OpenMethod                = "Open"
	CloseMethod               = "Close"
	AddMethod                 = "Add"
	RemoveMethod              = "Remove"
	GetMethod                 = "Get"
	GetAllMethod              = "GetAll"
	QueryMethod               = "Query"
	IssueMethod               = "Issue"
	ProveMethod               = "Prove"
	VerifyMethod              = "Verify"
	DeriveMethod              = "Derive"
	CreateKeyPairMethod       = "CreateKeyPair"
	ConnectMethod             = "Connect"
	ProposePresentationMethod = "ProposePresentation"
	PresentProofMethod        = "PresentProof"
)
const (
	logSuccess         = "success"
	logUserIDKey       = "userID"
	connectionIDString = "connectionID"
	invitationIDString = "invitationID"
	LabelString        = "label"
	emptyRawLength = 4
	defaultTokenExpiry = 5 * time.Minute
)
type AuthCapabilityProvider interface {
	GetHeaderSigner(authzKeyStoreURL, accessToken, secretShare string) HTTPHeaderSigner
}
type HTTPHeaderSigner interface {
	SignHeader(req *http.Request, capabilityBytes []byte) (*http.Header, error)
}
type Config struct {
	EdvAuthzProvider AuthCapabilityProvider
	WebKMSAuthzProvider AuthCapabilityProvider
	EDVReturnFullDocumentsOnQuery bool
	EDVBatchEndpointExtensionEnabled bool
	WebKMSCacheSize int
	DefaultTokenExpiry time.Duration
}
type provider interface {
	StorageProvider() storage.Provider
	VDRegistry() vdr.Registry
	Crypto() crypto.Crypto
	JSONLDDocumentLoader() ld.DocumentLoader
	MediaTypeProfiles() []string
	didCommProvider  
}
type didCommProvider interface {
	KMS() kms.KeyManager
	ServiceEndpoint() string
	ProtocolStateStorageProvider() storage.Provider
	Service(id string) (interface{}, error)
	KeyType() kms.KeyType
	KeyAgreementType() kms.KeyType
}
type Command struct {
	ctx    provider
	config *Config
}
func New(p provider, config *Config) *Command {
	cmd := &Command{ctx: p, config: &Config{}}
	if config != nil {
		cmd.config = config
	}
	if cmd.config.DefaultTokenExpiry == 0 {
		cmd.config.DefaultTokenExpiry = defaultTokenExpiry
	}
	return cmd
}
func (o *Command) GetHandlers() []command.Handler {
	return []command.Handler{
		cmdutil.NewCommandHandler(CommandName, CreateProfileMethod, o.CreateProfile),
		cmdutil.NewCommandHandler(CommandName, UpdateProfileMethod, o.UpdateProfile),
		cmdutil.NewCommandHandler(CommandName, ProfileExistsMethod, o.ProfileExists),
		cmdutil.NewCommandHandler(CommandName, OpenMethod, o.Open),
		cmdutil.NewCommandHandler(CommandName, CloseMethod, o.Close),
		cmdutil.NewCommandHandler(CommandName, AddMethod, o.Add),
		cmdutil.NewCommandHandler(CommandName, RemoveMethod, o.Remove),
		cmdutil.NewCommandHandler(CommandName, GetMethod, o.Get),
		cmdutil.NewCommandHandler(CommandName, GetAllMethod, o.GetAll),
		cmdutil.NewCommandHandler(CommandName, QueryMethod, o.Query),
		cmdutil.NewCommandHandler(CommandName, IssueMethod, o.Issue),
		cmdutil.NewCommandHandler(CommandName, ProveMethod, o.Prove),
		cmdutil.NewCommandHandler(CommandName, VerifyMethod, o.Verify),
		cmdutil.NewCommandHandler(CommandName, DeriveMethod, o.Derive),
		cmdutil.NewCommandHandler(CommandName, CreateKeyPairMethod, o.CreateKeyPair),
		cmdutil.NewCommandHandler(CommandName, ConnectMethod, o.Connect),
		cmdutil.NewCommandHandler(CommandName, ProposePresentationMethod, o.ProposePresentation),
		cmdutil.NewCommandHandler(CommandName, PresentProofMethod, o.PresentProof),
	}
}
func (o *Command) CreateProfile(rw io.Writer, req io.Reader) command.Error {
	request := &CreateOrUpdateProfileRequest{}
	err := json.NewDecoder(req).Decode(request)
	if err != nil {
		logutil.LogInfo(logger, CommandName, CreateProfileMethod, err.Error())
		return command.NewValidationError(InvalidRequestErrorCode, err)
	}
	err = wallet.CreateProfile(request.UserID, o.ctx, prepareProfileOptions(request)...)
	if err != nil {
		logutil.LogInfo(logger, CommandName, CreateProfileMethod, err.Error())
		return command.NewExecuteError(CreateProfileErrorCode, err)
	}
	if request.LocalKMSPassphrase != "" && request.EDVConfiguration != nil {
		err = wallet.CreateDataVaultKeyPairs(request.UserID, o.ctx, wallet.WithUnlockByPassphrase(request.LocalKMSPassphrase))
		if err != nil {
			logutil.LogInfo(logger, CommandName, CreateProfileMethod, err.Error())
			return command.NewExecuteError(CreateProfileErrorCode, err)
		}
	}
	logutil.LogDebug(logger, CommandName, CreateProfileMethod, logSuccess,
		logutil.CreateKeyValueString(logUserIDKey, request.UserID))
	return nil
}
func (o *Command) UpdateProfile(rw io.Writer, req io.Reader) command.Error {
	request := &CreateOrUpdateProfileRequest{}
	err := json.NewDecoder(req).Decode(&request)
	if err != nil {
		logutil.LogInfo(logger, CommandName, UpdateProfileMethod, err.Error())
		return command.NewValidationError(InvalidRequestErrorCode, err)
	}
	err = wallet.UpdateProfile(request.UserID, o.ctx, prepareProfileOptions(request)...)
	if err != nil {
		logutil.LogInfo(logger, CommandName, UpdateProfileMethod, err.Error())
		return command.NewExecuteError(UpdateProfileErrorCode, err)
	}
	logutil.LogDebug(logger, CommandName, UpdateProfileMethod, logSuccess,
		logutil.CreateKeyValueString(logUserIDKey, request.UserID))
	return nil
}