I have user details and I want to the services and exchange codes he is entitled to. How to achieve it?
Hello @Ashish Gupta,
In Developer Guide for your language option, for example OpenDacs - Java Development Guides look up AuthorizationAgent -> getPEList().
If you are just starting with OpenDACS I would suggest to first work through OpenDACS QuickStart Guide and OpenDACS Tutorials (I include likes to Java, the exact same materials can be found in C++ and .Net),
as together, these materials give a working understanding of the fundamentals of OpenDACS API.
Hope this helps
Hello @Ashish Gupta
You can modify DacsSubscribeClient.java to get the list of services on DACS as example snipped source code below:
private Vector<AuthorizationServiceAttributes> _getServiceAttributes() { try { // AuthorizableServiceAttributes is an instance for keeping // attributes information of an authorizable service. Vector<AuthorizationServiceAttributes> services = new Vector<AuthorizationServiceAttributes>(); /* * Pass the vector of AuthorizableServiceAttribute instances as * a parameter of the AuthorizationAgent's getServiceAttributes() * method.It will be pushed the attributes of all authorizable * services within that method. */ AuthorizationCheckResult authCheckResult = _agent.getServiceAttributes(services); // Check the result of calling the getServiceAttributes() method. if (authCheckResult == AuthorizationCheckResult.ACCESS_ALLOWED) { // Calling the method success. return services; } else { // Calling the method failed, return null. return null; } } catch (AuthorizationException ae) { System.err.println("AuthorizationAgent.getServiceAttributes() failed"); return null; } }
Then, check if the user is entitled to each service.
public void checkAuthorizableServices() { Vector<AuthorizationServiceAttributes> services = _getServiceAttributes(); if (services != null) { System.out.println("Connected DACS server has " + services.size() + " authorizable service(s)"); for (int i = 0; i < services.size(); i++) { AuthorizationServiceAttributes attrs = services.get(i); System.out.println("#" + (i + 1) + "#"); System.out.println(" Service ID: " + attrs.getServiceId()); System.out.println(" Service Name: " + attrs.getServiceName()); System.out.println(" Service Type: " + attrs.getServiceType()); System.out.println(" Service Qos: " + attrs.getServiceQoS()); AuthorizationCheckStatus authCheckStatus = new AuthorizationCheckStatus(); try { AuthorizationCheckResult authCheckResult = _agent.checkSubscription(_handle, _usage, _reqtype, authCheckStatus,services.get(i).getServiceName()); if (authCheckResult == AuthorizationCheckResult.ACCESS_ALLOWED) { System.out.println("[" + _daemonHost + "] " + _name + " allowed subscription access to service " + services.get(i).getServiceName()); } else { System.out.println("[" + _daemonHost + "] " + _name + " denied subscription access to service " + services.get(i).getServiceName()); System.out.println("status message - " + authCheckStatus.getStatusText()); } } catch (AuthorizationException ae) { // In case the exception occurs during calling method. System.err.println("[" + _daemonHost + "] " + _name + " check subscription service " + services.get(i).getServiceName() + " failed"); } } } }
The example output: