Search in sources :

Example 1 with OAuthRsaSigner

use of com.google.api.client.auth.oauth.OAuthRsaSigner in project che by eclipse.

the class OAuthAuthenticator method getOAuthRsaSigner.

private OAuthRsaSigner getOAuthRsaSigner() throws NoSuchAlgorithmException, InvalidKeySpecException {
    OAuthRsaSigner oAuthRsaSigner = new OAuthRsaSigner();
    oAuthRsaSigner.privateKey = getPrivateKey(privateKey);
    return oAuthRsaSigner;
}
Also used : OAuthRsaSigner(com.google.api.client.auth.oauth.OAuthRsaSigner)

Example 2 with OAuthRsaSigner

use of com.google.api.client.auth.oauth.OAuthRsaSigner in project syndesis-qe by syndesisio.

the class OAuthJiraAuthenticationHandler method createAccessToken.

private AbstractOAuthGetToken createAccessToken() throws NoSuchAlgorithmException, InvalidKeySpecException {
    Account jiraAccount = AccountsDirectory.getInstance().get("Jira");
    String privateKey = jiraAccount.getProperty("privatekey");
    String tempToken = jiraAccount.getProperty("accesstoken");
    String verifier = jiraAccount.getProperty("verificationcode");
    String consumerKey = jiraAccount.getProperty("consumerkey");
    String jiraUrl = jiraAccount.getProperty("jiraurl");
    byte[] privateBytes = Base64.decodeBase64(privateKey);
    PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(privateBytes);
    KeyFactory kf = KeyFactory.getInstance("RSA");
    OAuthRsaSigner oAuthRsaSigner = new OAuthRsaSigner();
    oAuthRsaSigner.privateKey = kf.generatePrivate(keySpec);
    JiraOAuthGetAccessToken accessToken = new JiraOAuthGetAccessToken(jiraUrl + "/plugins/servlet/oauth/access-token");
    accessToken.temporaryToken = tempToken;
    accessToken.signer = oAuthRsaSigner;
    accessToken.transport = new ApacheHttpTransport();
    accessToken.verifier = verifier;
    accessToken.consumerKey = consumerKey;
    return accessToken;
}
Also used : Account(io.syndesis.qe.account.Account) OAuthRsaSigner(com.google.api.client.auth.oauth.OAuthRsaSigner) PKCS8EncodedKeySpec(java.security.spec.PKCS8EncodedKeySpec) ApacheHttpTransport(com.google.api.client.http.apache.ApacheHttpTransport) KeyFactory(java.security.KeyFactory)

Aggregations

OAuthRsaSigner (com.google.api.client.auth.oauth.OAuthRsaSigner)2 ApacheHttpTransport (com.google.api.client.http.apache.ApacheHttpTransport)1 Account (io.syndesis.qe.account.Account)1 KeyFactory (java.security.KeyFactory)1 PKCS8EncodedKeySpec (java.security.spec.PKCS8EncodedKeySpec)1