use of com.sun.identity.shared.debug.Debug in project OpenAM by OpenRock.
the class AMIdentityMembershipConditionTest method setUp.
@BeforeMethod
public void setUp() {
Debug debug = mock(Debug.class);
coreWrapper = mock(CoreWrapper.class);
condition = new AMIdentityMembershipCondition(debug, coreWrapper);
adminToken = mock(SSOToken.class);
given(coreWrapper.getAdminToken()).willReturn(adminToken);
}
use of com.sun.identity.shared.debug.Debug in project OpenAM by OpenRock.
the class OpenAMTokenStoreTest method setUp.
@BeforeMethod
public void setUp() {
tokenStore = mock(OAuthTokenStore.class);
providerSettingsFactory = mock(OAuth2ProviderSettingsFactory.class);
oAuth2UrisFactory = mock(OAuth2UrisFactory.class);
clientRegistrationStore = mock(OpenIdConnectClientRegistrationStore.class);
realmNormaliser = mock(RealmNormaliser.class);
ssoTokenManager = mock(SSOTokenManager.class);
request = mock(Request.class);
cookieExtractor = mock(CookieExtractor.class);
auditLogger = mock(OAuth2AuditLogger.class);
debug = mock(Debug.class);
failureFactory = mock(ClientAuthenticationFailureFactory.class);
oAuth2RequestFactory = new RestletOAuth2RequestFactory(new JacksonRepresentationFactory(new ObjectMapper()));
ClientAuthenticationFailureFactory failureFactory = mock(ClientAuthenticationFailureFactory.class);
InvalidClientException expectedResult = mock(InvalidClientException.class);
when(expectedResult.getError()).thenReturn(new String("invalid_client"));
when(failureFactory.getException()).thenReturn(expectedResult);
when(failureFactory.getException(anyString())).thenReturn(expectedResult);
when(failureFactory.getException(any(OAuth2Request.class), anyString())).thenReturn(expectedResult);
openAMtokenStore = new OpenAMTokenStore(tokenStore, providerSettingsFactory, oAuth2UrisFactory, clientRegistrationStore, realmNormaliser, ssoTokenManager, cookieExtractor, auditLogger, debug, new SecureRandom(), failureFactory);
}
use of com.sun.identity.shared.debug.Debug in project OpenAM by OpenRock.
the class JCEEncryption method pbeEncrypt.
/**
* Method declaration
*
* @param clearText
*/
private byte[] pbeEncrypt(final byte[] clearText) {
byte[] result = null;
if (clearText == null || clearText.length == 0) {
return null;
}
if (_initialized) {
try {
byte[] type = new byte[2];
type[1] = (byte) DEFAULT_ENC_ALG_INDEX;
type[0] = (byte) DEFAULT_KEYGEN_ALG_INDEX;
final Cipher pbeCipher = cipherProvider.getCipher();
if (pbeCipher != null) {
pbeCipher.init(Cipher.ENCRYPT_MODE, pbeKey, pbeParameterSpec);
result = pbeCipher.doFinal(clearText);
byte[] iv = pbeCipher.getIV();
result = addPrefix(type, iv, result);
} else {
Debug debug = Debug.getInstance("amSDK");
if (debug != null) {
debug.error("JCEEncryption: Failed to obtain Cipher");
}
}
} catch (Exception ex) {
Debug debug = Debug.getInstance("amSDK");
if (debug != null) {
debug.error("JCEEncryption:: failed to encrypt data", ex);
}
}
} else {
Debug debug = Debug.getInstance("amSDK");
if (debug != null) {
debug.error("JCEEncryption:: not yet initialized");
}
}
return result;
}
use of com.sun.identity.shared.debug.Debug in project OpenAM by OpenRock.
the class JCEEncryption method pbeDecrypt.
/**
* Method declaration
*
* @param cipherText
*/
private byte[] pbeDecrypt(byte[] cipherText) {
byte[] result = null;
if (_initialized) {
try {
byte[] share = cipherText;
if (share[0] != VERSION) {
Debug debug = Debug.getInstance("amSDK");
if (debug != null) {
debug.error("JCEEncryption:: Unsupported version: " + share[0]);
}
return null;
}
byte[] raw = getRaw(share);
final Cipher pbeCipher = cipherProvider.getCipher();
if (pbeCipher != null) {
pbeCipher.init(Cipher.DECRYPT_MODE, pbeKey, pbeParameterSpec);
result = pbeCipher.doFinal(raw);
} else {
Debug debug = Debug.getInstance("amSDK");
if (debug != null) {
debug.error("JCEEncryption: Failed to obtain Cipher");
}
}
} catch (Exception ex) {
Debug debug = Debug.getInstance("amSDK");
if (debug != null) {
debug.error("JCEEncryption:: failed to decrypt data", ex);
}
}
} else {
Debug debug = Debug.getInstance("amSDK");
if (debug != null) {
debug.error("JCEEncryption:: not yet initialized");
}
}
return result;
}
use of com.sun.identity.shared.debug.Debug in project OpenAM by OpenRock.
the class CLIUtil method getFileContent.
/**
* Returns content of a file.
*
* @param mgr Command Line Manager.
* @param fileName Name of file.
* @param singleLine <code>true</code> to only read one line from the file.
* @return content of a file.
* @throws CLIException if file content cannot be returned.
*/
public static String getFileContent(CommandManager mgr, String fileName, boolean singleLine) throws CLIException {
File test = new File(fileName);
if (!test.exists()) {
Object[] param = { fileName };
throw new CLIException(MessageFormat.format(mgr.getResourceBundle().getString("error-message-file-does-not-exist"), param), ExitCodes.CANNOT_READ_FILE);
}
StringBuilder buff = new StringBuilder();
BufferedReader in = null;
try {
in = new BufferedReader(new FileReader(fileName));
if (in.ready()) {
String line = in.readLine();
while (line != null) {
buff.append(line);
if (singleLine) {
break;
} else {
buff.append("\n");
line = in.readLine();
}
}
}
} catch (IOException e) {
throw new CLIException(e.getMessage(), ExitCodes.CANNOT_READ_FILE);
} finally {
if (in != null) {
try {
in.close();
} catch (Exception e) {
Debug debugger = CommandManager.getDebugger();
if (debugger.warningEnabled()) {
debugger.warning("cannot close file, " + fileName, e);
}
}
}
}
return buff.toString();
}
Aggregations