diff --git a/lib/annotations/jdk/java/math/annotations.xml b/lib/annotations/jdk/java/math/annotations.xml new file mode 100644 index 000000000000..e24dbcf105c1 --- /dev/null +++ b/lib/annotations/jdk/java/math/annotations.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/platform/built-in-server/src/org/jetbrains/builtInWebServer/BuiltInWebServer.kt b/platform/built-in-server/src/org/jetbrains/builtInWebServer/BuiltInWebServer.kt index e8d95620fac7..372e2c8af7c9 100644 --- a/platform/built-in-server/src/org/jetbrains/builtInWebServer/BuiltInWebServer.kt +++ b/platform/built-in-server/src/org/jetbrains/builtInWebServer/BuiltInWebServer.kt @@ -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 diff --git a/platform/platform-api/src/com/intellij/ide/passwordSafe/PasswordSafe.java b/platform/platform-api/src/com/intellij/ide/passwordSafe/PasswordSafe.java index 50d503b76411..5e64427a7829 100644 --- a/platform/platform-api/src/com/intellij/ide/passwordSafe/PasswordSafe.java +++ b/platform/platform-api/src/com/intellij/ide/passwordSafe/PasswordSafe.java @@ -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); } diff --git a/platform/platform-impl/src/com/intellij/ide/passwordSafe/config/PasswordSafeSettings.java b/platform/platform-impl/src/com/intellij/ide/passwordSafe/config/PasswordSafeSettings.java index 669b99de4955..f1edc303a264 100644 --- a/platform/platform-impl/src/com/intellij/ide/passwordSafe/config/PasswordSafeSettings.java +++ b/platform/platform-impl/src/com/intellij/ide/passwordSafe/config/PasswordSafeSettings.java @@ -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", diff --git a/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/masterKey/windows/WindowsCryptUtils.java b/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/masterKey/windows/WindowsCryptUtils.java index 0b7c5e00e83a..cffa1c8d2c8d 100644 --- a/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/masterKey/windows/WindowsCryptUtils.java +++ b/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/masterKey/windows/WindowsCryptUtils.java @@ -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; diff --git a/platform/platform-impl/src/com/intellij/openapi/util/io/fileUtil.kt b/platform/platform-impl/src/com/intellij/openapi/util/io/fileUtil.kt index eeb97cb8c019..fc752370b3c0 100644 --- a/platform/platform-impl/src/com/intellij/openapi/util/io/fileUtil.kt +++ b/platform/platform-impl/src/com/intellij/openapi/util/io/fileUtil.kt @@ -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) == '/') \ No newline at end of file +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) + } + } +} \ No newline at end of file diff --git a/platform/platform-tests/testSrc/com/intellij/ide/passwordSafe/impl/providers/masterKey/windows/WindowsCryptUtilTest.java b/platform/platform-tests/testSrc/com/intellij/ide/passwordSafe/impl/providers/masterKey/windows/WindowsCryptUtilTest.java index faa1d31b724a..c428b8bb0416 100644 --- a/platform/platform-tests/testSrc/com/intellij/ide/passwordSafe/impl/providers/masterKey/windows/WindowsCryptUtilTest.java +++ b/platform/platform-tests/testSrc/com/intellij/ide/passwordSafe/impl/providers/masterKey/windows/WindowsCryptUtilTest.java @@ -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];