Search in sources :

Example 1 with Debug

use of com.sun.identity.shared.debug.Debug in project OpenAM by OpenRock.

the class LdapSearchHandlerTest method setUp.

@BeforeMethod
public void setUp() throws Exception {
    mockConnection = mock(Connection.class);
    mockRequest = mock(SearchRequest.class);
    debug = mock(Debug.class);
    handler = new LdapSearchHandler(new CTSDataLayerConfiguration("ou=test-case"), debug);
}
Also used : SearchRequest(org.forgerock.opendj.ldap.requests.SearchRequest) Connection(org.forgerock.opendj.ldap.Connection) LdapSearchHandler(org.forgerock.openam.sm.datalayer.impl.ldap.LdapSearchHandler) Debug(com.sun.identity.shared.debug.Debug) CTSDataLayerConfiguration(org.forgerock.openam.cts.impl.CTSDataLayerConfiguration) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 2 with Debug

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);
}
Also used : CoreWrapper(org.forgerock.openam.core.CoreWrapper) SSOToken(com.iplanet.sso.SSOToken) Debug(com.sun.identity.shared.debug.Debug) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 3 with Debug

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);
}
Also used : OAuth2UrisFactory(org.forgerock.oauth2.core.OAuth2UrisFactory) SSOTokenManager(com.iplanet.sso.SSOTokenManager) JacksonRepresentationFactory(org.forgerock.openam.rest.representations.JacksonRepresentationFactory) RestletOAuth2Request(org.forgerock.oauth2.restlet.RestletOAuth2Request) Request(org.restlet.Request) OAuth2Request(org.forgerock.oauth2.core.OAuth2Request) SecureRandom(java.security.SecureRandom) BDDMockito.anyString(org.mockito.BDDMockito.anyString) OpenIdConnectClientRegistrationStore(org.forgerock.openidconnect.OpenIdConnectClientRegistrationStore) ClientAuthenticationFailureFactory(org.forgerock.oauth2.core.exceptions.ClientAuthenticationFailureFactory) RealmNormaliser(org.forgerock.openam.utils.RealmNormaliser) RestletOAuth2Request(org.forgerock.oauth2.restlet.RestletOAuth2Request) OAuth2Request(org.forgerock.oauth2.core.OAuth2Request) OAuth2ProviderSettingsFactory(org.forgerock.oauth2.core.OAuth2ProviderSettingsFactory) InvalidClientException(org.forgerock.oauth2.core.exceptions.InvalidClientException) RestletOAuth2RequestFactory(org.forgerock.oauth2.restlet.RestletOAuth2RequestFactory) Debug(com.sun.identity.shared.debug.Debug) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 4 with Debug

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;
}
Also used : Cipher(javax.crypto.Cipher) Debug(com.sun.identity.shared.debug.Debug)

Example 5 with Debug

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;
}
Also used : Cipher(javax.crypto.Cipher) Debug(com.sun.identity.shared.debug.Debug)

Aggregations

Debug (com.sun.identity.shared.debug.Debug)50 BeforeMethod (org.testng.annotations.BeforeMethod)15 IOException (java.io.IOException)14 ByteString (org.forgerock.opendj.ldap.ByteString)10 FileNotFoundException (java.io.FileNotFoundException)8 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)7 NoSuchPaddingException (javax.crypto.NoSuchPaddingException)7 HashSet (java.util.HashSet)6 LdapException (org.forgerock.opendj.ldap.LdapException)6 BufferedReader (java.io.BufferedReader)5 File (java.io.File)5 Subject (javax.security.auth.Subject)5 CoreWrapper (org.forgerock.openam.core.CoreWrapper)5 Test (org.testng.annotations.Test)5 StringReader (java.io.StringReader)4 UnsupportedEncodingException (java.io.UnsupportedEncodingException)4 SSOToken (com.iplanet.sso.SSOToken)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 ArrayList (java.util.ArrayList)3 ZipFile (java.util.zip.ZipFile)3