Skip to content

Instantly share code, notes, and snippets.

View Qijiang60's full-sized avatar

Qi Jiang Qijiang60

  • Nanchang, Jiangxi
View GitHub Profile
@Qijiang60
Qijiang60 / how_to_gen_ssl_cert.md
Created April 21, 2017 18:04 — forked from iansheridan/how_to_gen_ssl_cert.md
How to generate an SSL CSR or self signed SSL certificate

How to generate an SSL CSR or self signed SSL certificate

Overview

The following is an extremely simplified view of how SSL is implemented and what part the certificate plays in the entire process.

Normal web traffic is sent unencrypted over the Internet. That is, anyone with access to the right tools can snoop all of that traffic. Obviously, this can lead to problems, especially where security and privacy is necessary, such as in credit card data and bank transactions. The Secure Socket Layer is used to encrypt the data stream between the web server and the web client (the browser).

SSL makes use of what is known as asymmetric cryptography, commonly referred to as public key cryptography (PKI). With public key cryptography, two keys are created, one public, one private. Anything encrypted with either key can only be decrypted with its corresponding key. Thus if a message or data stream were encrypted with the server's private key, it can be decrypted only using its corresponding public key, ensuring

@Qijiang60
Qijiang60 / gist:25ef1e45e4991944b9189ff60b2b2c88
Created April 25, 2017 19:45 — forked from ilguzin/gist:6606011
How to convert Java Key Store file to pem/key for nginx
1. Convert our ".jks" file to ".p12" (PKCS12 key store format):
keytool -importkeystore -srckeystore oldkeystore.jks -destkeystore newkeystore.p12 -deststoretype PKCS12
1.1. List new keystore file contents:
keytool -deststoretype PKCS12 -keystore newkeystore.p12 -list
2. Extract pem (certificate) from ".p12" keysotre file:
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.scriptrunner.runner.rest.common.CustomEndpointDelegate
import groovy.json.JsonBuilder
import groovy.transform.BaseScript
import javax.ws.rs.core.MultivaluedMap
import javax.ws.rs.core.Response
@BaseScript CustomEndpointDelegate delegate
package examples
import com.almworks.jira.structure.api.PermissionLevel
import com.almworks.jira.structure.api.StructureException
import com.almworks.jira.structure.api.forest.ForestAccessor
import com.almworks.jira.structure.api.forest.ForestTransaction
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.onresolve.scriptrunner.runner.customisers.PluginModule
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.bc.projectroles.ProjectRoleService
import com.atlassian.jira.security.GlobalPermissionManager
import com.atlassian.jira.security.Permissions
import com.atlassian.jira.security.roles.actor.UserRoleActorFactory
import com.atlassian.jira.user.util.UserUtil
import com.atlassian.jira.util.SimpleErrorCollection
import com.atlassian.crowd.embedded.api.Group
import com.atlassian.crowd.embedded.api.User
import com.atlassian.jira.user.util.UserManager
@Qijiang60
Qijiang60 / notifyOwnChanges.groovy
Created July 7, 2017 11:51 — forked from ricardocasares/notifyOwnChanges.groovy
Bulk profile update for JIRA users from Groovy script on script-runner plugin.
/**
* This script was succesfuly tested on JIRA 6.1
*/
// import JIRA Component Accessor
import com.atlassian.jira.component.ComponentAccessor
// Create a new instance
cA = new ComponentAccessor();
// Get all application users
users = cA.getUserManager().getAllApplicationUsers();
@Qijiang60
Qijiang60 / UpdateAssigneeOnComponentChangeListener.groovy
Created July 7, 2017 15:48 — forked from KenDUemura/UpdateAssigneeOnComponentChangeListener.groovy
Script Runner Listener for Re-assigning to Component Lead when Component is changed
/**
* Created by Ken D: Uemura <[email protected]> on 6/1/2016.
*
* On Issue Update Event
* If Component is changed and only one component is assigned
* then re-assigns the issue to the Component Lead
*
* Tested with JIRA 6.4.11
* Set this in Add-On -> Script Lisner -> Custom Listener
*
@Qijiang60
Qijiang60 / UpdateAssigneeOnComponentChangeListener.groovy
Created July 7, 2017 15:48 — forked from KenDUemura/UpdateAssigneeOnComponentChangeListener.groovy
Script Runner Listener for Re-assigning to Component Lead when Component is changed
/**
* Created by Ken D: Uemura <[email protected]> on 6/1/2016.
*
* On Issue Update Event
* If Component is changed and only one component is assigned
* then re-assigns the issue to the Component Lead
*
* Tested with JIRA 6.4.11
* Set this in Add-On -> Script Lisner -> Custom Listener
*
@Qijiang60
Qijiang60 / gist:9a07813ea6a398865685e944433160d4
Created July 11, 2017 15:31 — forked from jamieechlin/gist:8240692
Post-function to copy a project
package examples
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.jira.groovy.canned.admin.CopyProject
import org.apache.log4j.Logger
def log = Logger.getLogger("com.onresolve.jira.groovy.MyScript")
Thread executorThread = new Thread(new Runnable() {
void run() {
@Qijiang60
Qijiang60 / jira.groovy
Created July 11, 2017 15:36 — forked from dkandalov/jira.groovy
Tiny example of using JIRA rest API from groovy
/**
* You might need to import JIRA ssl certificate into your jdk/jre cacerts file:
* 1) save JIRA certificate. E.g. in Chrome right click on https icon, click "Certificate information" link.
* In "Details" tab, click "Copy to File..." button.
* 2) in jdk "bin" folder run: "keytool -importcert -keystore ./cacerts -file /file/from/the/step/above/cacert.crt -trustcacerts -alias jira_ca
*/
class JiraMain {
static void main(String[] args) {
// see https://docs.atlassian.com/jira/REST/latest/
def listWatchers = "https://jira/rest/api/2/issue/PROJ-123/watchers"