mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
prefer java.util.Base64
This commit is contained in:
@@ -32,11 +32,9 @@ import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.ui.popup.util.PopupUtil;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.wm.IdeFocusManager;
|
||||
import com.intellij.openapi.wm.IdeFrame;
|
||||
import com.intellij.util.Base64;
|
||||
import com.intellij.util.SystemProperties;
|
||||
import com.intellij.util.WaitForProgressToShow;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
@@ -61,6 +59,7 @@ import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.net.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -269,11 +268,11 @@ public class HttpConfigurable implements PersistentStateComponent<HttpConfigurab
|
||||
|
||||
|
||||
private static String decode(String value) {
|
||||
return new String(Base64.decode(value), CharsetToolkit.UTF8_CHARSET);
|
||||
return new String(Base64.getDecoder().decode(value), StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
private static String encode(String password) {
|
||||
return Base64.encode(password.getBytes(CharsetToolkit.UTF8_CHARSET));
|
||||
return Base64.getEncoder().encodeToString(password.getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
public PasswordAuthentication getGenericPromptedAuthentication(final String prefix, final String host, final String prompt, final int port, final boolean remember) {
|
||||
|
||||
@@ -15,6 +15,10 @@
|
||||
*/
|
||||
package com.intellij.util;
|
||||
|
||||
/**
|
||||
* @deprecated Please use java.util.Base64
|
||||
*/
|
||||
@Deprecated
|
||||
public class Base64 {
|
||||
private Base64() { }
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,9 +19,9 @@ import com.intellij.util.text.StringFactory;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author maxim
|
||||
* @since 18.07.2006
|
||||
* @deprecated Please use java.util.Base64
|
||||
*/
|
||||
@Deprecated
|
||||
public class Base64Converter {
|
||||
private static final char[] alphabet = {
|
||||
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', // 0 to 7
|
||||
|
||||
+5
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,8 +19,6 @@ import com.intellij.execution.testframework.sm.runner.SMTestProxy;
|
||||
import com.intellij.execution.testframework.sm.runner.ui.SMTestRunnerResultsForm;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.util.Base64;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.gradle.execution.GradleRunnerUtil;
|
||||
@@ -28,6 +26,9 @@ import org.jetbrains.plugins.gradle.execution.test.runner.GradleConsolePropertie
|
||||
import org.jetbrains.plugins.gradle.execution.test.runner.GradleTestsExecutionConsole;
|
||||
import org.jetbrains.plugins.gradle.util.XmlXpathHelper;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Base64;
|
||||
|
||||
/**
|
||||
* @author Vladislav.Soroka
|
||||
* @since 2/28/14
|
||||
@@ -94,6 +95,6 @@ public abstract class AbstractTestEvent implements TestEvent {
|
||||
}
|
||||
|
||||
protected String decode(String s) {
|
||||
return new String(Base64.decode(s), CharsetToolkit.UTF8_CHARSET);
|
||||
return new String(Base64.getDecoder().decode(s), StandardCharsets.UTF_8);
|
||||
}
|
||||
}
|
||||
|
||||
+6
-5
@@ -28,7 +28,6 @@ import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.packaging.artifacts.Artifact;
|
||||
import com.intellij.packaging.ui.ArtifactPropertiesEditor;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.Base64Converter;
|
||||
import com.intellij.util.ui.ColumnInfo;
|
||||
import com.intellij.util.ui.ListTableModel;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -38,7 +37,9 @@ import javax.swing.text.JTextComponent;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -148,9 +149,9 @@ public class JavaFxArtifactPropertiesEditor extends ArtifactPropertiesEditor {
|
||||
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;
|
||||
if (isModified(keypass != null ? new String(Base64.getDecoder().decode(keypass), StandardCharsets.UTF_8) : "", myDialog.myPanel.myKeypassTF)) return true;
|
||||
final String storepass = myProperties.getStorepass();
|
||||
if (isModified(storepass != null ? Base64Converter.decode(storepass) : "", myDialog.myPanel.myStorePassTF)) return true;
|
||||
if (isModified(storepass != null ? new String(Base64.getDecoder().decode(storepass), StandardCharsets.UTF_8) : "", myDialog.myPanel.myStorePassTF)) return true;
|
||||
if (myProperties.isSelfSigning() != myDialog.myPanel.mySelfSignedRadioButton.isSelected()) return true;
|
||||
}
|
||||
|
||||
@@ -194,9 +195,9 @@ public class JavaFxArtifactPropertiesEditor extends ArtifactPropertiesEditor {
|
||||
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);
|
||||
myProperties.setKeypass(!StringUtil.isEmptyOrSpaces(keyPass) ? Base64.getEncoder().encodeToString(keyPass.getBytes(StandardCharsets.UTF_8)) : null);
|
||||
final String storePass = String.valueOf(myDialog.myPanel.myStorePassTF.getPassword());
|
||||
myProperties.setStorepass(!StringUtil.isEmptyOrSpaces(storePass) ? Base64Converter.encode(storePass) : null);
|
||||
myProperties.setStorepass(!StringUtil.isEmptyOrSpaces(storePass) ? Base64.getEncoder().encodeToString(storePass.getBytes(StandardCharsets.UTF_8)) : null);
|
||||
}
|
||||
|
||||
myProperties.setCustomManifestAttributes(myCustomManifestAttributes);
|
||||
|
||||
+4
-3
@@ -21,7 +21,6 @@ import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.Base64Converter;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -29,6 +28,8 @@ import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.File;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Base64;
|
||||
|
||||
/**
|
||||
* User: anna
|
||||
@@ -58,9 +59,9 @@ public class JavaFxEditCertificatesDialog extends DialogWrapper {
|
||||
myPanel.myAliasTF.setText(properties.getAlias());
|
||||
myPanel.myKeystore.setText(properties.getKeystore());
|
||||
final String keypass = properties.getKeypass();
|
||||
myPanel.myKeypassTF.setText(keypass != null ? Base64Converter.decode(keypass) : "");
|
||||
myPanel.myKeypassTF.setText(keypass != null ? new String(Base64.getDecoder().decode(keypass), StandardCharsets.UTF_8) : "");
|
||||
final String storepass = properties.getStorepass();
|
||||
myPanel.myStorePassTF.setText(storepass != null ? Base64Converter.decode(storepass) : "");
|
||||
myPanel.myStorePassTF.setText(storepass != null ? new String(Base64.getDecoder().decode(storepass), StandardCharsets.UTF_8) : "");
|
||||
myPanel.myKeystore.addBrowseFolderListener("Choose Keystore File", "Select file containing generated keys", project, BrowseFilesListener.SINGLE_FILE_DESCRIPTOR);
|
||||
}
|
||||
|
||||
|
||||
+4
-3
@@ -30,7 +30,6 @@ import com.intellij.packaging.artifacts.ArtifactType;
|
||||
import com.intellij.packaging.elements.*;
|
||||
import com.intellij.packaging.impl.elements.ArchivePackagingElement;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.Base64Converter;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -42,7 +41,9 @@ import org.jetbrains.plugins.javaFX.packaging.JavaFxArtifactPropertiesProvider;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Base64;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@@ -167,10 +168,10 @@ public class JavaFxChunkBuildExtension extends ChunkBuildExtension {
|
||||
final String keystore = selfSigning ? tempDirPath + File.separator + "jb-key.jks" : properties.getKeystore();
|
||||
generator.add(new Property(artifactBasedProperty(ARTIFACT_KEYSTORE_SIGN_PROPERTY, artifactName), keystore));
|
||||
|
||||
final String storepass = selfSigning ? "storepass" : Base64Converter.decode(properties.getStorepass());
|
||||
final String storepass = selfSigning ? "storepass" : new String(Base64.getDecoder().decode(properties.getStorepass()), StandardCharsets.UTF_8);
|
||||
generator.add(new Property(artifactBasedProperty(ARTIFACT_STOREPASS_SIGN_PROPERTY, artifactName), storepass));
|
||||
|
||||
final String keypass = selfSigning ? "keypass" : Base64Converter.decode(properties.getKeypass());
|
||||
final String keypass = selfSigning ? "keypass" : new String(Base64.getDecoder().decode(properties.getKeypass()), StandardCharsets.UTF_8);
|
||||
generator.add(new Property(artifactBasedProperty(ARTIFACTKEYPASS_SIGN_PROPERTY, artifactName), keypass));
|
||||
|
||||
final Pair[] keysDescriptions = createKeysDescriptions(artifactName);
|
||||
|
||||
+22
-4
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jetbrains.idea.maven.project;
|
||||
|
||||
import com.intellij.compiler.CompilerConfiguration;
|
||||
@@ -14,8 +29,10 @@ import com.intellij.openapi.util.JDOMUtil;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.io.StreamUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.*;
|
||||
import com.intellij.util.Base64;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.xmlb.XmlSerializer;
|
||||
import org.jdom.Document;
|
||||
@@ -34,6 +51,7 @@ import org.jetbrains.idea.maven.utils.MavenUtil;
|
||||
import org.jetbrains.jps.maven.model.impl.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.jar.Manifest;
|
||||
import java.util.regex.Matcher;
|
||||
@@ -239,7 +257,7 @@ public class MavenResourceCompilerConfigurationGenerator {
|
||||
manifest.write(outputStream);
|
||||
MavenDomProjectModel domModel = MavenDomUtil.getMavenDomProjectModel(module.getProject(), mavenProject.getFile());
|
||||
final String resolvedText = MavenPropertyResolver.resolve(outputStream.toString(CharsetToolkit.UTF8), domModel);
|
||||
resourceConfig.manifest = Base64.encode(resolvedText.getBytes(CharsetToolkit.UTF8));
|
||||
resourceConfig.manifest = Base64.getEncoder().encodeToString(resolvedText.getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
finally {
|
||||
StreamUtil.closeStream(outputStream);
|
||||
@@ -385,7 +403,7 @@ public class MavenResourceCompilerConfigurationGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
private void addEjbClientArtifactConfiguration(Module module, MavenProjectConfiguration projectCfg, MavenProject mavenProject) {
|
||||
private static void addEjbClientArtifactConfiguration(Module module, MavenProjectConfiguration projectCfg, MavenProject mavenProject) {
|
||||
Element pluginCfg = mavenProject.getPluginConfiguration("org.apache.maven.plugins", "maven-ejb-plugin");
|
||||
|
||||
if (pluginCfg == null || !Boolean.parseBoolean(pluginCfg.getChildTextTrim("generateClient"))) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,9 +18,7 @@ package com.jetbrains.python.testing.pytest;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.io.StreamUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.Base64;
|
||||
import com.jetbrains.python.traceBackParsers.LinkInTrace;
|
||||
import org.apache.log4j.Level;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
@@ -54,7 +52,7 @@ public final class PyTestTracebackParserTest {
|
||||
}
|
||||
final String longString = StringUtil.repeat("1", junkSize);
|
||||
myStringJunk = String.format("%s:%s", longString, longString);
|
||||
myBase64Junk = Base64.encode(junk);
|
||||
myBase64Junk = java.util.Base64.getEncoder().encodeToString(junk);
|
||||
myStringJunkWithSpaces = StringUtil.repeat("dd ddddddddd", junkSize);
|
||||
myStringJunkWithSpacesAndLine = myStringJunkWithSpaces + " c:/file:12";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user