Java 类com.intellij.util.Base64Converter 实例源码

项目:intellij-ce-playground    文件:URLUtil.java   
/**
 * Extracts byte array from given data:URL string.
 * data:URL will be decoded from base64 if it contains the marker of base64 encoding.
 *
 * @param dataUrl data:URL-like string (may be quoted)
 * @return extracted byte array or {@code null} if it cannot be extracted.
 */
@Nullable
public static byte[] getBytesFromDataUri(@NotNull String dataUrl) {
  Matcher matcher = DATA_URI_PATTERN.matcher(StringUtil.unquoteString(dataUrl));
  if (matcher.matches()) {
    try {
      String content = matcher.group(4);
      return ";base64".equalsIgnoreCase(matcher.group(3))
             ? Base64Converter.decode(content.getBytes(CharsetToolkit.UTF8_CHARSET))
             : content.getBytes(CharsetToolkit.UTF8_CHARSET);
    }
    catch (IllegalArgumentException e) {
      return null;
    }
  }
  return null;
}
项目:intellij-ce-playground    文件:JavaFxEditCertificatesDialog.java   
protected JavaFxEditCertificatesDialog(JComponent parent, JavaFxArtifactProperties properties, Project project) {
  super(parent, true);
  setTitle("Choose Certificate");
  init();
  final ActionListener actionListener = new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      UIUtil.setEnabled(myPanel.myKeysPanel, !myPanel.mySelfSignedRadioButton.isSelected(), true);
    }
  };
  myPanel.mySelfSignedRadioButton.addActionListener(actionListener);
  myPanel.mySignedByKeyRadioButton.addActionListener(actionListener);
  final boolean selfSigning = properties.isSelfSigning();
  UIUtil.setEnabled(myPanel.myKeysPanel, !selfSigning, true);
  myPanel.mySelfSignedRadioButton.setSelected(selfSigning);
  myPanel.mySignedByKeyRadioButton.setSelected(!selfSigning);

  myPanel.myAliasTF.setText(properties.getAlias());
  myPanel.myKeystore.setText(properties.getKeystore());
  final String keypass = properties.getKeypass();
  myPanel.myKeypassTF.setText(keypass != null ? Base64Converter.decode(keypass) : "");
  final String storepass = properties.getStorepass();
  myPanel.myStorePassTF.setText(storepass != null ? Base64Converter.decode(storepass) : "");
  myPanel.myKeystore.addBrowseFolderListener("Choose Keystore File", "Select file containing generated keys", project, BrowseFilesListener.SINGLE_FILE_DESCRIPTOR);
}
项目:tools-idea    文件:JavaFxArtifactPropertiesEditor.java   
@Override
public boolean isModified() {
  if (isModified(myProperties.getTitle(), myTitleTF)) return true;
  if (isModified(myProperties.getVendor(), myVendorTF)) return true;
  if (isModified(myProperties.getDescription(), myDescriptionEditorPane)) return true;
  if (isModified(myProperties.getWidth(), myWidthTF)) return true;
  if (isModified(myProperties.getHeight(), myHeightTF)) return true;
  if (isModified(myProperties.getAppClass(), myAppClass)) return true;
  if (isModified(myProperties.getHtmlParamFile(), myHtmlParams)) return true;
  if (isModified(myProperties.getParamFile(), myParams)) return true;
  if (!Comparing.equal(myNativeBundleCB.getSelectedItem(), myProperties.getNativeBundle())) return true;
  final boolean inBackground = Comparing.strEqual(myProperties.getUpdateMode(), JavaFxPackagerConstants.UPDATE_MODE_BACKGROUND);
  if (inBackground != myUpdateInBackgroundCB.isSelected()) return true;
  if (myProperties.isEnabledSigning() != myEnableSigningCB.isSelected()) return true;
  if (myProperties.isConvertCss2Bin() != myConvertCssToBinCheckBox.isSelected()) return true;
  if (myDialog != null) {
    if (isModified(myProperties.getAlias(), myDialog.myPanel.myAliasTF)) return true;
    if (isModified(myProperties.getKeystore(), myDialog.myPanel.myKeystore)) return true;
    final String keypass = myProperties.getKeypass();
    if (isModified(keypass != null ? Base64Converter.decode(keypass) : "", myDialog.myPanel.myKeypassTF)) return true;
    final String storepass = myProperties.getStorepass();
    if (isModified(storepass != null ? Base64Converter.decode(storepass) : "", myDialog.myPanel.myStorePassTF)) return true;
    if (myProperties.isSelfSigning() != myDialog.myPanel.mySelfSignedRadioButton.isSelected()) return true;
  }
  return false;
}
项目:tools-idea    文件:JavaFxArtifactPropertiesEditor.java   
@Override
public void apply() {
  myProperties.setTitle(myTitleTF.getText());
  myProperties.setVendor(myVendorTF.getText());
  myProperties.setDescription(myDescriptionEditorPane.getText());
  myProperties.setAppClass(myAppClass.getText());
  myProperties.setWidth(myWidthTF.getText());
  myProperties.setHeight(myHeightTF.getText());
  myProperties.setHtmlParamFile(myHtmlParams.getText());
  myProperties.setParamFile(myParams.getText());
  myProperties.setUpdateMode(myUpdateInBackgroundCB.isSelected() ? JavaFxPackagerConstants.UPDATE_MODE_BACKGROUND 
                                                                 : JavaFxPackagerConstants.UPDATE_MODE_ALWAYS);
  myProperties.setEnabledSigning(myEnableSigningCB.isSelected());
  myProperties.setConvertCss2Bin(myConvertCssToBinCheckBox.isSelected());
  myProperties.setNativeBundle((String)myNativeBundleCB.getSelectedItem());
  if (myDialog != null) {
    myProperties.setSelfSigning(myDialog.myPanel.mySelfSignedRadioButton.isSelected());
    myProperties.setAlias(myDialog.myPanel.myAliasTF.getText());
    myProperties.setKeystore(myDialog.myPanel.myKeystore.getText());
    final String keyPass = String.valueOf((myDialog.myPanel.myKeypassTF.getPassword()));
    myProperties.setKeypass(!StringUtil.isEmptyOrSpaces(keyPass) ? Base64Converter.encode(keyPass) : null);
    final String storePass = String.valueOf(myDialog.myPanel.myStorePassTF.getPassword());
    myProperties.setStorepass(!StringUtil.isEmptyOrSpaces(storePass) ? Base64Converter.encode(storePass) : null);
  }
}
项目:tools-idea    文件:JavaFxEditCertificatesDialog.java   
protected JavaFxEditCertificatesDialog(JComponent parent, JavaFxArtifactProperties properties, Project project) {
  super(parent, true);
  setTitle("Choose Certificate");
  init();
  final ActionListener actionListener = new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      UIUtil.setEnabled(myPanel.myKeysPanel, !myPanel.mySelfSignedRadioButton.isSelected(), true);
    }
  };
  myPanel.mySelfSignedRadioButton.addActionListener(actionListener);
  myPanel.mySignedByKeyRadioButton.addActionListener(actionListener);
  final boolean selfSigning = properties.isSelfSigning();
  UIUtil.setEnabled(myPanel.myKeysPanel, !selfSigning, true);
  myPanel.mySelfSignedRadioButton.setSelected(selfSigning);
  myPanel.mySignedByKeyRadioButton.setSelected(!selfSigning);

  myPanel.myAliasTF.setText(properties.getAlias());
  myPanel.myKeystore.setText(properties.getKeystore());
  final String keypass = properties.getKeypass();
  myPanel.myKeypassTF.setText(keypass != null ? Base64Converter.decode(keypass) : "");
  final String storepass = properties.getStorepass();
  myPanel.myStorePassTF.setText(storepass != null ? Base64Converter.decode(storepass) : "");
  myPanel.myKeystore.addBrowseFolderListener("Choose Keystore File", "Select file containing generated keys", project, BrowseFilesListener.SINGLE_FILE_DESCRIPTOR);
}
项目:consulo-javafx    文件:JavaFxArtifactPropertiesEditor.java   
@Override
public boolean isModified() {
  if (isModified(myProperties.getTitle(), myTitleTF)) return true;
  if (isModified(myProperties.getVendor(), myVendorTF)) return true;
  if (isModified(myProperties.getDescription(), myDescriptionEditorPane)) return true;
  if (isModified(myProperties.getWidth(), myWidthTF)) return true;
  if (isModified(myProperties.getHeight(), myHeightTF)) return true;
  if (isModified(myProperties.getAppClass(), myAppClass)) return true;
  if (isModified(myProperties.getHtmlParamFile(), myHtmlParams)) return true;
  if (isModified(myProperties.getParamFile(), myParams)) return true;
  if (!Comparing.equal(myNativeBundleCB.getSelectedItem(), myProperties.getNativeBundle())) return true;
  final boolean inBackground = Comparing.strEqual(myProperties.getUpdateMode(), JavaFxPackagerConstants.UPDATE_MODE_BACKGROUND);
  if (inBackground != myUpdateInBackgroundCB.isSelected()) return true;
  if (myProperties.isEnabledSigning() != myEnableSigningCB.isSelected()) return true;
  if (myProperties.isConvertCss2Bin() != myConvertCssToBinCheckBox.isSelected()) return true;
  if (myDialog != null) {
    if (isModified(myProperties.getAlias(), myDialog.myPanel.myAliasTF)) return true;
    if (isModified(myProperties.getKeystore(), myDialog.myPanel.myKeystore)) return true;
    final String keypass = myProperties.getKeypass();
    if (isModified(keypass != null ? Base64Converter.decode(keypass) : "", myDialog.myPanel.myKeypassTF)) return true;
    final String storepass = myProperties.getStorepass();
    if (isModified(storepass != null ? Base64Converter.decode(storepass) : "", myDialog.myPanel.myStorePassTF)) return true;
    if (myProperties.isSelfSigning() != myDialog.myPanel.mySelfSignedRadioButton.isSelected()) return true;
  }
  return false;
}
项目:consulo-javafx    文件:JavaFxArtifactPropertiesEditor.java   
@Override
public void apply() {
  myProperties.setTitle(myTitleTF.getText());
  myProperties.setVendor(myVendorTF.getText());
  myProperties.setDescription(myDescriptionEditorPane.getText());
  myProperties.setAppClass(myAppClass.getText());
  myProperties.setWidth(myWidthTF.getText());
  myProperties.setHeight(myHeightTF.getText());
  myProperties.setHtmlParamFile(myHtmlParams.getText());
  myProperties.setParamFile(myParams.getText());
  myProperties.setUpdateMode(myUpdateInBackgroundCB.isSelected() ? JavaFxPackagerConstants.UPDATE_MODE_BACKGROUND 
                                                                 : JavaFxPackagerConstants.UPDATE_MODE_ALWAYS);
  myProperties.setEnabledSigning(myEnableSigningCB.isSelected());
  myProperties.setConvertCss2Bin(myConvertCssToBinCheckBox.isSelected());
  myProperties.setNativeBundle((String)myNativeBundleCB.getSelectedItem());
  if (myDialog != null) {
    myProperties.setSelfSigning(myDialog.myPanel.mySelfSignedRadioButton.isSelected());
    myProperties.setAlias(myDialog.myPanel.myAliasTF.getText());
    myProperties.setKeystore(myDialog.myPanel.myKeystore.getText());
    final String keyPass = String.valueOf((myDialog.myPanel.myKeypassTF.getPassword()));
    myProperties.setKeypass(!StringUtil.isEmptyOrSpaces(keyPass) ? Base64Converter.encode(keyPass) : null);
    final String storePass = String.valueOf(myDialog.myPanel.myStorePassTF.getPassword());
    myProperties.setStorepass(!StringUtil.isEmptyOrSpaces(storePass) ? Base64Converter.encode(storePass) : null);
  }
}
项目:consulo-javafx    文件:JavaFxEditCertificatesDialog.java   
protected JavaFxEditCertificatesDialog(JComponent parent, JavaFxArtifactProperties properties, Project project) {
  super(parent, true);
  setTitle("Choose Certificate");
  init();
  final ActionListener actionListener = new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      UIUtil.setEnabled(myPanel.myKeysPanel, !myPanel.mySelfSignedRadioButton.isSelected(), true);
    }
  };
  myPanel.mySelfSignedRadioButton.addActionListener(actionListener);
  myPanel.mySignedByKeyRadioButton.addActionListener(actionListener);
  final boolean selfSigning = properties.isSelfSigning();
  UIUtil.setEnabled(myPanel.myKeysPanel, !selfSigning, true);
  myPanel.mySelfSignedRadioButton.setSelected(selfSigning);
  myPanel.mySignedByKeyRadioButton.setSelected(!selfSigning);

  myPanel.myAliasTF.setText(properties.getAlias());
  myPanel.myKeystore.setText(properties.getKeystore());
  final String keypass = properties.getKeypass();
  myPanel.myKeypassTF.setText(keypass != null ? Base64Converter.decode(keypass) : "");
  final String storepass = properties.getStorepass();
  myPanel.myStorePassTF.setText(storepass != null ? Base64Converter.decode(storepass) : "");
  myPanel.myKeystore.addBrowseFolderListener("Choose Keystore File", "Select file containing generated keys", project, BrowseFilesListener.SINGLE_FILE_DESCRIPTOR);
}
项目:intellij-ce-playground    文件:JavaFxArtifactPropertiesEditor.java   
@Override
public boolean isModified() {
  if (isModified(myProperties.getTitle(), myTitleTF)) return true;
  if (isModified(myProperties.getVendor(), myVendorTF)) return true;
  if (isModified(myProperties.getDescription(), myDescriptionEditorPane)) return true;
  if (isModified(myProperties.getWidth(), myWidthTF)) return true;
  if (isModified(myProperties.getHeight(), myHeightTF)) return true;
  if (isModified(myProperties.getAppClass(), myAppClass)) return true;
  if (isModified(myProperties.getHtmlParamFile(), myHtmlParams)) return true;
  if (isModified(myProperties.getParamFile(), myParams)) return true;
  if (!Comparing.equal(myNativeBundleCB.getSelectedItem(), myProperties.getNativeBundle())) return true;
  final boolean inBackground = Comparing.strEqual(myProperties.getUpdateMode(), JavaFxPackagerConstants.UPDATE_MODE_BACKGROUND);
  if (inBackground != myUpdateInBackgroundCB.isSelected()) return true;
  if (myProperties.isEnabledSigning() != myEnableSigningCB.isSelected()) return true;
  if (myProperties.isConvertCss2Bin() != myConvertCssToBinCheckBox.isSelected()) return true;
  if (myDialog != null) {
    if (isModified(myProperties.getAlias(), myDialog.myPanel.myAliasTF)) return true;
    if (isModified(myProperties.getKeystore(), myDialog.myPanel.myKeystore)) return true;
    final String keypass = myProperties.getKeypass();
    if (isModified(keypass != null ? Base64Converter.decode(keypass) : "", myDialog.myPanel.myKeypassTF)) return true;
    final String storepass = myProperties.getStorepass();
    if (isModified(storepass != null ? Base64Converter.decode(storepass) : "", myDialog.myPanel.myStorePassTF)) return true;
    if (myProperties.isSelfSigning() != myDialog.myPanel.mySelfSignedRadioButton.isSelected()) return true;
  }

  if (myManifestAttributesDialog != null) {
    if (!Comparing.equal(myManifestAttributesDialog.getAttrs(), myProperties.getCustomManifestAttributes())) return true;
  }
  return false;
}
项目:intellij-ce-playground    文件:JavaFxArtifactPropertiesEditor.java   
@Override
public void apply() {
  myProperties.setTitle(myTitleTF.getText());
  myProperties.setVendor(myVendorTF.getText());
  myProperties.setDescription(myDescriptionEditorPane.getText());
  myProperties.setAppClass(myAppClass.getText());
  myProperties.setWidth(myWidthTF.getText());
  myProperties.setHeight(myHeightTF.getText());
  myProperties.setHtmlParamFile(myHtmlParams.getText());
  myProperties.setParamFile(myParams.getText());
  myProperties.setUpdateMode(myUpdateInBackgroundCB.isSelected() ? JavaFxPackagerConstants.UPDATE_MODE_BACKGROUND
                                                                 : JavaFxPackagerConstants.UPDATE_MODE_ALWAYS);
  myProperties.setEnabledSigning(myEnableSigningCB.isSelected());
  myProperties.setConvertCss2Bin(myConvertCssToBinCheckBox.isSelected());
  myProperties.setNativeBundle((String)myNativeBundleCB.getSelectedItem());
  if (myDialog != null) {
    myProperties.setSelfSigning(myDialog.myPanel.mySelfSignedRadioButton.isSelected());
    myProperties.setAlias(myDialog.myPanel.myAliasTF.getText());
    myProperties.setKeystore(myDialog.myPanel.myKeystore.getText());
    final String keyPass = String.valueOf((myDialog.myPanel.myKeypassTF.getPassword()));
    myProperties.setKeypass(!StringUtil.isEmptyOrSpaces(keyPass) ? Base64Converter.encode(keyPass) : null);
    final String storePass = String.valueOf(myDialog.myPanel.myStorePassTF.getPassword());
    myProperties.setStorepass(!StringUtil.isEmptyOrSpaces(storePass) ? Base64Converter.encode(storePass) : null);
  }

  if (myManifestAttributesDialog != null) {
    myProperties.setCustomManifestAttributes(myManifestAttributesDialog.getAttrs());
  }
}
项目:intellij-ce-playground    文件:Attachment.java   
@NotNull
public String getEncodedBytes() {
  return Base64Converter.encode(myBytes);
}
项目:intellij-ce-playground    文件:AbstractJavaFxPackager.java   
private String getKeypass(boolean selfSigning) {
  return selfSigning ? "keypass" : Base64Converter.decode(getKeypass());
}
项目:intellij-ce-playground    文件:AbstractJavaFxPackager.java   
private String getStorepass(boolean selfSigning) {
  return selfSigning ? "storepass" : Base64Converter.decode(getStorepass());
}
项目:tools-idea    文件:Attachment.java   
public String getEncodedBytes() {
  return Base64Converter.encode(myBytes);
}
项目:tools-idea    文件:AbstractJavaFxPackager.java   
private String getKeypass(boolean selfSigning) {
  return selfSigning ? "keypass" : Base64Converter.decode(getKeypass());
}
项目:tools-idea    文件:AbstractJavaFxPackager.java   
private String getStorepass(boolean selfSigning) {
  return selfSigning ? "storepass" : Base64Converter.decode(getStorepass());
}
项目:consulo-javafx    文件:AbstractJavaFxPackager.java   
private String getKeypass(boolean selfSigning) {
  return selfSigning ? "keypass" : Base64Converter.decode(getKeypass());
}
项目:consulo-javafx    文件:AbstractJavaFxPackager.java   
private String getStorepass(boolean selfSigning) {
  return selfSigning ? "storepass" : Base64Converter.decode(getStorepass());
}