-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use Bearer token if OPA started with it (#7353)
* feat: use Bearer token if OPA started with it #7340 Signed-off-by: Yuriy Movchan <Yuriy.Movchan@gmail.com> * feat: use Bearer token if OPA started with it #7340 Signed-off-by: Yuriy Movchan <Yuriy.Movchan@gmail.com> * feat: use Bearer token if OPA started with it #7340 Signed-off-by: Yuriy Movchan <Yuriy.Movchan@gmail.com> * feat: use Bearer token if OPA started with it #7340 Signed-off-by: Yuriy Movchan <Yuriy.Movchan@gmail.com> * feat: use Bearer token if OPA started with it #7340 Signed-off-by: Yuriy Movchan <Yuriy.Movchan@gmail.com> * feat: use Bearer token if OPA started with it #7340 Signed-off-by: Yuriy Movchan <Yuriy.Movchan@gmail.com> * feat: use Bearer token if OPA started with it #7340 Signed-off-by: Yuriy Movchan <Yuriy.Movchan@gmail.com> * feat: use Bearer token if OPA started with it #7340 Signed-off-by: Yuriy Movchan <Yuriy.Movchan@gmail.com> --------- Signed-off-by: Yuriy Movchan <Yuriy.Movchan@gmail.com>
- Loading branch information
Showing
40 changed files
with
166 additions
and
223 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
77 changes: 22 additions & 55 deletions
77
...-auth-server/common/src/main/java/io/jans/as/common/service/common/EncryptionService.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 |
---|---|---|
@@ -1,80 +1,47 @@ | ||
/* | ||
* Janssen Project software is available under the Apache License (2004). See http://www.apache.org/licenses/ for full text. | ||
* Janssen Project software is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text. | ||
* | ||
* Copyright (c) 2020, Janssen Project | ||
*/ | ||
|
||
package io.jans.as.common.service.common; | ||
|
||
import io.jans.util.StringHelper; | ||
import io.jans.util.security.PropertiesDecrypter; | ||
import io.jans.util.security.StringEncrypter; | ||
import io.jans.util.security.StringEncrypter.EncryptionException; | ||
import org.slf4j.Logger; | ||
import java.util.Properties; | ||
|
||
import io.jans.util.security.StringEncrypter.EncryptionException; | ||
import jakarta.enterprise.context.ApplicationScoped; | ||
import jakarta.inject.Inject; | ||
import java.util.Properties; | ||
|
||
/** | ||
* Allows to decrypt passwords | ||
* Proxy for compatibility with old versions | ||
* | ||
* @author Yuriy Movchan Date: 09/23/2014 | ||
* @author Yuriy Movchan Date: 01/12/2024 | ||
*/ | ||
@ApplicationScoped | ||
@Deprecated | ||
public class EncryptionService { | ||
|
||
@Inject | ||
private Logger log; | ||
|
||
@Inject | ||
private StringEncrypter stringEncrypter; | ||
|
||
public String decrypt(String encryptedString) throws EncryptionException { | ||
if (StringHelper.isEmpty(encryptedString)) { | ||
return null; | ||
} | ||
|
||
return stringEncrypter.decrypt(encryptedString); | ||
} | ||
|
||
public String decrypt(String encryptedValue, boolean returnSource) { | ||
if (encryptedValue == null) { | ||
return encryptedValue; | ||
} | ||
@Inject | ||
private io.jans.service.EncryptionService encryptionService; | ||
|
||
String resultValue; | ||
if (returnSource) { | ||
resultValue = encryptedValue; | ||
} else { | ||
resultValue = null; | ||
} | ||
public String decrypt(String encryptedString) throws EncryptionException { | ||
return encryptionService.decrypt(encryptedString); | ||
} | ||
|
||
try { | ||
resultValue = stringEncrypter.decrypt(encryptedValue); | ||
} catch (Exception ex) { | ||
if (!returnSource) { | ||
log.error(String.format("Failed to decrypt value: '%s'", encryptedValue, ex)); | ||
} | ||
} | ||
|
||
return resultValue; | ||
public String decrypt(String encryptedValue, boolean returnSource) { | ||
return encryptionService.decrypt(encryptedValue, returnSource); | ||
} | ||
|
||
public String encrypt(String unencryptedString) throws EncryptionException { | ||
if (StringHelper.isEmpty(unencryptedString)) { | ||
return null; | ||
} | ||
public String encrypt(String unencryptedString) throws EncryptionException { | ||
return encryptionService.decrypt(unencryptedString); | ||
} | ||
|
||
return stringEncrypter.encrypt(unencryptedString); | ||
} | ||
public Properties decryptProperties(Properties connectionProperties) { | ||
return encryptionService.decryptProperties(connectionProperties); | ||
} | ||
|
||
public Properties decryptProperties(Properties connectionProperties) { | ||
return PropertiesDecrypter.decryptProperties(stringEncrypter, connectionProperties); | ||
} | ||
|
||
public Properties decryptAllProperties(Properties connectionProperties) { | ||
return PropertiesDecrypter.decryptAllProperties(stringEncrypter, connectionProperties); | ||
} | ||
public Properties decryptAllProperties(Properties connectionProperties) { | ||
return encryptionService.decryptAllProperties(connectionProperties); | ||
} | ||
|
||
} |
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
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
Oops, something went wrong.