virtual void copyTo(ISecUser& destination) { destination.setAuthenticateStatus(getAuthenticateStatus()); destination.setName(getName()); destination.setFullName(getFullName()); destination.setFirstName(getFirstName()); destination.setLastName(getLastName()); destination.setEmployeeID(getEmployeeID()); destination.setRealm(getRealm()); destination.setFqdn(getFqdn()); destination.setPeer(getPeer()); destination.credentials().setPassword(credentials().getPassword()); destination.credentials().setSessionToken(credentials().getSessionToken()); destination.credentials().setSignature(credentials().getSignature()); CDateTime exp; credentials().getPasswordExpiration(exp); destination.credentials().setPasswordExpiration(exp); CDateTime tmpTime; destination.setPasswordExpiration(getPasswordExpiration(tmpTime)); destination.setStatus(getStatus()); CriticalBlock b(crit); Owned<IPropertyIterator> Itr = m_parameters->getIterator(); ForEach(*Itr) { destination.setProperty(Itr->getPropKey(),m_parameters->queryProp(Itr->getPropKey())); } // DBGLOG("Copied name %s to %s",getName(),destination.getName()); }
virtual void copyTo(ISecUser& destination) { destination.setAuthenticateStatus(getAuthenticateStatus()); destination.setName(getName()); destination.setFullName(getFullName()); destination.setFirstName(getFirstName()); destination.setLastName(getLastName()); destination.setRealm(getRealm()); destination.setFqdn(getFqdn()); destination.setPeer(getPeer()); destination.credentials().setPassword(credentials().getPassword()); CDateTime tmpTime; destination.setPasswordExpiration(getPasswordExpiration(tmpTime)); destination.setStatus(getStatus()); if(m_parameters.get()==NULL) return; CriticalBlock b(crit); Owned<IPropertyIterator> Itr = m_parameters->getIterator(); Itr->first(); while(Itr->isValid()) { destination.setProperty(Itr->getPropKey(),m_parameters->queryProp(Itr->getPropKey())); Itr->next(); } //addToken is not currently implemented.... // DBGLOG("Copied name %s to %s",getName(),destination.getName()); }
int CSoapService::processHeader(CHeader* header, IEspContext* ctx) { int num = header->getNumBlocks(); if(ctx == NULL) return 0; int returnValue = 0; bool authenticated = !ctx->toBeAuthenticated(); for (int i = 0; i < num; i++) { IRpcMessage* oneblock = header->getHeaderBlock(i); if(oneblock == NULL) continue; if(strcmp(oneblock->get_name(), "Security") == 0) { bool encodeXML = oneblock->getEncodeXml(); oneblock->setEncodeXml(false); StringBuffer username, password,realm; oneblock->get_value("UsernameToken/Username", username); oneblock->get_value("UsernameToken/Password", password); oneblock->get_value("RealmToken/Realm", realm); oneblock->setEncodeXml(encodeXML); //DBGLOG("username=%s, password=%s", username.str(), password.str()); if(username.length() > 0) { ctx->setUserID(username.str()); ctx->setPassword(password.str()); if(realm.length()>0) ctx->setRealm(realm.str()); ISecManager* secmgr = ctx->querySecManager(); if(secmgr != NULL) { ISecUser *user = ctx->queryUser(); if(user==NULL) { user = secmgr->createUser(username.str()); ctx->setUser(user); } if(user == NULL) { WARNLOG("Couldn't create ISecUser object for %s", username.str()); } user->setName(username.str()); user->credentials().setPassword(password.str()); if(realm.length()>0) user->setRealm(realm.str()); } if(ctx->toBeAuthenticated()) { if(stricmp(m_soapbinding->getTransportType(), "http") == 0) { EspHttpBinding* httpbinding = dynamic_cast<EspHttpBinding*>(m_soapbinding.get()); authenticated = httpbinding->doAuth(ctx); } else { authenticated = false; } if(!authenticated) returnValue = SOAP_AUTHENTICATION_ERROR; break; } } } } if (returnValue == 0) { if (authenticated) return 0; returnValue = SOAP_AUTHENTICATION_REQUIRED; } StringBuffer peerStr; ctx->getPeer(peerStr); const char* userId = ctx->queryUserId(); VStringBuffer msg("SOAP request from %s@%s.", (userId&&*userId)?userId:"unknown", (peerStr.length()>0)?peerStr.str():"unknown"); if (returnValue == SOAP_AUTHENTICATION_ERROR) msg.append(" User authentication failed"); else msg.append(" User authentication required"); DBGLOG("%s", msg.str()); return returnValue; }