public WSUserStoreManager(String serverUrl, String cookie, ConfigurationContext configCtxt) throws UserStoreException { try { stub = new RemoteUserStoreManagerServiceStub(configCtxt, serverUrl + SERVICE_NAME); ServiceClient client = stub._getServiceClient(); Options option = client.getOptions(); option.setManageSession(true); option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie); } catch (AxisFault e) { handleException(e.getMessage(), e); } }
/** * Query the remote user manager and retrieve the list of role names associated for the given * user name. This is used when authorization for certain actions are appropriately delegated * to other components (ex:- Lifecycle Management). * * @param user Username * @return the list of roles to which the user belongs to. * @throws org.wso2.carbon.appmgt.api.AppManagementException If and error occurs while accessing the admin service */ public String[] getRolesOfUser(String user) throws AppManagementException { CarbonUtils.setBasicAccessSecurityHeaders(username, password, true, userStoreManager._getServiceClient()); if (cookie != null) { userStoreManager._getServiceClient().getOptions().setProperty(HTTPConstants.COOKIE_STRING, cookie); } try { String[] roles = userStoreManager.getRoleListOfUser(user); ServiceContext serviceContext = userStoreManager. _getServiceClient().getLastOperationContext().getServiceContext(); cookie = (String) serviceContext.getProperty(HTTPConstants.COOKIE_STRING); return roles; } catch (Exception e) { throw new AppManagementException("Error while accessing backend services for " + "user role list", e); } }
/** * Query the remote user manager and retrieve the list of role names in users-store * * * @return the list of roles * @throws org.wso2.carbon.appmgt.api.AppManagementException If and error occurs while accessing the admin service */ public String[] getRoleNames() throws AppManagementException { CarbonUtils.setBasicAccessSecurityHeaders(username, password, true, userStoreManager._getServiceClient()); if (cookie != null) { userStoreManager._getServiceClient().getOptions().setProperty(HTTPConstants.COOKIE_STRING, cookie); } try { String[] roles = userStoreManager.getRoleNames(); ServiceContext serviceContext = userStoreManager. _getServiceClient().getLastOperationContext().getServiceContext(); cookie = (String) serviceContext.getProperty(HTTPConstants.COOKIE_STRING); return roles; } catch (Exception e) { throw new AppManagementException("Error while accessing backend services for " + "getting list of all the roles.", e); } } }
public WSUserStoreManager(String serverUrl, String cookie, ConfigurationContext configCtxt) throws UserStoreException { try { stub = new RemoteUserStoreManagerServiceStub(configCtxt, serverUrl + "RemoteUserStoreManagerService"); ServiceClient client = stub._getServiceClient(); Options option = client.getOptions(); option.setManageSession(true); option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie); } catch (AxisFault e) { handleException(e.getMessage(), e); } }
public WSUserStoreManager(String userName, String password, String serverUrl, ConfigurationContext configCtxt) throws UserStoreException { try { if (serverUrl != null && !serverUrl.endsWith("/")) { serverUrl += "/"; } stub = new RemoteUserStoreManagerServiceStub(configCtxt, serverUrl + SERVICE_NAME); HttpTransportProperties.Authenticator authenticator = new HttpTransportProperties.Authenticator(); authenticator.setUsername(userName); authenticator.setPassword(password); authenticator.setPreemptiveAuthentication(true); ServiceClient client = stub._getServiceClient(); Options option = client.getOptions(); option.setManageSession(true); option.setProperty(org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE, authenticator); } catch (AxisFault e) { handleException(e.getMessage(), e); } }
public RemoteAuthorizationManagerClient() throws AppManagementException { AppManagerConfiguration config = ServiceReferenceHolder.getInstance(). getAPIManagerConfigurationService().getAPIManagerConfiguration(); String serviceURL = config.getFirstProperty(AppMConstants.AUTH_MANAGER_URL); username = config.getFirstProperty(AppMConstants.AUTH_MANAGER_USERNAME); password = config.getFirstProperty(AppMConstants.AUTH_MANAGER_PASSWORD); if (serviceURL == null || username == null || password == null) { throw new AppManagementException("Required connection details for authentication " + "manager not provided"); } try { authorizationManager = new RemoteAuthorizationManagerServiceStub(null, serviceURL + "RemoteAuthorizationManagerService"); userStoreManager = new RemoteUserStoreManagerServiceStub(null, serviceURL + "RemoteUserStoreManagerService"); for (ServiceClient client : new ServiceClient[] { authorizationManager._getServiceClient(), userStoreManager._getServiceClient()}) { Options options = client.getOptions(); options.setTimeOutInMilliSeconds(TIMEOUT_IN_MILLIS); options.setProperty(HTTPConstants.SO_TIMEOUT, TIMEOUT_IN_MILLIS); options.setProperty(HTTPConstants.CONNECTION_TIMEOUT, TIMEOUT_IN_MILLIS); options.setCallTransportCleanup(true); options.setManageSession(true); } } catch (AxisFault axisFault) { throw new AppManagementException("Error while initializing the user management stubs", axisFault); } }
userStoreManagerStub = new RemoteUserStoreManagerServiceStub(configContext, serviceURL + "RemoteUserStoreManagerService"); ServiceClient svcClient = userStoreManagerStub._getServiceClient(); CarbonUtils.setBasicAccessSecurityHeaders(username, password, true,svcClient); Options options = svcClient.getOptions();