/** * Removes the pointers to this <code>OperationContext</code> in the * <code>ConfigurationContext</code>'s OperationContextMap so that this * <code>OperationContext</code> will eventually get garbage collected * along with the <code>MessageContext</code>'s it contains. Note that if * the caller wants to make sure its safe to clean up this OperationContext * he should call isComplete() first. However, in cases like IN_OPTIONAL_OUT * and OUT_OPTIONAL_IN, it is possibe this will get called without the MEP * being complete due to the optional nature of the MEP. */ public void cleanup() { ServiceContext serv = getServiceContext(); if (serv != null) { serv.getConfigurationContext().unregisterOperationContext(key); } }
/** * Removes the pointers to this <code>OperationContext</code> in the * <code>ConfigurationContext</code>'s OperationContextMap so that this * <code>OperationContext</code> will eventually get garbage collected * along with the <code>MessageContext</code>'s it contains. Note that if * the caller wants to make sure its safe to clean up this OperationContext * he should call isComplete() first. However, in cases like IN_OPTIONAL_OUT * and OUT_OPTIONAL_IN, it is possibe this will get called without the MEP * being complete due to the optional nature of the MEP. */ public void cleanup() { ServiceContext serv = getServiceContext(); if (serv != null) { serv.getConfigurationContext().unregisterOperationContext(key); } }
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); } }
private boolean isAuthenticated(String remoteIP) { OperationContext opCtx = msgContext.getOperationContext(); ServiceContext serviceCtx = opCtx.getServiceContext(); String opName = opCtx.getAxisOperation().getName().getLocalPart(); String serviceName = serviceCtx.getAxisService().getName(); if ((serviceName.equals(ServerConstants.GLOBAL_ADMIN_SERVICE) || serviceName.equals(ClusteringConstants.NODE_MANAGER_SERVICE)) && (opName.equals("login") || opName.equals("logout"))) { return true; } String loginStatus = (String) serviceCtx.getServiceGroupContext(). getPropertyNonReplicable(ServerConstants.ADMIN_LOGGED_IN); boolean authenticated = "true".equals(loginStatus); if(!authenticated){ SimpleDateFormat date = new SimpleDateFormat("'['yyyy-MM-dd HH:mm:ss,SSSS']'"); log.warn("Illegal access attempt at " + date.format(new Date()) + " from IP address " + remoteIP); } return authenticated; }
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; }
public AxisService findService(MessageContext messageContext) throws AxisFault { RelatesTo relatesTo = messageContext.getRelatesTo(); if (LoggingControl.debugLoggingAllowed && log.isDebugEnabled()) { log.debug(messageContext.getLogIDString() + " Checking for OperationContext using RelatesTo : " + relatesTo); } if ((relatesTo != null) && (relatesTo.getValue() != null)) { ConfigurationContext configurationContext = messageContext.getConfigurationContext(); OperationContext operationContext = configurationContext.getOperationContext(relatesTo.getValue()); if (operationContext != null) { if (LoggingControl.debugLoggingAllowed && log.isDebugEnabled()) { log.debug(messageContext.getLogIDString() + " Found OperationContext: " + operationContext); } return operationContext.getServiceContext().getAxisService(); } } return null; }
public AxisService findService(MessageContext messageContext) throws AxisFault { RelatesTo relatesTo = messageContext.getRelatesTo(); if (LoggingControl.debugLoggingAllowed && log.isDebugEnabled()) { log.debug(messageContext.getLogIDString() + " Checking for OperationContext using RelatesTo : " + relatesTo); } if ((relatesTo != null) && (relatesTo.getValue() != null)) { ConfigurationContext configurationContext = messageContext.getConfigurationContext(); OperationContext operationContext = configurationContext.getOperationContext(relatesTo.getValue()); if (operationContext != null) { if (LoggingControl.debugLoggingAllowed && log.isDebugEnabled()) { log.debug(messageContext.getLogIDString() + " Found OperationContext: " + operationContext); } return operationContext.getServiceContext().getAxisService(); } } return null; }
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 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); } } }
/** * @param context The OperationContext */ public void setOperationContext(OperationContext context) { // allow setting the fields to null // useful when extracting the messge context from the object graph operationContext = context; this.setParent(operationContext); if (operationContext != null) { if (serviceContext == null) { setServiceContext(operationContext.getServiceContext()); } else { if (operationContext.getParent() != serviceContext) { throw new AxisError("ServiceContext in OperationContext does not match !"); } } this.setAxisOperation(operationContext.getAxisOperation()); } }
/** * @param context The OperationContext */ public void setOperationContext(OperationContext context) { // allow setting the fields to null // useful when extracting the messge context from the object graph operationContext = context; this.setParent(operationContext); if (operationContext != null) { if (serviceContext == null) { setServiceContext(operationContext.getServiceContext()); } else { if (operationContext.getParent() != serviceContext) { throw new AxisError("ServiceContext in OperationContext does not match !"); } } this.setAxisOperation(operationContext.getAxisOperation()); } }
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); } }