com.google.api.client.repackaged.org.apache.commons.codec.binary.Base64 Java Examples

The following examples show how to use com.google.api.client.repackaged.org.apache.commons.codec.binary.Base64. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RsaSha1MessageSigner.java    From jira-steps-plugin with Apache License 2.0 6 votes vote down vote up
@Override
public String sign(HttpRequest request, HttpParameters requestParams)
    throws OAuthMessageSignerException {

  final OAuthRsaSigner signer = new OAuthRsaSigner();
  final byte[] privateBytes = Base64.decodeBase64(getConsumerSecret());
  final PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(privateBytes);

  try {
    signer.privateKey = KeyFactory.getInstance("RSA").generatePrivate(keySpec);
    final String signatureBaseString = new SignatureBaseString(request, requestParams).generate();
    return signer.computeSignature(signatureBaseString);
  } catch (GeneralSecurityException e) {
    throw new OAuthMessageSignerException(e);
  }
}
 
Example #2
Source File: BaseGmailProvider.java    From PrivacyStreams with Apache License 2.0 5 votes vote down vote up
private List<String> getDataFromApi(String query) throws IOException {
    List<String> messageList = new ArrayList<>();
    String user = "me";
    ListMessagesResponse response = mService.users().messages().list(user).setQ(query).execute();
    int total = 1;
    String deliverTo = "";
    String from = "";
    String subject = "";
    String content = "";
    long timestamp = 0;
    if (response.getMessages() != null) {
        for(int i = response.getMessages().size()-1;i>=0;i--){
            Message item = response.getMessages().get(i);
            if (total > mMaxResult) {
                break;
            }
            Message message = mService.users().messages().get(user, item.getId()).setFormat("full").execute();
            List<MessagePart> messageParts = message.getPayload().getParts();
            List<MessagePartHeader> headers = message.getPayload().getHeaders();

            if (!headers.isEmpty()) {
                for (MessagePartHeader header : headers) {
                    String name = header.getName();
                    switch (name) {
                        case "From":
                            from = header.getValue();
                            break;
                        case "To":
                            deliverTo = header.getValue();
                            break;
                        case "Subject":
                            subject = header.getValue();
                            break;
                        case "Date":
                            String date = header.getValue();
                            if(date.contains(","))
                                date = date.substring(date.indexOf(",") + 2,date.length());;
                            String timestampFormat = "dd MMM yyyy HH:mm:ss Z";
                            timestamp = TimeUtils.fromFormattedString(timestampFormat,date) / 1000;
                            break;
                    }
                }
            }
            if (messageParts != null && !messageParts.isEmpty()) {
                byte[] bytes = Base64.decodeBase64(messageParts.get(0).getBody().getData());
                if (bytes != null) {
                    String mailText = new String(bytes);
                    if (!mailText.isEmpty()) {
                        total++;
                        content = mailText;
                        messageList.add(mailText);
                    }
                }
            }
            if(mLastEmailTime < timestamp) mLastEmailTime = timestamp;
            this.output(new Email(content, AppUtils.APP_PACKAGE_GMAIL, from, deliverTo, subject, timestamp));
        }
    }

    //Reset the value for from and to
    mBegin = 0;
    mEnd = 0;
    return messageList;
}
 
Example #3
Source File: YarnSmokeTest.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
private String generateCreateCMUserRecipeContent(String filePath) throws IOException {
    String cmUser = commonClusterManagerProperties().getClouderaManager().getDefaultUser();
    String cmPassword = commonClusterManagerProperties().getClouderaManager().getDefaultPassword();
    String recipeContentFromFile = ResourceUtil.readResourceAsString(applicationContext, filePath);

    recipeContentFromFile = recipeContentFromFile.replaceAll("CM_USER", cmUser);
    recipeContentFromFile = recipeContentFromFile.replaceAll("CM_PASSWORD", cmPassword);
    return Base64.encodeBase64String(recipeContentFromFile.getBytes());
}
 
Example #4
Source File: InternalSdxRepairWithRecipeTest.java    From cloudbreak with Apache License 2.0 4 votes vote down vote up
private String generateRecipeContent() throws IOException {
    String recipeContentFromFile = ResourceUtil.readResourceAsString(applicationContext, getRecipePath());
    return Base64.encodeBase64String(recipeContentFromFile.getBytes());
}