Post a module to the server

@param module
@param user
@param password
@throws GrapesCommunicationException
@throws javax.naming.AuthenticationException
482120
public void postModule(final Module module, final String user, final String password) throws GrapesCommunicationException, AuthenticationException {
        final Client client = getClient(user, password);
        final WebResource resource = client.resource(serverURL).path(RequestUtils.moduleResourcePath());
        final ClientResponse response = resource.type(MediaType.APPLICATION_JSON).post(ClientResponse.class, module);

        client.destroy();
        if(ClientResponse.Status.CREATED.getStatusCode() != response.getStatus()){
            final String message = "Failed to POST module";
            if(LOG.isErrorEnabled()) {
                LOG.error(String.format(HTTP_STATUS_TEMPLATE_MSG, message, response.getStatus()));
            }
            throw new GrapesCommunicationException(message, response.getStatus());
        }
    }
1271701
@Override
    public void initModule() throws ModuleInitializationException {
        Map<String, String> parameters = getParameters();
        copyPropertiesOverParameters(parameters);
        serverInterface = new ServerWrapper(getServer());
        logger.info("Journaling parameters: " + parameters);
        parseParameters(parameters);

        if (inRecoveryMode) {
            worker =
                    new JournalConsumer(parameters, getRole(), serverInterface);
        } else {
            worker = new JournalCreator(parameters, getRole(), serverInterface);
        }
        logger.info("Journal worker module is: " + worker.toString());
    }
497863
public void setUserPassword(String userName, String password) {

        ProtocolHeader header = new ProtocolHeader();
        header.setType(ProtocolType.SetUserPassword);
        byte[] secret = null;
        if(password != null && ! password.isEmpty()){
            secret = ObfuscatUtil.base64Encode(password.getBytes());
        }
        SetUserPasswordProtocol p = new SetUserPasswordProtocol(userName, secret);

        connection.submitRequest(header, p, null);

    }
571480
@CommandArgument
  public void adduser(
      @OptionArgument("username") String username,
      @OptionArgument("password") String password,
      @OptionArgument("roles") String roles) {

    if (users.containsKey(username)) {
      System.err.println(String.format("User '%s' already exists", username));
    } else {

      User user = new User(username);
      user.salt = passwd.generateSalt();
      user.hash = passwd.getEncryptedPassword(password, user.salt);
      user.roles.addAll(Arrays.asList(roles.split(",")));
      users.put(username, user);

    }
  }
95497
private void installModule(final Node node, final ModuleContext module, final Handler<AsyncResult<Void>> doneHandler) {
    node.installModule(module.module(), doneHandler);
  }
662822
@Override
    public void bindJavaModule(String name, EJBBinding bindingObject) {
        ejbJavaColonHelper.addModuleBinding(moduleMetaData, name, bindingObject);
    }
1071052
@Override
    public void postInitModule() throws ModuleInitializationException {
        ManagementDelegate delegate = serverInterface.getManagementDelegate();
        if (delegate == null) {
            throw new ModuleInitializationException("Can't get a ManagementDelegate from Server.getModule()",
                                                    getRole());
        }
        worker.setManagementDelegate(delegate);
    }
932080
public void createProductDelivery(final String productLogicalName, final Delivery delivery, final String user, final String password) throws GrapesCommunicationException, AuthenticationException {      
    	final Client client = getClient(user, password);
        final WebResource resource = client.resource(serverURL).path(RequestUtils.getProductDelivery(productLogicalName));
        final ClientResponse response = resource.type(MediaType.APPLICATION_JSON).post(ClientResponse.class, delivery);

        client.destroy();
        if(ClientResponse.Status.CREATED.getStatusCode() != response.getStatus()){
            final String message = "Failed to create a delivery";
            if(LOG.isErrorEnabled()) {
                LOG.error(String.format(HTTP_STATUS_TEMPLATE_MSG, message, response.getStatus()));
            }
            throw new GrapesCommunicationException(message, response.getStatus());
        }
    }
791530
function(stream, post) {
  this._credentials = [];
  this._status      = {};
  this._modules = {
    stream:   stream   || Stream,
    post:     post     || Post
  };
}
614654
public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		String accountId  = getServletContext().getInitParameter("accountId"); // Put your AccountId here
		String email      = getServletContext().getInitParameter("email"); // Put your Email address here (Used for authentication and replies)
		String password   = getServletContext().getInitParameter("password");  // Put your Password here				
		
		String alertId = request.getParameter("alertId");
		String tel = request.getParameter("tel");
		String alertText = request.getParameter("alertText");        
        if(alertText == null || alertText.length() < 1) {
	        // Get the content of the request as the text to parse
	        byte[] content = new byte[request.getContentLength()];
	        request.getInputStream().read(content,0, request.getContentLength());        
	        alertText = new String(content); 	        
        }
        alertId = URLEncoder.encode(alertId, "UTF-8");
//        tel = URLEncoder.encode(tel, "UTF-8");
//        alertText = URLEncoder.encode(alertText, "UTF-8");        
		
		Integer nResult;
		StringBuffer strResponse = new StringBuffer();
		String sData;

		try {
			sData = ("AccountId=" + URLEncoder.encode(accountId, "UTF-8"));
//			sData += ("&Email=" + URLEncoder.encode(email, "UTF-8"));
			sData += ("&Email=" + email);
			sData += ("&Password=" + URLEncoder.encode(password, "UTF-8"));
			sData += ("&Recipient=" + URLEncoder.encode(tel, "UTF-8"));
			sData += ("&Message=" + URLEncoder.encode(alertText, "UTF-8"));

			if(logger.isInfoEnabled()) {        	
	        	logger.info("Got an alert : \n alertID : " + alertId + " \n tel : " + tel + " \n text : " +alertText);
	        	logger.info("Red Oxygen : \n Account Id : " + accountId + " \n email : " + email + " \n password : " + password);
	        	logger.info("Red Oxygen URL : \n URL : " + RED_OXYGEN_URL + " \n data : " + sData);
	        }
	        
			
			URL urlObject = new URL(RED_OXYGEN_URL);

			HttpURLConnection con = (HttpURLConnection) urlObject.openConnection();
			con.setRequestMethod(HTTP_METHOD);
			con.setDoInput(true);
			con.setDoOutput(true);

			DataOutputStream out = new DataOutputStream(con.getOutputStream());
			out.writeBytes(sData);
			out.flush();
			out.close();

			BufferedReader in = new BufferedReader(new InputStreamReader(con
					.getInputStream()));

			String inputLine;
			StringBuffer responseBuffer = new StringBuffer();

			while ((inputLine = in.readLine()) != null) {
				responseBuffer = responseBuffer.append(inputLine);
				responseBuffer = responseBuffer.append("\n\n\n");
			}

			strResponse.replace(0, 0, responseBuffer.toString());

			String sResultCode = strResponse.substring(0, 4);
			nResult = new Integer(sResultCode);

			in.close();
		} catch (Exception e) {			
			logger.error("Exception caught sending SMS",e);
			nResult = -2;
		}		

		sendHttpResponse(response, RESPONSE_BEGIN + "result : " + nResult + "<br/>response : " + strResponse + RESPONSE_END);
	}
287638
public void tryLogin(String protocol,
                         String host,
                         int port,
                         String context,
                         String user,
                         String pass) throws Exception {

        try {
            logger.info("Logging in...");
            // get a FedoraClient
            String baseURL = protocol + "://" + host + ":" + port + "/" + context;
            FedoraClient fc = new FedoraClient(baseURL, user, pass);

            // attempt to connect via REST
            String serverVersion = fc.getServerVersion();

            // ensure client is compatible with server, warn if not
            List<String> compatibleVersions =
                    FedoraClient.getCompatibleServerVersions();
            if (!compatibleVersions.contains(serverVersion)) {
                StringBuffer endText = new StringBuffer();
                if (compatibleVersions.size() == 1) {
                    // version A
                    endText.append("version " + compatibleVersions.get(0));
                } else {
                    // versions A and B
                    // versions A, B, and C
                    endText.append("versions ");
                    for (int i = 0; i < compatibleVersions.size(); i++) {
                        if (i > 0) {
                            if (i == compatibleVersions.size() - 1) {
                                if (i > 1) {
                                    endText.append(",");
                                }
                                endText.append(" and ");
                            } else {
                                endText.append(", ");
                            }
                        }
                        endText.append(compatibleVersions.get(i));
                    }
                }
                System.err.println("WARNING: Server version is "
                        + serverVersion + ".  This client is "
                        + "only designed to work with " + endText.toString());
            }

            // set SOAP stubs for Administrator
            Administrator.APIA = fc.getAPIAMTOM();
            Administrator.APIM = fc.getAPIMMTOM();

        } catch (Exception e) {
            if (e.getMessage().indexOf("Unauthorized") != -1
                    || e.getMessage().indexOf("Unrecognized") != -1) {
                throw new IOException("Bad username or password.");
            } else {
                if (e.getMessage() != null) {
                    throw new IOException(e.getClass().getName() + ": "
                            + e.getMessage());
                } else {
                    throw new IOException(e.getClass().getName());
                }
            }
        }
    }
572923
def post(self):
        
        #1.
        username = request.form.get("username")
        password = request.form.get("password")
        exipres  = 7200
        #expire time(seconds)
        if username and password:
            _authRes = self._getAuthentication(username, password)
        else:
            return {"msg": "invalid username or password"}
        #2.
        if _authRes:
            _payload = self._getUserData(username)
            #3.
            try:
                token = self.jwt.createJWT(_payload, expiredSeconds=exipres)
            except JWTException:
            	return {"msg": "Failed to request token"}
            else:
                return {"token": token}
        else:
            return {"msg": "Authentication failed"}
448233
public static function checkComponentAccess(ModuleInterface $module, string $component, Tree $tree, UserInterface $user): void
    {
        if ($module->accessLevel($tree, $component) < self::accessLevel($tree, $user)) {
            throw new AccessDeniedHttpException('');
        }
    }
1190925
public ServerUpdater addRoleToUser(User user, Role role) {
        delegate.addRoleToUser(user, role);
        return this;
    }
1196603
public void authenticate(String username, String password) {
		logger.debug("Authenticate:" + username);

		Authentication request = new UsernamePasswordAuthenticationToken(username, password);
		authenticationManager.authenticate(request);
	}
1069383
def post_with_auth(path, response_class, payload)
      response_class.new(client.post_with_auth(path, payload))
    end
870920
public void login(String user) throws AppEngineException {
    Preconditions.checkNotNull(user);
    if (!EMAIL_PATTERN.matcher(user).find()) {
      throw new AppEngineException("Invalid email address: " + user);
    }
    try {
      runner.run(ImmutableList.of("auth", "login", user), null);
    } catch (ProcessHandlerException | IOException ex) {
      throw new AppEngineException(ex);
    }
  }