/* \n Copyright 1999-2011 (c) My-Channels \n Copyright (c) 2012-2014 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors. \n\n Use, reproduction, transfer, publication or disclosure is prohibited except as specifically provided for in your License Agreement with Software AG.\n */\n #include "nSampleApp.h" #include "authserver.h" #include "LoginMonitor.h" #include "nSessionAttributes.h" #include "nRealmNode.h" #ifdef WIN32 #include #endif using namespace com::pcbsys::nirvana::client; using namespace com::pcbsys::nirvana::nAdminAPI; using namespace com::pcbsys::nirvana::nAdminAPI::apps; // //This example, demonstrates how the admin api can be used in order to set up //permissions for users connecting to a realm. When a user connects, the realm acl //will be set for the user. In reality, the program would set other permissions for //channel & queues when connections are received and the client app would have //to wait for some kind of application level handshake to take place before //connecting to those objects. //This is purely to demonstrate the idea behind writing your own authorisation //server. // /// /// * Consruct an instance of this class using the command line arguments passed /// * when it is executed. /// AuthServer::AuthServer(std::string *pUrls, int nUrl) : m_pRealm(NULL) { // // Create the session attributes // nSessionAttributes *pAttr = new nSessionAttributes(pUrls, nUrl); // // Create realm object // m_pRealm = new nRealmNode(pAttr); // // Now create the login monitor and add it to the realm node // LoginMonitor *pLogMonitor = new LoginMonitor(this); m_pRealm->addConnectionListener(pLogMonitor); // // At this point the LoginMonitor will be getting all of the // currently connected connections and whenever a new connection // is made // printf("Press any key to quit !\n"); try { char buffer[80]; gets(buffer); } catch (Exception read) //Ignore this { } m_pRealm->close(); if (m_pRealm->delRef()) delete m_pRealm; delete pLogMonitor; } int main (int argc, char** argv) { std::string *pNodes = new std::string[argc - 1]; for (int iNode = 1; iNode < argc; iNode++) pNodes[iNode - 1] = argv[iNode]; AuthServer *pSimple = new AuthServer (pNodes, argc - 1); return 0; }