mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
<root>
|
||||
<item name='java.math.BigInteger java.lang.String toString(int)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
</root>
|
||||
@@ -32,6 +32,7 @@ import com.intellij.openapi.ui.Messages
|
||||
import com.intellij.openapi.util.SystemInfoRt
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import com.intellij.openapi.util.io.endsWithName
|
||||
import com.intellij.openapi.util.io.setOwnerPermissions
|
||||
import com.intellij.openapi.util.registry.Registry
|
||||
import com.intellij.openapi.util.text.StringUtil
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
@@ -52,11 +53,8 @@ import java.awt.datatransfer.StringSelection
|
||||
import java.io.IOException
|
||||
import java.math.BigInteger
|
||||
import java.net.InetAddress
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Path
|
||||
import java.nio.file.Paths
|
||||
import java.nio.file.attribute.PosixFileAttributeView
|
||||
import java.nio.file.attribute.PosixFilePermission
|
||||
import java.security.SecureRandom
|
||||
import java.util.*
|
||||
import java.util.concurrent.TimeUnit
|
||||
@@ -127,15 +125,7 @@ private val STANDARD_COOKIE by lazy {
|
||||
if (token == null) {
|
||||
token = UUID.randomUUID().toString()
|
||||
file.write(token!!)
|
||||
val view = Files.getFileAttributeView(file, PosixFileAttributeView::class.java)
|
||||
if (view != null) {
|
||||
try {
|
||||
view.setPermissions(setOf(PosixFilePermission.OWNER_READ, PosixFilePermission.OWNER_WRITE))
|
||||
}
|
||||
catch (e: IOException) {
|
||||
LOG.warn(e)
|
||||
}
|
||||
}
|
||||
file.setOwnerPermissions()
|
||||
}
|
||||
|
||||
// explicit setting domain cookie on localhost doesn't work for chrome
|
||||
|
||||
@@ -16,21 +16,10 @@
|
||||
package com.intellij.ide.passwordSafe;
|
||||
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* The password safe component. It allows storing, removing, and retrieving the passwords.
|
||||
* Note that on the first access to the password safe functions, the dialog asking for the
|
||||
* master password might have to be shown. So the access should be either done from UI thread,
|
||||
* or it should be possible to invoke {@link java.awt.EventQueue#invokeAndWait(Runnable)}
|
||||
* method when password access methods are invoked.
|
||||
*
|
||||
* @see com.intellij.ide.passwordSafe.ui.PasswordSafePromptDialog
|
||||
*/
|
||||
public abstract class PasswordSafe implements PasswordStorage {
|
||||
|
||||
/**
|
||||
* @return the instance of password safe service
|
||||
*/
|
||||
@NotNull
|
||||
public static PasswordSafe getInstance() {
|
||||
return ServiceManager.getService(PasswordSafe.class);
|
||||
}
|
||||
|
||||
-1
@@ -22,7 +22,6 @@ import com.intellij.openapi.components.Storage;
|
||||
|
||||
/**
|
||||
* The password safe settings
|
||||
* The password database. The internal component for {@link com.intellij.ide.passwordSafe.impl.providers.masterKey.MasterKeyPasswordSafe}.
|
||||
*/
|
||||
@State(
|
||||
name = "PasswordSafe",
|
||||
|
||||
+4
-1
@@ -23,6 +23,7 @@ import com.sun.jna.Structure;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
import com.sun.jna.win32.W32APIFunctionMapper;
|
||||
import com.sun.jna.win32.W32APITypeMapper;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -51,7 +52,8 @@ public class WindowsCryptUtils {
|
||||
* @param data the data to protect
|
||||
* @return the the protected form the data
|
||||
*/
|
||||
public static byte[] protect(byte[] data) {
|
||||
@NotNull
|
||||
public static byte[] protect(@NotNull byte[] data) {
|
||||
if(data.length == 0) {
|
||||
return data;
|
||||
}
|
||||
@@ -74,6 +76,7 @@ public class WindowsCryptUtils {
|
||||
* @param data the data to protect
|
||||
* @return the the protected form the data
|
||||
*/
|
||||
@NotNull
|
||||
public static byte[] unprotect(byte[] data) {
|
||||
if(data.length == 0) {
|
||||
return data;
|
||||
|
||||
@@ -15,9 +15,17 @@
|
||||
*/
|
||||
package com.intellij.openapi.util.io
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger
|
||||
import com.intellij.openapi.util.text.StringUtil
|
||||
import com.intellij.util.PathUtilRt
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Path
|
||||
import java.nio.file.attribute.PosixFileAttributeView
|
||||
import java.nio.file.attribute.PosixFilePermission
|
||||
|
||||
private val LOG = Logger.getInstance("#com.intellij.openapi.util.io.FileUtil")
|
||||
|
||||
val File.systemIndependentPath: String
|
||||
get() = path.replace(File.separatorChar, '/')
|
||||
@@ -30,4 +38,15 @@ fun getParentPath(path: String) = StringUtil.nullize(PathUtilRt.getParentPath(pa
|
||||
|
||||
fun endsWithSlash(path: String) = path.getOrNull(path.length - 1) == '/'
|
||||
|
||||
fun endsWithName(path: String, name: String) = path.endsWith(name) && (path.length == name.length || path.getOrNull(path.length - name.length - 1) == '/')
|
||||
fun endsWithName(path: String, name: String) = path.endsWith(name) && (path.length == name.length || path.getOrNull(path.length - name.length - 1) == '/')
|
||||
|
||||
fun Path.setOwnerPermissions() {
|
||||
Files.getFileAttributeView(this, PosixFileAttributeView::class.java)?.let {
|
||||
try {
|
||||
it.setPermissions(setOf(PosixFilePermission.OWNER_READ, PosixFilePermission.OWNER_WRITE))
|
||||
}
|
||||
catch (e: IOException) {
|
||||
LOG.warn(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
+16
-2
@@ -1,7 +1,21 @@
|
||||
/*
|
||||
* 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 com.intellij.ide.passwordSafe.impl.providers.masterKey.windows;
|
||||
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.ide.passwordSafe.MasterPasswordUnavailableException;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -12,7 +26,7 @@ import java.security.SecureRandom;
|
||||
*/
|
||||
public class WindowsCryptUtilTest {
|
||||
@Test
|
||||
public void testProtect() throws MasterPasswordUnavailableException {
|
||||
public void testProtect() {
|
||||
if(SystemInfo.isWindows) {
|
||||
SecureRandom t = new SecureRandom();
|
||||
byte[] data = new byte[256];
|
||||
|
||||
Reference in New Issue
Block a user