当前位置: 首页>>代码示例>>C++>>正文


C++ Credentials类代码示例

本文整理汇总了C++中Credentials的典型用法代码示例。如果您正苦于以下问题:C++ Credentials类的具体用法?C++ Credentials怎么用?C++ Credentials使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Credentials类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: credentialsFromFile

/**
 * Read Credentials from file.
 * @param path
 * @return
 */
Credentials Credentials::credentialsFromFile(const QString &path)
{
    Credentials credentials;
    credentials.loadCredentialsFromFile(path);

    return credentials;
}
开发者ID:Kri-7-q,项目名称:PWKeeper,代码行数:12,代码来源:credentials.cpp

示例2: String

bool NativeAuthListenerInternal::VerifyCredentials(
    /* [in] */ const char* authMechanism,
    /* [in] */ const char* peerName,
    /* [in] */ const Credentials& credentials)
{
    String userName = credentials.IsSet(AuthListener::CRED_USER_NAME) ?
            String(credentials.GetUserName().c_str()) : String(NULL);

    String cert = credentials.IsSet(AuthListener::CRED_CERT_CHAIN) ?
            String(credentials.GetCertChain().c_str()) : String(NULL);

    ECode ec;
    Boolean acceptable;
    {
        AutoLock lock(mBusPtr->mBaAuthenticationChangeLock);

        AutoPtr<IAuthListenerInternal> al;
        mAuthListener->Resolve(EIID_IAuthListenerInternal, (IInterface**)&al);
        if (al == NULL) {
            Logger::E("NativeAuthListenerInternal", "VerifyCredentials(): Can't get new local reference to AuthListener");
            return false;
        }

        ec = al->VerifyCredentials(String(authMechanism), String(peerName), userName, cert, &acceptable);
    }

    return FAILED(ec) ? false : (bool)acceptable;

}
开发者ID:elastos,项目名称:Elastos5,代码行数:29,代码来源:NativeAuthListenerInternal.cpp

示例3: TYPED_TEST

// This test verifies that the pending future returned by
// 'Authenticator::authenticate()' is properly failed when the Authenticator is
// destructed in the middle of authentication.
TYPED_TEST(CRAMMD5Authentication, AuthenticatorDestructionRace)
{
  // Launch a dummy process (somebody to send the AuthenticateMessage).
  UPID pid = spawn(new ProcessBase(), true);

  Credential credential1;
  credential1.set_principal("benh");
  credential1.set_secret("secret");

  Credentials credentials;
  Credential* credential2 = credentials.add_credentials();
  credential2->set_principal(credential1.principal());
  credential2->set_secret(credential1.secret());

  secrets::load(credentials);

  Future<Message> message =
    FUTURE_MESSAGE(Eq(AuthenticateMessage().GetTypeName()), _, _);

  Try<Authenticatee*> authenticatee = TypeParam::TypeAuthenticatee::create();
  CHECK_SOME(authenticatee);

  Future<bool> client =
    authenticatee.get()->authenticate(pid, UPID(), credential1);

  AWAIT_READY(message);

  Try<Authenticator*> authenticator = TypeParam::TypeAuthenticator::create();
  CHECK_SOME(authenticator);

  authenticator.get()->initialize(message.get().from);

  // Drop the AuthenticationStepMessage from authenticator to keep
  // the authentication from getting completed.
  Future<AuthenticationStepMessage> authenticationStepMessage =
    DROP_PROTOBUF(AuthenticationStepMessage(), _, _);

  Future<Option<string>> principal = authenticator.get()->authenticate();

  AWAIT_READY(authenticationStepMessage);

  // At this point 'AuthenticatorProcess::authenticate()' has been
  // executed and its promise associated with the promise returned
  // by 'Authenticator::authenticate()'.
  // Authentication should be pending.
  ASSERT_TRUE(principal.isPending());

  // Now delete the authenticator.
  delete authenticator.get();

  // The future should be failed at this point.
  AWAIT_FAILED(principal);

  terminate(pid);
  delete authenticatee.get();
}
开发者ID:abhishekamralkar,项目名称:mesos,代码行数:59,代码来源:cram_md5_authentication_tests.cpp

示例4: v

    ACES::Word<HuboVia>* Device::processDS(ACES::Word<float>* s){
        float pos = s->getData();       //User given set point

        //Calculate the absolute command based on the configured zero and
        //direction.
        Credentials* c = (Credentials*)credentials;
        double goal = c->getDirection()*pos + c->getZero(); 
        HuboVia v(goal);

        //Copy word info from state
        ACES::Word<HuboVia>* w = new ACES::Word<HuboVia>(v, s->getNodeID(),
                                                         s->getDevID(),
                                                         s->getMode(), NULL);
        w->setCred(credentials);    
        return w;
    }
开发者ID:bob2827,项目名称:conductor,代码行数:16,代码来源:huboVia.cpp

示例5: setConnect

void UploadProgressModel::setConnect(bool _connect, const Credentials& _c)
{
    if(_connect)
    {
        setAdmin(_c.admin());
        setShowOK(true);
        setShowError(true);
        setShowArchive(false);
        setShowUploading(true);
        setShowCopying(true);
        setIsPaused(false);
        setVisiblePause(_c.admin());
    }
    else
    {
        clear();
    }
}
开发者ID:alexvrn,项目名称:projects,代码行数:18,代码来源:uploadprogressmodel.cpp

示例6: TYPED_TEST

TYPED_TEST(CRAMMD5Authentication, Success)
{
  // Launch a dummy process (somebody to send the AuthenticateMessage).
  UPID pid = spawn(new ProcessBase(), true);

  Credential credential1;
  credential1.set_principal("benh");
  credential1.set_secret("secret");

  Credentials credentials;
  Credential* credential2 = credentials.add_credentials();
  credential2->set_principal(credential1.principal());
  credential2->set_secret(credential1.secret());

  Future<Message> message =
    FUTURE_MESSAGE(Eq(AuthenticateMessage().GetTypeName()), _, _);

  Try<Authenticatee*> authenticatee = TypeParam::TypeAuthenticatee::create();
  CHECK_SOME(authenticatee);

  Future<bool> client =
    authenticatee.get()->authenticate(pid, UPID(), credential1);

  AWAIT_READY(message);

  Try<Authenticator*> authenticator = TypeParam::TypeAuthenticator::create();
  CHECK_SOME(authenticator);

  EXPECT_SOME(authenticator.get()->initialize(credentials));

  Future<Option<string>> principal =
    authenticator.get()->authenticate(message.get().from);

  AWAIT_EQ(true, client);
  AWAIT_READY(principal);
  EXPECT_SOME_EQ("benh", principal.get());

  terminate(pid);

  delete authenticator.get();
  delete authenticatee.get();
}
开发者ID:ankurcha,项目名称:mesos,代码行数:42,代码来源:cram_md5_authentication_tests.cpp

示例7: sltQueryLogon

void ServiceClient::sltQueryLogon(const Credentials& c)
{
    m_Credentials = c;

    bool isVal = false;
    m_iPortService = Setting::value(Setting::KEY_PORT_SERVICE).toInt(&isVal);
    if(!isVal)
        m_iPortService = 0;
    m_iPortServer  = Setting::value(Setting::KEY_PORT_SERVER).toInt(&isVal);
    if(!isVal)
        m_iPortServer = 0;

    //Попытка установки соединения
    if(!Connect(c.service(), m_iPortService))
    {
        //
        //emit isLogon(c, true);
        qDebug() << QString("Unable to connect to remote server! port_server=%1, por_service=%2").arg(m_iPortServer).arg(m_iPortService);
        QMessageBox::information(0, "", "Не удается подключиться к удаленному серверу!");
        return;
    }
}
开发者ID:alexvrn,项目名称:projects,代码行数:22,代码来源:serviceclient.cpp

示例8: RequestCredentials

bool SrpKeyXListener::RequestCredentials(const char* authMechanism,
                                         const char* authPeer,
                                         uint16_t authCount,
                                         const char* userId,
                                         uint16_t credMask,
                                         Credentials& creds)
{
    if (strcmp(authMechanism, "ALLJOYN_SRP_KEYX") == 0 || strcmp(authMechanism, "ALLJOYN_PIN_KEYX") == 0 || strcmp(authMechanism, "ALLJOYN_ECDHE_PSK") == 0) {
        if (credMask & AuthListener::CRED_PASSWORD) {
            if (authCount <= 3) {
                qcc::String passCodeFromGet;
                if (m_GetPassCode) {
                    m_GetPassCode(passCodeFromGet);
                }
                creds.SetPassword(m_GetPassCode ? passCodeFromGet.c_str() : m_PassCode.c_str());
                return true;
            } else {
                return false;
            }
        }
    }
    return false;
}
开发者ID:muzzley,项目名称:alljoyn-muzzley-gateway-connector,代码行数:23,代码来源:SrpKeyXListener.cpp

示例9: Q_UNUSED

}

QString ServiceProvider::resourceName() const
{
    return m_providerName;
}

void ServiceProvider::relay(Jolie::Server *server, int descriptor,
                                      const Jolie::Message &message)
{
    Q_UNUSED(server)

    if (message.operationName() == "startConnection") {
        kDebug() << "reset token";
        //add the identity
        Credentials identity;
        QByteArray identityByteArray = JolieMessage::field(JolieMessage::Field::IDENTITY, message);
        QDataStream stream(&identityByteArray, QIODevice::ReadOnly);
        stream >> identity;
        AuthorizationManager::self()->d->addCredentials(identity);

        Jolie::Message response(message.resourcePath(), message.operationName(), message.id());
        QByteArray uuid = JolieMessage::field(JolieMessage::Field::UUID, message);
        response = appendToken(response, identity.id().toAscii(), uuid);
        AuthorizationManager::self()->d->server->sendReply(descriptor, response);

        return;
    }
    
    if (JolieMessage::field(JolieMessage::Field::TOKEN, message).isEmpty()) {
        Jolie::Message response(message.resourcePath(), message.operationName(), message.id());
开发者ID:vasi,项目名称:kdelibs,代码行数:31,代码来源:serviceprovider.cpp

示例10: lock

bool NativeAuthListenerInternal::RequestCredentials(
    /* [in] */ const char* authMechanism,
    /* [in] */ const char* authPeer,
    /* [in] */ uint16_t authCount,
    /* [in] */ const char* userName,
    /* [in] */ uint16_t credMask,
    /* [in] */ Credentials& credentials)
{
    /*
     * Take the authentication changed lock to prevent clients from changing the
     * authListener out from under us while we are calling out into it.
     */
    AutoPtr<ICredentials> cs;
    {
        AutoLock lock(mBusPtr->mBaAuthenticationChangeLock);

        AutoPtr<IAuthListenerInternal> al;
        mAuthListener->Resolve(EIID_IAuthListenerInternal, (IInterface**)&al);
        if (al == NULL) {
            Logger::E("NativeAuthListenerInternal", "RequestCredentials(): Can't get new local reference to AuthListener");
            return false;
        }

        al->RequestCredentials(String(authMechanism), String(authPeer),
                (Int32)authCount, String(userName), (Int32)credMask, (ICredentials**)&cs);
    }

    if (cs == NULL) {
        Logger::E("NativeAuthListenerInternal", "RequestCredentials(): Null return from method");
        return false;
    }

    AutoPtr< ArrayOf<Byte> > password;
    cs->GetPassword((ArrayOf<Byte>**)&password);
    if (password != NULL) {
        credentials.SetPassword(qcc::String((const char*)password->GetPayload(), password->GetLength()));
    }

    String strUserName;
    cs->GetUserName(&strUserName);
    if (!strUserName.IsNull()) {
        credentials.SetUserName(strUserName.string());
    }

    String certificateChain;
    cs->GetCertificateChain(&certificateChain);
    if (!certificateChain.IsNull()) {
        credentials.SetCertChain(certificateChain.string());
    }

    String privateKey;
    cs->GetPrivateKey(&privateKey);
    if (!privateKey.IsNull()) {
        credentials.SetPrivateKey(privateKey.string());
    }

    AutoPtr< ArrayOf<Byte> > logonEntry;
    cs->GetLogonEntry((ArrayOf<Byte>**)&logonEntry);
    if (logonEntry != NULL) {
        credentials.SetLogonEntry(qcc::String((const char*)logonEntry->GetPayload(), logonEntry->GetLength()));
    }

    AutoPtr<IInteger32> expiration;
    cs->GetExpiration((IInteger32**)&expiration);
    if (expiration != NULL) {
        Int32 seconds;
        expiration->GetValue(&seconds);
        credentials.SetExpiration(seconds);
    }

    return true;
}
开发者ID:elastos,项目名称:Elastos5,代码行数:72,代码来源:NativeAuthListenerInternal.cpp

示例11: newConversationID

AuthenticateResult SCRAMAuthenticator::authenticate(const Credentials& creds, Poco::UInt32 conversationID)
{
	if (conversationID == 0)
	{
		conversationID = newConversationID();

		Conversation::Ptr pConv = new Conversation;
		pConv->username = creds.getAttribute(Credentials::ATTR_USERNAME);
		pConv->clientNonce = creds.getAttribute(Credentials::ATTR_NONCE);
		pConv->serverNonce = createNonce();
		pConv->salt = saltForUser(pConv->username, pConv->iterations);

		if (!pConv->salt.empty())
		{
			Credentials serverCreds;
			serverCreds.setAttribute(Credentials::ATTR_NONCE, pConv->serverNonce);
			serverCreds.setAttribute(Credentials::ATTR_SALT, pConv->salt);
			serverCreds.setAttribute(Credentials::ATTR_ITERATIONS, Poco::NumberFormatter::format(pConv->iterations));
		
			_conversations.add(conversationID, pConv);
			pConv->state = STATE_START;

			return AuthenticateResult(AuthenticateResult::AUTH_CONTINUE, serverCreds, conversationID);
		}
	}
	else
	{
		Conversation::Ptr pConv = _conversations.get(conversationID);
		if (pConv)
		{
			if (pConv->state == STATE_START)
			{
				const std::string receivedServerNonce = creds.getAttribute(Credentials::ATTR_NONCE);
				const std::string receivedClientProof = creds.getAttribute(Credentials::ATTR_PASSWORD);
				
				const std::string saltedPassword = hashForUser(pConv->username);
				std::string clientAuthMessage;
				const std::string computedClientProof = computeClientProof(pConv->username, pConv->clientNonce, pConv->salt, pConv->iterations, saltedPassword, pConv->serverNonce, clientAuthMessage);
				
				if (computedClientProof == receivedClientProof && pConv->serverNonce == receivedServerNonce)
				{
					std::string serverSignature = computeServerSignature(saltedPassword, clientAuthMessage);
					
					Credentials serverCreds;
					serverCreds.setAttribute(Credentials::ATTR_SIGNATURE, serverSignature);
					
					pConv->state = STATE_CLIENT_AUTH;
					return AuthenticateResult(AuthenticateResult::AUTH_CONTINUE, serverCreds, conversationID);		
				}
				else
				{
					_conversations.remove(conversationID);
				}
			}
			else if (pConv->state == STATE_CLIENT_AUTH)
			{
				_conversations.remove(conversationID);
				Credentials serverCreds;
				serverCreds.setAttribute(Credentials::ATTR_USERNAME, pConv->username);					
				return AuthenticateResult(AuthenticateResult::AUTH_DONE, serverCreds, conversationID);
			}
		}
	}
	return AuthenticateResult();
}
开发者ID:macchina-io,项目名称:macchina.io,代码行数:65,代码来源:SCRAMAuthenticator.cpp

示例12: exists

/**
  Sets the credentials we'll be using. You should acquire
  the credentals before passing them in. Also, you need to
  keep the credentials alive as long as this Context 
  exists (easily done).
*/
void Context::SetCredentials ( Credentials & cred )
{
  assert ( cred.IsValid ( ) );
  m_cred = &cred;
}
开发者ID:tomasr,项目名称:wsspi,代码行数:11,代码来源:sspictxt.cpp

示例13: TRACE_MESSAGE2

bool KLUPD::HttpProtocol::switchAuthorization(const Path &fileName, const Path &relativeUrlPath,
                const DownloadProgress::AuthorizationTarget &authorizationTarget, const Address &proxyAddress,
                bool &authorizationTypeSwitched,
                bool &ntlmAuthorizationTriedAlready)
{
    authorizationTypeSwitched = false;
    const AuthorizationType currentAuthorizationType = m_authorizationDriver.currentAuthorizationType();

    if(!m_downloadProgress.authorizationTargetEnabled(authorizationTarget))
    {
        TRACE_MESSAGE2("Failed to switch authorization by product '%s'", DownloadProgress::toString(authorizationTarget).c_str());
        return false;
    }

    // authorization needed
    bool needUpdateCredentials = false;
    const bool switchedToNextAuthorizationSuccess = m_authorizationDriver.switchToNextAuthorization(needUpdateCredentials,
        ntlmAuthorizationTriedAlready);

    // report authorization failed
    if(!switchedToNextAuthorizationSuccess || needUpdateCredentials)
    {
        if(m_authorizationDriver.credentials().userName().empty())
            informAuthorizationFailed(authorizationTarget, relativeUrlPath + fileName, proxyAddress.BuildURI().toWideChar());
        else
        {
            informAuthorizationFailed(authorizationTarget, relativeUrlPath + fileName,
                m_authorizationDriver.credentials().userName() + L"@" + proxyAddress.BuildURI().toWideChar());
        }
    }

    if(!switchedToNextAuthorizationSuccess)
        return false;

    if(needUpdateCredentials)
    {
        Credentials newCredentials = m_authorizationDriver.credentials();
        // proxy authorization failed, asking credentials to authenticate on proxy
        if(!m_downloadProgress.requestAuthorizationCredentials(newCredentials))
        {
            TRACE_MESSAGE("User cancelled HTTP authorization");
			// Treat cancel as "don't use credentials at all"
            //m_authorizationDriver.resetNtlmState();
			newCredentials.cancel( true );
			m_authorizationDriver.credentials( newCredentials );
            m_authorizationDriver.currentAuthorizationType(noAuthorization);

            // reset authorization to initial state to keep object consistency
            bool needUpdateCredentials = false;
            bool ntlmAuthorizationTriedAlready = false;
            m_authorizationDriver.switchToNextAuthorization(needUpdateCredentials, ntlmAuthorizationTriedAlready);
            return false;
        }
        // no credentials specified
        if(newCredentials.userName().empty())
        {
            TRACE_MESSAGE("Credentials to authenticate on proxy were asked, but not obtained from Product: user name is empty");
            return false;
        }

        TRACE_MESSAGE2("Credentials to authenticate on proxy were asked, user name provided is '%S'",
            newCredentials.userName().toWideChar());

        m_authorizationDriver.credentials(newCredentials);
    }

    authorizationTypeSwitched = currentAuthorizationType != m_authorizationDriver.currentAuthorizationType();
    return true;
}
开发者ID:hackshields,项目名称:antivirus,代码行数:69,代码来源:NetFacHTTP.cpp

示例14: SetDefaults

 void SetDefaults() {
   www_credentials.SetDefaults();
   ftp_credentials.SetDefaults();
 }
开发者ID:Advi42,项目名称:XCSoar,代码行数:4,代码来源:Settings.hpp


注:本文中的Credentials类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。