-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[329832604] Fix password-related NPEs in Oracle, provide more descrip…
…tive errors (#369) Fix password-related NPEs in Oracle, provide more descriptive errors (#369) - introduce changes to how password prompts are handled by Dumper - handle cases where incomplete authorization is provided to Oracle connectors bug id: 329832604
- Loading branch information
Showing
12 changed files
with
179 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
...pp/src/main/java/com/google/edwmigration/dumper/application/dumper/io/PasswordReader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright 2022-2023 Google LLC | ||
* Copyright 2013-2021 CompilerWorks | ||
* | ||
* 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.google.edwmigration.dumper.application.dumper.io; | ||
|
||
import com.google.edwmigration.dumper.application.dumper.MetadataDumperUsageException; | ||
import java.io.Console; | ||
import javax.annotation.Nonnull; | ||
|
||
/** | ||
* Provides the functionality of reading a password from prompt. | ||
* | ||
* <p>Needed, because users may not want to provide the password on the command line. This might be | ||
* for security reasons or due to issues caused by special characters. | ||
*/ | ||
public class PasswordReader { | ||
|
||
private boolean hasCachedValue = false; | ||
@Nonnull private String cachedValue = ""; | ||
|
||
@Nonnull | ||
public synchronized String getOrPrompt() { | ||
if (hasCachedValue) { | ||
return cachedValue; | ||
} | ||
Console console = System.console(); | ||
if (console == null) { | ||
// user requested a prompt, but we can't even get a console, so let's just fail | ||
throw new MetadataDumperUsageException( | ||
"A password prompt was requested, but there is no console available."); | ||
} | ||
console.printf("Password: "); | ||
cachedValue = new String(console.readPassword()); | ||
hasCachedValue = true; | ||
return cachedValue; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.