use of org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProviderProperty in project carbon-identity-framework by wso2.
the class IdentityProviderManagementServiceTest method addResidentIdp.
private void addResidentIdp() throws IdentityProviderManagementException {
IdentityProvider residentIdp = new IdentityProvider();
residentIdp.setIdentityProviderName("LOCAL");
IdentityProviderProperty idpProperty1 = new IdentityProviderProperty();
idpProperty1.setName(IdentityApplicationConstants.SESSION_IDLE_TIME_OUT);
idpProperty1.setValue("20");
residentIdp.setIdpProperties(new IdentityProviderProperty[] { idpProperty1 });
identityProviderManagementService.addIdP(residentIdp);
}
use of org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProviderProperty in project identity-inbound-auth-oauth by wso2-extensions.
the class JWTSignatureValidationUtils method getJWKSUri.
/**
* Method to get the JWKS Uri of the identity provider.
*
* @param idp Identity provider to get the JWKS Uri.
* @return JWKS Uri of the identity provider.
*/
private static String getJWKSUri(IdentityProvider idp) {
String jwksUri = null;
IdentityProviderProperty[] identityProviderProperties = idp.getIdpProperties();
if (!ArrayUtils.isEmpty(identityProviderProperties)) {
for (IdentityProviderProperty identityProviderProperty : identityProviderProperties) {
if (StringUtils.equals(identityProviderProperty.getName(), JWKS_URI)) {
jwksUri = identityProviderProperty.getValue();
if (log.isDebugEnabled()) {
log.debug("JWKS endpoint set for the identity provider : " + idp.getIdentityProviderName() + ", jwks_uri : " + jwksUri);
}
break;
} else {
if (log.isDebugEnabled()) {
log.debug("JWKS endpoint not specified for the identity provider : " + idp.getIdentityProviderName());
}
}
}
}
return jwksUri;
}
use of org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProviderProperty in project identity-governance by wso2-extensions.
the class IdentityGovernanceServiceImpl method getConfiguration.
@Override
public Property[] getConfiguration(String tenantDomain) throws IdentityGovernanceException {
IdpManager identityProviderManager = IdentityMgtServiceDataHolder.getInstance().getIdpManager();
IdentityProvider residentIdp = null;
try {
residentIdp = identityProviderManager.getResidentIdP(tenantDomain);
} catch (IdentityProviderManagementException e) {
String errorMsg = String.format("Error while retrieving resident Idp for %s tenant.", tenantDomain);
throw new IdentityGovernanceException(errorMsg, e);
}
IdentityProviderProperty[] identityMgtProperties = residentIdp.getIdpProperties();
Property[] configMap = new Property[identityMgtProperties.length];
int index = 0;
for (IdentityProviderProperty identityMgtProperty : identityMgtProperties) {
if (IdentityEventConstants.PropertyConfig.ALREADY_WRITTEN_PROPERTY_KEY.equals(identityMgtProperty.getName())) {
continue;
}
Property property = new Property();
property.setName(identityMgtProperty.getName());
property.setValue(identityMgtProperty.getValue());
configMap[index] = property;
index++;
}
return configMap;
}
use of org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProviderProperty in project identity-governance by wso2-extensions.
the class IdentityGovernanceUtil method saveConnectorDefaultProperties.
@Deprecated
public static void saveConnectorDefaultProperties(IdentityConnectorConfig identityConnectorConfig, String tenantDomain) throws ConnectorException {
IdpManager identityProviderManager = IdentityMgtServiceDataHolder.getInstance().getIdpManager();
try {
IdentityProvider residentIdp = identityProviderManager.getResidentIdP(tenantDomain);
IdentityProviderProperty[] idpProperties = residentIdp.getIdpProperties();
String[] connectorPropertiesNames = identityConnectorConfig.getPropertyNames();
List<IdentityProviderProperty> propertiesToAdd = new ArrayList<>();
for (String connectorPropertyName : connectorPropertiesNames) {
boolean propertyExists = false;
for (IdentityProviderProperty property : idpProperties) {
if (connectorPropertyName.equals(property.getName())) {
propertyExists = true;
break;
}
}
if (!propertyExists) {
IdentityProviderProperty newProperty = new IdentityProviderProperty();
newProperty.setName(connectorPropertyName);
newProperty.setDisplayName(identityConnectorConfig.getPropertyNameMapping().get(connectorPropertyName));
Properties defaultPropertyValues = identityConnectorConfig.getDefaultPropertyValues(tenantDomain);
newProperty.setValue(String.valueOf(defaultPropertyValues.get(connectorPropertyName)));
propertiesToAdd.add(newProperty);
}
}
// If the property list size is greater than 0, add the new properties to the database.
if (propertiesToAdd.size() > 0) {
String alreadyWrittenPropertyName = identityConnectorConfig.getName() + "." + IdentityEventConstants.PropertyConfig.ALREADY_WRITTEN_PROPERTY_KEY;
boolean alreadyWrittenPropertyExists = false;
for (IdentityProviderProperty property : idpProperties) {
if (alreadyWrittenPropertyName.equals(property.getName())) {
alreadyWrittenPropertyExists = true;
break;
}
}
if (!alreadyWrittenPropertyExists) {
IdentityProviderProperty property = new IdentityProviderProperty();
property.setName(alreadyWrittenPropertyName);
property.setValue(IdentityEventConstants.PropertyConfig.ALREADY_WRITTEN_PROPERTY_VALUE);
propertiesToAdd.add(property);
}
propertiesToAdd.addAll(Arrays.asList(idpProperties));
residentIdp.setIdpProperties(propertiesToAdd.toArray(new IdentityProviderProperty[0]));
FederatedAuthenticatorConfig[] authenticatorConfigs = residentIdp.getFederatedAuthenticatorConfigs();
List<FederatedAuthenticatorConfig> configsToSave = new ArrayList<>();
for (FederatedAuthenticatorConfig authenticatorConfig : authenticatorConfigs) {
if (IdentityApplicationConstants.Authenticator.PassiveSTS.NAME.equals(authenticatorConfig.getName()) || IdentityApplicationConstants.Authenticator.SAML2SSO.NAME.equals(authenticatorConfig.getName())) {
configsToSave.add(authenticatorConfig);
}
}
residentIdp.setFederatedAuthenticatorConfigs(configsToSave.toArray(new FederatedAuthenticatorConfig[0]));
identityProviderManager.updateResidentIdP(residentIdp, tenantDomain);
if (log.isDebugEnabled()) {
log.debug("New resident IDP properties for tenant : " + tenantDomain + " written to database");
}
}
} catch (IdentityProviderManagementException e) {
log.error("Error while adding identity management properties to resident Idp.", e);
}
}
use of org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProviderProperty in project identity-governance by wso2-extensions.
the class PostAuthnMissingChallengeQuestionsHandlerTest method testAlreadyChallengeQuestionProvidedUserFlow.
@Test(description = "Test the flow for the user who has already given the challenge questions")
public void testAlreadyChallengeQuestionProvidedUserFlow() throws Exception {
AuthenticationContext context = spy(new AuthenticationContext());
when(context.getTenantDomain()).thenReturn("carbon.super");
IdentityProvider residentIdp = spy(new IdentityProvider());
IdentityProviderProperty[] idpProperties = new IdentityProviderProperty[1];
IdentityProviderProperty idpProp = new IdentityProviderProperty();
idpProp.setName(IdentityRecoveryConstants.ConnectorConfig.FORCE_ADD_PW_RECOVERY_QUESTION);
idpProp.setValue("true");
idpProperties[0] = idpProp;
residentIdp.setIdpProperties(idpProperties);
mockedIdentityProviderManager.when(IdentityProviderManager::getInstance).thenReturn(identityProviderManager);
when(identityProviderManager.getResidentIdP("carbon.super")).thenReturn(residentIdp);
SequenceConfig sequenceConfig = spy(new SequenceConfig());
AuthenticatedUser user = spy(new AuthenticatedUser());
user.setUserName("admin");
when(sequenceConfig.getAuthenticatedUser()).thenReturn(user);
context.setSequenceConfig(sequenceConfig);
mockedMultitenantUtils.when(() -> MultitenantUtils.getTenantDomain("admin")).thenReturn("carbon.super");
mockedUtils.when(() -> Utils.getTenantId("carbon.super")).thenReturn(-1234);
mockedIdentityRecoveryServiceDataHolder.when(IdentityRecoveryServiceDataHolder::getInstance).thenReturn(frameworkServiceDataHolder);
RealmService realmService = mock(RealmService.class);
UserStoreManager userStoreManager = mock(UserStoreManager.class);
UserRealm userRealm = mock(UserRealm.class);
when(userRealm.getUserStoreManager()).thenReturn(userStoreManager);
when(realmService.getTenantUserRealm(-1234)).thenReturn(userRealm);
when(frameworkServiceDataHolder.getRealmService()).thenReturn(realmService);
when(userRealm.getUserStoreManager()).thenReturn(userStoreManager);
Map<String, String> claimsMap = new HashMap<>();
claimsMap.put(IdentityRecoveryConstants.CHALLENGE_QUESTION_URI, "dummy_data");
when(userStoreManager.getUserClaimValues("admin", new String[] { IdentityRecoveryConstants.CHALLENGE_QUESTION_URI }, UserCoreConstants.DEFAULT_PROFILE)).thenReturn(claimsMap);
PostAuthnHandlerFlowStatus flowStatus = PostAuthnMissingChallengeQuestionsHandler.getInstance().handle(httpServletRequest, httpServletResponse, context);
String expectedResult = PostAuthnHandlerFlowStatus.SUCCESS_COMPLETED.name();
assertEquals(flowStatus.name(), expectedResult);
}
Aggregations