use of org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProviderProperty in project product-is by wso2.
the class SelfRegistrationTestCase method updateResidentIdP.
@Test(description = "2.1.1")
public void updateResidentIdP() throws Exception {
IdentityProvider identityProvider = identityProviderMgtServiceClient.getResidentIdP();
for (IdentityProviderProperty property : identityProvider.getIdpProperties()) {
if (SELF_REGISTRATION_ENABLE.equals(property.getName())) {
property.setValue("true");
} else if (SELF_REGISTRATION_LOCK_ON_CREATION.equals(property.getName())) {
property.setValue("true");
} else if (SELF_REGISTRATION_NOTIFICATION_IM.equals(property.getName())) {
property.setValue("false");
} else if (SELF_REGISTRATION_RE_CAPTCHA.equals(property.getName())) {
property.setValue("false");
} else if (SELF_REGISTRATION_CODE_EXPIRY_TIME.equals(property.getName())) {
property.setValue("1440");
}
}
// This is to remove invalid authenticators
updateFederatedAuthenticators(identityProvider);
identityProviderMgtServiceClient.updateResidentIdP(identityProvider);
IdentityProvider updatedIdentityProvider = identityProviderMgtServiceClient.getResidentIdP();
for (IdentityProviderProperty property : updatedIdentityProvider.getIdpProperties()) {
if (SELF_REGISTRATION_ENABLE.equals(property.getName())) {
assertEquals(property.getValue(), "true");
} else if (SELF_REGISTRATION_LOCK_ON_CREATION.equals(property.getName())) {
assertEquals(property.getValue(), "true");
} else if (SELF_REGISTRATION_NOTIFICATION_IM.equals(property.getName())) {
assertEquals(property.getValue(), "false");
} else if (SELF_REGISTRATION_RE_CAPTCHA.equals(property.getName())) {
assertEquals(property.getValue(), "false");
} else if (SELF_REGISTRATION_CODE_EXPIRY_TIME.equals(property.getName())) {
assertEquals(property.getValue(), "1440");
}
}
// To sync the local caches.
Thread.sleep(5000);
}
use of org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProviderProperty in project identity-api-server by wso2.
the class ServerIdpManagementService method createIDP.
private IdentityProvider createIDP(IdentityProviderPOSTRequest identityProviderPOSTRequest) {
String idpJWKSUri = null;
IdentityProvider idp = new IdentityProvider();
idp.setIdentityProviderName(identityProviderPOSTRequest.getName());
idp.setAlias(identityProviderPOSTRequest.getAlias());
idp.setTemplateId(identityProviderPOSTRequest.getTemplateId());
idp.setPrimary(false);
idp.setIdentityProviderDescription(identityProviderPOSTRequest.getDescription());
idp.setHomeRealmId(identityProviderPOSTRequest.getHomeRealmIdentifier());
idp.setImageUrl(identityProviderPOSTRequest.getImage());
if (identityProviderPOSTRequest.getCertificate() != null && StringUtils.isNotBlank(identityProviderPOSTRequest.getCertificate().getJwksUri())) {
idpJWKSUri = identityProviderPOSTRequest.getCertificate().getJwksUri();
} else if (identityProviderPOSTRequest.getCertificate() != null && identityProviderPOSTRequest.getCertificate().getCertificates() != null) {
List<String> certificates = new ArrayList<>();
for (int certificateNo = 0; certificateNo < identityProviderPOSTRequest.getCertificate().getCertificates().size(); certificateNo++) {
if (identityProviderPOSTRequest.getCertificate().getCertificates().get(certificateNo).startsWith(IdentityUtil.PEM_BEGIN_CERTFICATE)) {
certificates.add(identityProviderPOSTRequest.getCertificate().getCertificates().get(certificateNo));
} else {
try {
certificates.add(base64Decode(identityProviderPOSTRequest.getCertificate().getCertificates().get(certificateNo)));
} catch (IllegalArgumentException e) {
throw handleException(Response.Status.BAD_REQUEST, Constants.ErrorMessage.ERROR_CODE_INVALID_CERTIFICATE_FORMAT, null);
}
}
}
idp.setCertificate(base64Encode(StringUtils.join(certificates, "")));
}
idp.setFederationHub(identityProviderPOSTRequest.getIsFederationHub());
updateFederatedAuthenticatorConfig(idp, identityProviderPOSTRequest.getFederatedAuthenticators());
if (identityProviderPOSTRequest.getProvisioning() != null) {
updateOutboundConnectorConfig(idp, identityProviderPOSTRequest.getProvisioning().getOutboundConnectors());
updateJIT(idp, identityProviderPOSTRequest.getProvisioning().getJit());
}
updateClaims(idp, identityProviderPOSTRequest.getClaims());
updateRoles(idp, identityProviderPOSTRequest.getRoles());
List<IdentityProviderProperty> idpProperties = new ArrayList<>();
if (StringUtils.isNotBlank(idpJWKSUri)) {
IdentityProviderProperty jwksProperty = new IdentityProviderProperty();
jwksProperty.setName(Constants.JWKS_URI);
jwksProperty.setValue(idpJWKSUri);
idpProperties.add(jwksProperty);
}
if (StringUtils.isNotEmpty(identityProviderPOSTRequest.getIdpIssuerName())) {
IdentityProviderProperty idpIssuerProperty = new IdentityProviderProperty();
idpIssuerProperty.setName(Constants.IDP_ISSUER_NAME);
idpIssuerProperty.setValue(identityProviderPOSTRequest.getIdpIssuerName());
idpProperties.add(idpIssuerProperty);
}
idp.setIdpProperties(idpProperties.toArray(new IdentityProviderProperty[0]));
return idp;
}
use of org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProviderProperty in project identity-api-server by wso2.
the class ServerConfigManagementService method updateIdPProperty.
private void updateIdPProperty(IdentityProvider identityProvider, String key, String value) {
List<IdentityProviderProperty> idPProperties = new ArrayList<>(Arrays.asList(identityProvider.getIdpProperties()));
if (StringUtils.isBlank(value) || !StringUtils.isNumeric(value) || Integer.parseInt(value) <= 0) {
String message = "Value should be numeric and positive";
throw handleException(Response.Status.BAD_REQUEST, Constants.ErrorMessage.ERROR_CODE_INVALID_INPUT, message);
}
boolean isPropertyFound = false;
if (CollectionUtils.isNotEmpty(idPProperties)) {
for (IdentityProviderProperty property : idPProperties) {
if (StringUtils.equals(key, property.getName())) {
isPropertyFound = true;
property.setValue(value);
}
}
}
if (!isPropertyFound) {
IdentityProviderProperty property = new IdentityProviderProperty();
property.setName(key);
property.setDisplayName(key);
property.setValue(value);
idPProperties.add(property);
}
identityProvider.setIdpProperties(idPProperties.toArray(new IdentityProviderProperty[0]));
}
use of org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProviderProperty in project identity-api-server by wso2.
the class ServerConfigManagementService method getConfigs.
/**
* Get Server Configs.
*
* @return ServerConfig.
*/
public ServerConfig getConfigs() {
IdentityProvider residentIdP = getResidentIdP();
UserRealm userRealm = CarbonContext.getThreadLocalCarbonContext().getUserRealm();
RealmConfig realmConfig = new RealmConfig();
try {
if (userRealm != null && userRealm.getRealmConfiguration() != null) {
realmConfig.adminUser(userRealm.getRealmConfiguration().getAdminUserName());
realmConfig.adminRole(userRealm.getRealmConfiguration().getAdminRoleName());
realmConfig.everyoneRole(userRealm.getRealmConfiguration().getEveryOneRoleName());
}
} catch (UserStoreException e) {
log.error("Error while retrieving user-realm information.", e);
throw handleException(Response.Status.INTERNAL_SERVER_ERROR, Constants.ErrorMessage.ERROR_CODE_ERROR_RETRIEVING_CONFIGS, null);
}
String idleSessionTimeout = null;
IdentityProviderProperty idleSessionProp = IdentityApplicationManagementUtil.getProperty(residentIdP.getIdpProperties(), IdentityApplicationConstants.SESSION_IDLE_TIME_OUT);
if (idleSessionProp != null) {
idleSessionTimeout = idleSessionProp.getValue();
}
String rememberMePeriod = null;
IdentityProviderProperty rememberMeProp = IdentityApplicationManagementUtil.getProperty(residentIdP.getIdpProperties(), IdentityApplicationConstants.REMEMBER_ME_TIME_OUT);
if (rememberMeProp != null) {
rememberMePeriod = rememberMeProp.getValue();
}
String homeRealmIdStr = residentIdP.getHomeRealmId();
List<String> homeRealmIdentifiers = null;
if (StringUtils.isNotBlank(homeRealmIdStr)) {
homeRealmIdentifiers = Arrays.stream(homeRealmIdStr.trim().split("\\s*,\\s*")).collect(Collectors.toList());
}
ServerConfig serverConfig = new ServerConfig();
serverConfig.setRealmConfig(realmConfig);
serverConfig.setIdleSessionTimeoutPeriod(idleSessionTimeout);
serverConfig.setRememberMePeriod(rememberMePeriod);
serverConfig.setHomeRealmIdentifiers(homeRealmIdentifiers);
serverConfig.setProvisioning(buildProvisioningConfig());
serverConfig.setAuthenticators(getAuthenticators(null));
serverConfig.setCors(getCORSConfiguration());
return serverConfig;
}
use of org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProviderProperty in project carbon-apimgt by wso2.
the class APIAdminImpl method createIdp.
private IdentityProvider createIdp(KeyManagerConfigurationDTO keyManagerConfigurationDTO) {
IdentityProvider identityProvider = new IdentityProvider();
String idpName = sanitizeName(getSubstringOfTen(keyManagerConfigurationDTO.getName()) + "_" + keyManagerConfigurationDTO.getOrganization() + "_" + keyManagerConfigurationDTO.getUuid());
identityProvider.setIdentityProviderName(idpName);
identityProvider.setDisplayName(keyManagerConfigurationDTO.getDisplayName());
identityProvider.setPrimary(Boolean.FALSE);
identityProvider.setIdentityProviderDescription(keyManagerConfigurationDTO.getDescription());
identityProvider.setAlias(keyManagerConfigurationDTO.getAlias());
String certificate = null;
if (keyManagerConfigurationDTO.getAdditionalProperties().containsKey(APIConstants.KeyManager.CERTIFICATE_VALUE)) {
certificate = (String) keyManagerConfigurationDTO.getAdditionalProperties().get(APIConstants.KeyManager.CERTIFICATE_VALUE);
}
String certificateType = null;
if (keyManagerConfigurationDTO.getAdditionalProperties().containsKey(APIConstants.KeyManager.CERTIFICATE_TYPE)) {
certificateType = (String) keyManagerConfigurationDTO.getAdditionalProperties().get(APIConstants.KeyManager.CERTIFICATE_TYPE);
}
List<IdentityProviderProperty> idpProperties = new ArrayList<>();
if (StringUtils.isNotEmpty(certificate) && StringUtils.isNotEmpty(certificateType)) {
if (APIConstants.KeyManager.CERTIFICATE_TYPE_JWKS_ENDPOINT.equals(certificateType)) {
if (StringUtils.isNotBlank(certificate)) {
IdentityProviderProperty jwksProperty = new IdentityProviderProperty();
jwksProperty.setName(APIConstants.JWKS_URI);
jwksProperty.setValue(certificate);
idpProperties.add(jwksProperty);
}
} else if (APIConstants.KeyManager.CERTIFICATE_TYPE_PEM_FILE.equals(certificateType)) {
identityProvider.setCertificate(String.join(certificate, ""));
}
}
if (keyManagerConfigurationDTO.getProperty(APIConstants.KeyManager.ISSUER) != null) {
IdentityProviderProperty identityProviderProperty = new IdentityProviderProperty();
identityProviderProperty.setName(IdentityApplicationConstants.IDP_ISSUER_NAME);
identityProviderProperty.setValue((String) keyManagerConfigurationDTO.getProperty(APIConstants.KeyManager.ISSUER));
idpProperties.add(identityProviderProperty);
}
if (idpProperties.size() > 0) {
identityProvider.setIdpProperties(idpProperties.toArray(new IdentityProviderProperty[0]));
}
identityProvider.setEnable(keyManagerConfigurationDTO.isEnabled());
Object claims = keyManagerConfigurationDTO.getProperty(APIConstants.KeyManager.CLAIM_MAPPING);
updateClaims(identityProvider, claims);
return identityProvider;
}
Aggregations