void loadOutHeader() throws XdsInternalException { if (serviceClient == null) return; OperationContext oc = serviceClient.getLastOperationContext(); if (oc == null) return; HashMap<String, MessageContext> ocs = oc.getMessageContexts(); MessageContext out = ocs.get("Out"); if (out == null) return; outHeader = Util.deep_copy(out.getEnvelope().getHeader()); }
void loadInHeader() throws XdsInternalException { if (serviceClient == null) return; OperationContext oc = serviceClient.getLastOperationContext(); if (oc == null) return; HashMap<String, MessageContext> ocs = oc.getMessageContexts(); MessageContext in = ocs.get("In"); if (in == null) return; if (in.getEnvelope() == null) return; if (in.getEnvelope().getHeader() == null) return; inHeader = Util.deep_copy(in.getEnvelope().getHeader()); logger.info("incoming header loaded"); }
private String login() throws AxisFault { if (parameters.get(SERVER_URL) == null || parameters.get(USERNAME) == null || parameters.get(PASSWORD) == null) { throw new AxisFault("SSO Configurator authentication details unspecified"); } String host; try { host = new URL(parameters.get(SERVER_URL)).getHost(); } catch (MalformedURLException e) { throw new AxisFault("SSO Configurator provider URL is malformed", e); } AuthenticationAdminStub authAdminStub = new AuthenticationAdminStub(null, parameters.get(SERVER_URL) + "/services/AuthenticationAdmin"); ServiceClient client = authAdminStub._getServiceClient(); Options options = client.getOptions(); options.setManageSession(true); try { authAdminStub.login(parameters.get(USERNAME), parameters.get(PASSWORD), host); ServiceContext serviceContext = authAdminStub. _getServiceClient().getLastOperationContext().getServiceContext(); String sessionCookie = (String) serviceContext.getProperty(HTTPConstants.COOKIE_STRING); return sessionCookie; } catch (RemoteException e) { throw new AxisFault("Error while contacting the authentication admin services", e); } catch (LoginAuthenticationExceptionException e) { throw new AxisFault("Error while authenticating against the SSO IDP admin", e); } }
public String login(String username, char[] password, String backendURL) throws MalformedURLException, RemoteException, LoginAuthenticationExceptionException { String authenticationServiceURL = backendURL + "AuthenticationAdmin"; AuthenticationAdminStub authenticationAdminStub = new AuthenticationAdminStub(authenticationServiceURL); ServiceClient client = authenticationAdminStub._getServiceClient(); String hostName = new URL(backendURL).getHost(); Options options = client.getOptions(); options.setManageSession(true); if (log.isDebugEnabled()) { log.debug("UserName : " + username + " Password : " + String.valueOf(password) + " HostName : " + hostName); } boolean isLoggedIn = authenticationAdminStub.login(username, String.valueOf(password), hostName); assert isLoggedIn : "Login failed!"; log.debug("getting sessionCookie"); ServiceContext serviceContext = authenticationAdminStub._getServiceClient().getLastOperationContext().getServiceContext(); sessionCookie = (String) serviceContext.getProperty(HTTPConstants.COOKIE_STRING); assert sessionCookie != null : "Logged in session cookie is null"; if (log.isDebugEnabled()) { log.debug("sessionCookie : " + sessionCookie); } log.info("Successfully logged in : " + sessionCookie); return sessionCookie; }
public String login(String userName, String password, String host) throws LoginAuthenticationExceptionException, RemoteException { Boolean loginStatus; ServiceContext serviceContext; String sessionCookie; loginStatus = authenticationAdminStub.login(userName, password, host); if (!loginStatus) { throw new LoginAuthenticationExceptionException("Login Unsuccessful. Return false as a login status by Server"); } log.info("Login Successful"); serviceContext = authenticationAdminStub._getServiceClient().getLastOperationContext().getServiceContext(); sessionCookie = (String) serviceContext.getProperty(HTTPConstants.COOKIE_STRING); if (log.isDebugEnabled()) { log.debug("SessionCookie :" + sessionCookie); } return sessionCookie; }
private String login() throws AxisFault { if (backendServerURL == null || user == null || pass == null) { throw new AxisFault("SSO Configurator authentication details unspecified"); } String host; try { host = new URL(backendServerURL).getHost(); } catch (MalformedURLException e) { throw new AxisFault("SSO Configurator provider URL is malformed", e); } AuthenticationAdminStub authAdminStub = new AuthenticationAdminStub(null, backendServerURL + "/services/AuthenticationAdmin"); ServiceClient client = authAdminStub._getServiceClient(); Options options = client.getOptions(); options.setManageSession(true); try { authAdminStub.login(user, pass, host); ServiceContext serviceContext = authAdminStub. _getServiceClient().getLastOperationContext().getServiceContext(); String sessionCookie = (String) serviceContext.getProperty(HTTPConstants.COOKIE_STRING); return sessionCookie; } catch (RemoteException e) { throw new AxisFault("Error while contacting the authentication admin services", e); } catch (LoginAuthenticationExceptionException e) { throw new AxisFault("Error while authenticating against the SSO IDP admin", e); } }
private String login() throws AxisFault { if (backendServerURL == null || user == null || pass == null) { throw new AxisFault("SSO Configurator authentication details unspecified"); } String host; try { host = new URL(backendServerURL).getHost(); } catch (MalformedURLException e) { throw new AxisFault("SSO Configurator provider URL is malformed", e); } AuthenticationAdminStub authAdminStub = new AuthenticationAdminStub(null, backendServerURL + "/services/AuthenticationAdmin"); ServiceClient client = authAdminStub._getServiceClient(); Options options = client.getOptions(); options.setManageSession(true); try { authAdminStub.login(user, pass, host); ServiceContext serviceContext = authAdminStub. _getServiceClient().getLastOperationContext().getServiceContext(); String sessionCookie = (String) serviceContext.getProperty(HTTPConstants.COOKIE_STRING); return sessionCookie; } catch (RemoteException e) { throw new AxisFault("Error while contacting the authentication admin services", e); } catch (LoginAuthenticationExceptionException e) { throw new AxisFault("Error while authenticating against the SSO IDP admin", e); } }
public static String login(String hostName, String userName, String password) throws Exception { authenticationAdminStub.login(userName, password, hostName); // authenticationAdminStub.login(userName, password, hostName); ServiceContext serviceContext = authenticationAdminStub. _getServiceClient().getLastOperationContext().getServiceContext(); String sessionCookie = (String) serviceContext.getProperty(HTTPConstants.COOKIE_STRING); return sessionCookie; }
.getLastOperationContext().getServiceContext(); cookie = (String) serviceContext.getProperty(HTTPConstants.COOKIE_STRING); } else {
public APIAuthenticationServiceClient(String backendServerURL, String username, String password) throws Exception { try { AuthenticationAdminStub authenticationAdminStub = new AuthenticationAdminStub(null, backendServerURL + "AuthenticationAdmin"); ServiceClient authAdminServiceClient = authenticationAdminStub._getServiceClient(); authAdminServiceClient.getOptions().setManageSession(true); authenticationAdminStub.login(username, password, new URL(backendServerURL).getHost()); ServiceContext serviceContext = authenticationAdminStub. _getServiceClient().getLastOperationContext().getServiceContext(); String authenticatedCookie = (String) serviceContext.getProperty(HTTPConstants.COOKIE_STRING); if (log.isDebugEnabled()) { log.debug("Authentication Successful with AuthenticationAdmin. " + "Authenticated Cookie ID : " + authenticatedCookie); } stub = new APIAuthenticationServiceStub( null, backendServerURL + "APIAuthenticationService"); ServiceClient client = stub._getServiceClient(); Options options = client.getOptions(); options.setManageSession(true); options.setProperty(HTTPConstants.COOKIE_STRING, authenticatedCookie); } catch (Exception e) { String errorMsg = "Error when instantiating APIAuthenticationServiceClient."; log.error(errorMsg, e); throw e; } }
public boolean authenticate(String username, String password) throws RemoteException, SocketException, AuthenticationExceptionException { boolean loginResponse; loginResponse = stub.login(username, password, NetworkUtils.getLocalHostname()); this.sessionCookie = (String) stub._getServiceClient().getLastOperationContext().getServiceContext() .getProperty(HTTPConstants.COOKIE_STRING); return loginResponse; }
public boolean authenticate(String username, String password) throws Exception { boolean loginResponse; loginResponse = stub.login(username, password, NetworkUtils.getLocalHostname()); this.sessionCookie = (String) stub._getServiceClient().getLastOperationContext().getServiceContext() .getProperty(HTTPConstants.COOKIE_STRING); return loginResponse; }
public boolean authenticate(String username, String password) throws RemoteException, SocketException, AuthenticationExceptionException { boolean loginResponse; loginResponse = stub.login(username, password, NetworkUtils.getLocalHostname()); this.sessionCookie = (String)stub._getServiceClient().getLastOperationContext().getServiceContext() .getProperty(HTTPConstants.COOKIE_STRING); return loginResponse; }
public ProviderKeyMgtClient(String backendServerURL, String username, String password) throws APIManagementException { try { AuthenticationAdminStub authenticationAdminStub = new AuthenticationAdminStub(null, backendServerURL + "AuthenticationAdmin"); ServiceClient authAdminServiceClient = authenticationAdminStub._getServiceClient(); authAdminServiceClient.getOptions().setManageSession(true); authenticationAdminStub.login(username, password, new URL(backendServerURL).getHost()); ServiceContext serviceContext = authenticationAdminStub. _getServiceClient().getLastOperationContext().getServiceContext(); String authenticatedCookie = (String) serviceContext.getProperty(HTTPConstants.COOKIE_STRING); if (log.isDebugEnabled()) { log.debug("Authentication Successful with AuthenticationAdmin. Authenticated Cookie ID : " + authenticatedCookie); } providerServiceStub = new APIKeyMgtProviderServiceStub(null, backendServerURL + "APIKeyMgtProviderService"); ServiceClient client = providerServiceStub._getServiceClient(); Options options = client.getOptions(); options.setManageSession(true); options.setProperty(HTTPConstants.COOKIE_STRING, authenticatedCookie); } catch (RemoteException e) { handleException("Cannot connect to the service, instantiating ProviderKeyMgtClient failed", e); } catch (LoginAuthenticationExceptionException e) { handleException("Error during Authentication, instantiating ProviderKeyMgtClient failed", e); } catch (MalformedURLException e) { handleException("Invalid backendServerURL, instantiating ProviderKeyMgtClient failed", e); } }
authAdminStub.login(user, password, host); ServiceContext serviceContext = authAdminStub. _getServiceClient().getLastOperationContext().getServiceContext(); String sessionCookie = (String) serviceContext.getProperty(HTTPConstants.COOKIE_STRING); return sessionCookie;
public boolean authenticate(String userName, String password) throws RemoteException, SocketException, AuthenticationExceptionException { boolean logInResponse = false; try { logInResponse = stub.login(userName, password, NetworkUtils.getLocalHostname()); this.sessionCookie = (String) stub._getServiceClient().getLastOperationContext().getServiceContext() .getProperty(HTTPConstants.COOKIE_STRING); } catch (org.wso2.carbon.bam.services.stub.authenticationadmin_3_1_0.AuthenticationExceptionException e) { e.printStackTrace(); } return logInResponse; }
/** * 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); } } }
/** * Query the remote user manager to find out whether the specified user has the * specified permission. * * @param user Username * @param permission A valid Carbon permission * @return true if the user has the specified permission and false otherwise * @throws org.wso2.carbon.appmgt.api.AppManagementException If and error occurs while accessing the admin service */ public boolean isUserAuthorized(String user, String permission) throws AppManagementException { CarbonUtils.setBasicAccessSecurityHeaders(username, password, true, authorizationManager._getServiceClient()); if (cookie != null) { authorizationManager._getServiceClient().getOptions().setProperty(HTTPConstants.COOKIE_STRING, cookie); } try { boolean authorized = authorizationManager.isUserAuthorized(user, permission, CarbonConstants.UI_PERMISSION_ACTION); ServiceContext serviceContext = authorizationManager. _getServiceClient().getLastOperationContext().getServiceContext(); cookie = (String) serviceContext.getProperty(HTTPConstants.COOKIE_STRING); return authorized; } catch (Exception e) { throw new AppManagementException("Error while accessing backend services for " + "user permission validation", e); } }
public boolean authenticate(String username, String password) throws AuthenticationExceptionException, RemoteException { try { boolean isAuthenticated = stub.login(username,password,NetworkUtils.getLocalHostname()); if(isAuthenticated){ ServiceContext serviceContext; serviceContext = stub._getServiceClient().getLastOperationContext().getServiceContext(); String sessionCookie; sessionCookie = (String) serviceContext.getProperty(HTTPConstants.COOKIE_STRING); this.sessionCookie = sessionCookie; }else{ throw new AuthenticationExceptionException("Authentication Failed"); } return isAuthenticated; } catch (SocketException e) { throw new AuthenticationExceptionException(e); } }