/* * * Copyright (c) 1999 - 2011 my-Channels Ltd * Copyright (c) 2012 - 2017 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. * * Use, reproduction, transfer, publication or disclosure is prohibited except as specifically provided for in your License Agreement with Software AG. * */ #include "nSampleApp.h" #include "authserver.h" #include "LoginMonitor.h" #include "nSessionAttributes.h" #include "nRealmNode.h" #include 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) { try { // // 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 // std::cout << "Press any key to quit !\n"; std::cin.ignore(); m_pRealm->close(); if (m_pRealm->delRef()) delete m_pRealm; delete pLogMonitor; } catch (Exception e) { std::cout << e.message() << std::endl; } } 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 (pNodes, argc - 1); delete[] pNodes; return 0; }