Search in sources :

Example 1 with ProcessInstanceConfig

use of org.forgerock.selfservice.core.config.ProcessInstanceConfig in project OpenAM by OpenRock.

the class ForgottenUsernameConfigProvider method getServiceConfig.

@Override
public ProcessInstanceConfig getServiceConfig(ForgottenUsernameConsoleConfig config, Context context, String realm) {
    List<StageConfig> stages = new ArrayList<>();
    if (config.isCaptchaEnabled()) {
        stages.add(new CaptchaStageConfig().setRecaptchaSiteKey(config.getCaptchaSiteKey()).setRecaptchaSecretKey(config.getCaptchaSecretKey()).setRecaptchaUri(config.getCaptchaVerificationUrl()));
    }
    stages.add(new UserQueryConfig().setValidQueryFields(config.getValidQueryAttributes()).setIdentityIdField("/username").setIdentityUsernameField("/username").setIdentityEmailField("/" + config.getEmailAttributeName() + "/0").setIdentityServiceUrl("/users"));
    if (config.isKbaEnabled()) {
        stages.add(new SecurityAnswerVerificationConfig(new KbaConfig()).setQuestions(config.getSecurityQuestions()).setKbaPropertyName("kbaInfo").setNumberOfQuestionsUserMustAnswer(config.getMinimumAnswersToVerify()).setIdentityServiceUrl("/users"));
    }
    if (config.isEmailEnabled()) {
        stages.add(new EmailUsernameConfig().setEmailServiceUrl("/email").setSubjectTranslations(config.getSubjectTranslations()).setMessageTranslations(config.getMessageTranslations()).setMimeType("text/html").setUsernameToken("%username%"));
    }
    if (config.isShowUsernameEnabled()) {
        stages.add(new RetrieveUsernameConfig());
    }
    String secret = SystemProperties.get(Constants.ENC_PWD_PROPERTY);
    JwtTokenHandlerConfig jwtTokenConfig = new JwtTokenHandlerConfig().setSharedKey(secret).setKeyPairAlgorithm("RSA").setKeyPairSize(1024).setJweAlgorithm(JweAlgorithm.RSAES_PKCS1_V1_5).setEncryptionMethod(EncryptionMethod.A128CBC_HS256).setJwsAlgorithm(JwsAlgorithm.HS256).setTokenLifeTimeInSeconds(config.getTokenExpiry());
    return new ProcessInstanceConfig().setStageConfigs(stages).setSnapshotTokenConfig(jwtTokenConfig).setStorageType(StorageType.STATELESS);
}
Also used : CaptchaStageConfig(org.forgerock.selfservice.stages.captcha.CaptchaStageConfig) JwtTokenHandlerConfig(org.forgerock.selfservice.stages.tokenhandlers.JwtTokenHandlerConfig) ArrayList(java.util.ArrayList) SecurityAnswerVerificationConfig(org.forgerock.selfservice.stages.kba.SecurityAnswerVerificationConfig) EmailUsernameConfig(org.forgerock.selfservice.stages.user.EmailUsernameConfig) RetrieveUsernameConfig(org.forgerock.selfservice.stages.user.RetrieveUsernameConfig) KbaConfig(org.forgerock.selfservice.stages.kba.KbaConfig) UserQueryConfig(org.forgerock.selfservice.stages.user.UserQueryConfig) CaptchaStageConfig(org.forgerock.selfservice.stages.captcha.CaptchaStageConfig) StageConfig(org.forgerock.selfservice.core.config.StageConfig) ProcessInstanceConfig(org.forgerock.selfservice.core.config.ProcessInstanceConfig)

Example 2 with ProcessInstanceConfig

use of org.forgerock.selfservice.core.config.ProcessInstanceConfig in project OpenAM by OpenRock.

the class SelfServiceRequestHandlerTest method initialReadCallsIntoUnderlyingService.

@Test
public void initialReadCallsIntoUnderlyingService() throws ResourceException {
    // When
    ReadRequest request = Requests.newReadRequest("/someEndpoint");
    given(consoleConfigHandler.getConfig("/", MockBuilder.class)).willReturn(consoleConfig);
    given(providerFactory.getProvider(consoleConfig)).willReturn(configProvider);
    given(configProvider.isServiceEnabled(consoleConfig)).willReturn(true);
    ProcessInstanceConfig config = new ProcessInstanceConfig();
    given(configProvider.getServiceConfig(consoleConfig, context, "/")).willReturn(config);
    given(serviceFactory.getService("/", config)).willReturn(underlyingService);
    // Given
    selfServiceHandler.handleRead(context, request);
    // Then
    verify(underlyingService).handleRead(context, request);
}
Also used : ProcessInstanceConfig(org.forgerock.selfservice.core.config.ProcessInstanceConfig) ReadRequest(org.forgerock.json.resource.ReadRequest) Test(org.testng.annotations.Test)

Example 3 with ProcessInstanceConfig

use of org.forgerock.selfservice.core.config.ProcessInstanceConfig in project OpenAM by OpenRock.

the class SelfServiceRequestHandlerTest method initialActionCallsIntoUnderlyingService.

@Test
public void initialActionCallsIntoUnderlyingService() throws ResourceException {
    // When
    ActionRequest request = Requests.newActionRequest("/someEndpoint", "submitRequirements");
    given(consoleConfigHandler.getConfig("/", MockBuilder.class)).willReturn(consoleConfig);
    given(providerFactory.getProvider(consoleConfig)).willReturn(configProvider);
    given(configProvider.isServiceEnabled(consoleConfig)).willReturn(true);
    ProcessInstanceConfig config = new ProcessInstanceConfig();
    given(configProvider.getServiceConfig(consoleConfig, context, "/")).willReturn(config);
    given(serviceFactory.getService("/", config)).willReturn(underlyingService);
    // Given
    selfServiceHandler.handleAction(context, request);
    // Then
    verify(underlyingService).handleAction(context, request);
}
Also used : ActionRequest(org.forgerock.json.resource.ActionRequest) ProcessInstanceConfig(org.forgerock.selfservice.core.config.ProcessInstanceConfig) Test(org.testng.annotations.Test)

Example 4 with ProcessInstanceConfig

use of org.forgerock.selfservice.core.config.ProcessInstanceConfig in project OpenAM by OpenRock.

the class ForgottenPasswordConfigProvider method getServiceConfig.

@Override
public ProcessInstanceConfig getServiceConfig(ForgottenPasswordConsoleConfig config, Context context, String realm) {
    List<StageConfig> stages = new ArrayList<>();
    if (config.isCaptchaEnabled()) {
        stages.add(new CaptchaStageConfig().setRecaptchaSiteKey(config.getCaptchaSiteKey()).setRecaptchaSecretKey(config.getCaptchaSecretKey()).setRecaptchaUri(config.getCaptchaVerificationUrl()));
    }
    stages.add(new UserQueryConfig().setValidQueryFields(config.getValidQueryAttributes()).setIdentityIdField("/username").setIdentityUsernameField("/username").setIdentityEmailField("/" + config.getEmailAttributeName() + "/0").setIdentityServiceUrl("/users"));
    if (config.isEmailEnabled()) {
        String serverUrl = config.getEmailVerificationUrl() + "&realm=" + realm;
        stages.add(new VerifyEmailAccountConfig().setEmailServiceUrl("/email").setIdentityEmailField(config.getEmailAttributeName()).setSubjectTranslations(config.getSubjectTranslations()).setMessageTranslations(config.getMessageTranslations()).setMimeType("text/html").setVerificationLinkToken("%link%").setVerificationLink(serverUrl));
    }
    if (config.isKbaEnabled()) {
        stages.add(new SecurityAnswerVerificationConfig(new KbaConfig()).setQuestions(config.getSecurityQuestions()).setKbaPropertyName("kbaInfo").setNumberOfQuestionsUserMustAnswer(config.getMinimumAnswersToVerify()).setIdentityServiceUrl("/users"));
    }
    stages.add(new ResetStageConfig().setIdentityServiceUrl("/users").setIdentityPasswordField("userPassword"));
    String secret = SystemProperties.get(Constants.ENC_PWD_PROPERTY);
    JwtTokenHandlerConfig jwtTokenConfig = new JwtTokenHandlerConfig().setSharedKey(secret).setKeyPairAlgorithm("RSA").setKeyPairSize(1024).setJweAlgorithm(JweAlgorithm.RSAES_PKCS1_V1_5).setEncryptionMethod(EncryptionMethod.A128CBC_HS256).setJwsAlgorithm(JwsAlgorithm.HS256).setTokenLifeTimeInSeconds(config.getTokenExpiry());
    return new ProcessInstanceConfig().setStageConfigs(stages).setSnapshotTokenConfig(jwtTokenConfig).setStorageType(StorageType.STATELESS);
}
Also used : CaptchaStageConfig(org.forgerock.selfservice.stages.captcha.CaptchaStageConfig) VerifyEmailAccountConfig(org.forgerock.selfservice.stages.email.VerifyEmailAccountConfig) JwtTokenHandlerConfig(org.forgerock.selfservice.stages.tokenhandlers.JwtTokenHandlerConfig) ArrayList(java.util.ArrayList) SecurityAnswerVerificationConfig(org.forgerock.selfservice.stages.kba.SecurityAnswerVerificationConfig) ResetStageConfig(org.forgerock.selfservice.stages.reset.ResetStageConfig) KbaConfig(org.forgerock.selfservice.stages.kba.KbaConfig) UserQueryConfig(org.forgerock.selfservice.stages.user.UserQueryConfig) ResetStageConfig(org.forgerock.selfservice.stages.reset.ResetStageConfig) CaptchaStageConfig(org.forgerock.selfservice.stages.captcha.CaptchaStageConfig) StageConfig(org.forgerock.selfservice.core.config.StageConfig) ProcessInstanceConfig(org.forgerock.selfservice.core.config.ProcessInstanceConfig)

Example 5 with ProcessInstanceConfig

use of org.forgerock.selfservice.core.config.ProcessInstanceConfig in project OpenAM by OpenRock.

the class UserRegistrationConfigProvider method getServiceConfig.

@Override
public ProcessInstanceConfig getServiceConfig(UserRegistrationConsoleConfig config, Context context, String realm) {
    List<StageConfig> stages = new ArrayList<>();
    if (config.isCaptchaEnabled()) {
        stages.add(new CaptchaStageConfig().setRecaptchaSiteKey(config.getCaptchaSiteKey()).setRecaptchaSecretKey(config.getCaptchaSecretKey()).setRecaptchaUri(config.getCaptchaVerificationUrl()));
    }
    if (config.isEmailEnabled()) {
        String serverUrl = config.getEmailVerificationUrl() + "&realm=" + realm;
        stages.add(new VerifyEmailAccountConfig().setEmailServiceUrl("/email").setIdentityEmailField(config.getEmailAttributeName()).setSubjectTranslations(config.getSubjectTranslations()).setMessageTranslations(config.getMessageTranslations()).setMimeType("text/html").setVerificationLinkToken("%link%").setVerificationLink(serverUrl));
    }
    stages.add(new UserDetailsConfig().setIdentityEmailField(config.getEmailAttributeName()));
    if (config.isKbaEnabled()) {
        stages.add(new SecurityAnswerDefinitionConfig(new KbaConfig()).setQuestions(config.getSecurityQuestions()).setNumberOfAnswersUserMustSet(config.getMinimumAnswersToDefine()).setKbaPropertyName("kbaInfo"));
    }
    stages.add(new UserRegistrationConfig().setIdentityServiceUrl("/users"));
    String secret = SystemProperties.get(Constants.ENC_PWD_PROPERTY);
    JwtTokenHandlerConfig jwtTokenConfig = new JwtTokenHandlerConfig().setSharedKey(secret).setKeyPairAlgorithm("RSA").setKeyPairSize(1024).setJweAlgorithm(JweAlgorithm.RSAES_PKCS1_V1_5).setEncryptionMethod(EncryptionMethod.A128CBC_HS256).setJwsAlgorithm(JwsAlgorithm.HS256).setTokenLifeTimeInSeconds(config.getTokenExpiry());
    return new ProcessInstanceConfig().setStageConfigs(stages).setSnapshotTokenConfig(jwtTokenConfig).setStorageType(StorageType.STATELESS);
}
Also used : SecurityAnswerDefinitionConfig(org.forgerock.selfservice.stages.kba.SecurityAnswerDefinitionConfig) CaptchaStageConfig(org.forgerock.selfservice.stages.captcha.CaptchaStageConfig) VerifyEmailAccountConfig(org.forgerock.selfservice.stages.email.VerifyEmailAccountConfig) UserRegistrationConfig(org.forgerock.selfservice.stages.registration.UserRegistrationConfig) UserDetailsConfig(org.forgerock.selfservice.stages.user.UserDetailsConfig) JwtTokenHandlerConfig(org.forgerock.selfservice.stages.tokenhandlers.JwtTokenHandlerConfig) ArrayList(java.util.ArrayList) KbaConfig(org.forgerock.selfservice.stages.kba.KbaConfig) CaptchaStageConfig(org.forgerock.selfservice.stages.captcha.CaptchaStageConfig) StageConfig(org.forgerock.selfservice.core.config.StageConfig) ProcessInstanceConfig(org.forgerock.selfservice.core.config.ProcessInstanceConfig)

Aggregations

ProcessInstanceConfig (org.forgerock.selfservice.core.config.ProcessInstanceConfig)5 ArrayList (java.util.ArrayList)3 StageConfig (org.forgerock.selfservice.core.config.StageConfig)3 CaptchaStageConfig (org.forgerock.selfservice.stages.captcha.CaptchaStageConfig)3 KbaConfig (org.forgerock.selfservice.stages.kba.KbaConfig)3 JwtTokenHandlerConfig (org.forgerock.selfservice.stages.tokenhandlers.JwtTokenHandlerConfig)3 VerifyEmailAccountConfig (org.forgerock.selfservice.stages.email.VerifyEmailAccountConfig)2 SecurityAnswerVerificationConfig (org.forgerock.selfservice.stages.kba.SecurityAnswerVerificationConfig)2 UserQueryConfig (org.forgerock.selfservice.stages.user.UserQueryConfig)2 Test (org.testng.annotations.Test)2 ActionRequest (org.forgerock.json.resource.ActionRequest)1 ReadRequest (org.forgerock.json.resource.ReadRequest)1 SecurityAnswerDefinitionConfig (org.forgerock.selfservice.stages.kba.SecurityAnswerDefinitionConfig)1 UserRegistrationConfig (org.forgerock.selfservice.stages.registration.UserRegistrationConfig)1 ResetStageConfig (org.forgerock.selfservice.stages.reset.ResetStageConfig)1 EmailUsernameConfig (org.forgerock.selfservice.stages.user.EmailUsernameConfig)1 RetrieveUsernameConfig (org.forgerock.selfservice.stages.user.RetrieveUsernameConfig)1 UserDetailsConfig (org.forgerock.selfservice.stages.user.UserDetailsConfig)1