Java源码示例:org.wso2.carbon.identity.application.common.model.Property
示例1
/**
* Remove random passwords with original passwords when sending password properties to Service Back-end
* @param properties
*/
public Property[] removeRandomPasswords(Property[] properties, boolean withCacheClear) {
if (ArrayUtils.isEmpty(properties)) {
return new Property[0];
}
String uuid = IdentityApplicationManagementUtil.getPropertyValue(properties,
IdentityApplicationConstants.UNIQUE_ID_CONSTANT);
if (StringUtils.isBlank(uuid)) {
if (log.isDebugEnabled()) {
log.debug("Cache Key not found for Random Password Container");
}
} else {
properties = removeUniqueIdProperty(properties);
RandomPassword[] randomPasswords = getRandomPasswordContainerFromCache(uuid, withCacheClear);
if (!ArrayUtils.isEmpty(randomPasswords)) {
replaceRandomPasswordsWithOriginalPasswords(properties,
randomPasswords);
}
}
return properties;
}
示例2
/**
* Create internal federated authenticator config from external federated authenticator PUT request.
*
* @param federatedAuthenticatorId Federated authenticator ID.
* @param authenticator Internal federated authenticator config.
* @return Federated authenticator config of the specified ID.
*/
private FederatedAuthenticatorConfig createFederatedAuthenticatorConfig(String federatedAuthenticatorId,
FederatedAuthenticatorPUTRequest
authenticator) {
FederatedAuthenticatorConfig authConfig = new FederatedAuthenticatorConfig();
String authenticatorName = base64URLDecode(federatedAuthenticatorId);
authConfig.setName(authenticatorName);
authConfig.setDisplayName(getDisplayNameOfAuthenticator(authenticatorName));
authConfig.setEnabled(authenticator.getIsEnabled());
List<org.wso2.carbon.identity.api.server.idp.v1.model.Property> authProperties = authenticator.getProperties();
if (IdentityApplicationConstants.Authenticator.SAML2SSO.FED_AUTH_NAME.equals(authenticatorName)) {
validateSamlMetadata(authProperties);
}
List<Property> properties = authProperties.stream().map(propertyToInternal).collect(Collectors.toList());
authConfig.setProperties(properties.toArray(new Property[0]));
return authConfig;
}
示例3
private ConnectorRes buildConnectorResDTO(ConnectorConfig connectorConfig) {
ConnectorRes connectorsResDTO = new ConnectorRes();
connectorsResDTO.setId(Base64.getUrlEncoder()
.withoutPadding()
.encodeToString(connectorConfig.getName().getBytes(StandardCharsets.UTF_8)));
connectorsResDTO.setName(connectorConfig.getName());
connectorsResDTO.setFriendlyName(connectorConfig.getFriendlyName());
connectorsResDTO.setCategory(connectorConfig.getCategory());
connectorsResDTO.setSubCategory(connectorConfig.getSubCategory());
connectorsResDTO.setOrder(connectorConfig.getOrder());
List<PropertyRes> properties = new ArrayList<>();
for (Property property : connectorConfig.getProperties()) {
PropertyRes propertyRes = new PropertyRes();
propertyRes.setName(property.getName());
propertyRes.setValue(property.getValue());
propertyRes.setDisplayName(property.getDisplayName());
propertyRes.setDescription(property.getDescription() != null ? property.getDescription() : "");
properties.add(propertyRes);
}
connectorsResDTO.setProperties(properties);
return connectorsResDTO;
}
示例4
public static Property getProperty(Property[] properties, String propertyName) {
if (ArrayUtils.isEmpty(properties) || StringUtils.isBlank(propertyName)) {
return null;
}
for (Property property : properties) {
if (property == null) {
continue;
}
if (propertyName.equals(property.getName())) {
return property;
}
}
return null;
}
示例5
private Property[] addUniqueIdProperty(Property [] properties) {
if (ArrayUtils.isEmpty(properties)){
return new Property[0];
}
String uuid = UUID.randomUUID().toString();
Property uniqueIdProperty = new Property();
uniqueIdProperty.setName(IdentityApplicationConstants.UNIQUE_ID_CONSTANT);
uniqueIdProperty.setValue(uuid);
if (log.isDebugEnabled()){
log.debug("Adding uniqueId property: " + uuid);
}
properties = (Property[]) ArrayUtils.add(properties, uniqueIdProperty);
return properties;
}
示例6
/**
* @param externalIdPConfig
* @param name
* @return
*/
public static Map<String, String> getAuthenticatorPropertyMapFromIdP(
ExternalIdPConfig externalIdPConfig, String name) {
Map<String, String> propertyMap = new HashMap<String, String>();
if (externalIdPConfig != null) {
FederatedAuthenticatorConfig[] authenticatorConfigs = externalIdPConfig
.getIdentityProvider().getFederatedAuthenticatorConfigs();
for (FederatedAuthenticatorConfig authenticatorConfig : authenticatorConfigs) {
if (authenticatorConfig.getName().equals(name)) {
for (Property property : authenticatorConfig.getProperties()) {
propertyMap.put(property.getName(), property.getValue());
}
break;
}
}
}
return propertyMap;
}
示例7
/**
* Get the configurations of a tenant from cache or database
*
* @param tenantDomain Domain name of the tenant
* @return Configurations belong to the tenant
*/
private static Property[] getResidentIdpConfiguration(String tenantDomain) throws FrameworkException {
IdpManager identityProviderManager = IdentityProviderManager.getInstance();
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 FrameworkException(errorMsg, e);
}
IdentityProviderProperty[] identityMgtProperties = residentIdp.getIdpProperties();
Property[] configMap = new Property[identityMgtProperties.length];
int index = 0;
for (IdentityProviderProperty identityMgtProperty : identityMgtProperties) {
if (ALREADY_WRITTEN_PROPERTY.equals(identityMgtProperty.getName())) {
continue;
}
Property property = new Property();
property.setName(identityMgtProperty.getName());
property.setValue(identityMgtProperty.getValue());
configMap[index] = property;
index++;
}
return configMap;
}
示例8
/**
* This method is used to get the requested resident Idp configuration details.
*
* @param propertyName
* @param tenantDomain
* @return Property
* @throws FrameworkException
*/
public static Property getResidentIdpConfiguration(String propertyName, String tenantDomain) throws
FrameworkException {
Property requestedProperty = null;
Property[] allProperties = getResidentIdpConfiguration(tenantDomain);
for (int i = 0; i < allProperties.length; i++) {
if (propertyName.equals(allProperties[i].getName())) {
requestedProperty = allProperties[i];
break;
}
}
return requestedProperty;
}
示例9
@Override
/**
*
*/
public void init(Property[] provisioningProperties) throws IdentityProvisioningException {
Properties configs = new Properties();
if (provisioningProperties != null && provisioningProperties.length > 0) {
for (Property property : provisioningProperties) {
configs.put(property.getName(), property.getValue());
if (IdentityProvisioningConstants.JIT_PROVISIONING_ENABLED.equals(property
.getName()) && "1".equals(property.getValue())) {
jitProvisioningEnabled = true;
}
}
}
configHolder = new SalesforceProvisioningConnectorConfig(configs);
}
示例10
/**
* Use this method to replace random passwords with original passwords when original passwords are required
* @param identityProvider
* @param withCacheClear
*/
public static void removeRandomPasswords(IdentityProvider identityProvider, boolean withCacheClear) {
if (identityProvider == null || identityProvider.getProvisioningConnectorConfigs() == null) {
return;
}
for (ProvisioningConnectorConfig provisioningConnectorConfig : identityProvider
.getProvisioningConnectorConfigs()) {
Property[] properties = provisioningConnectorConfig.getProvisioningProperties();
if (ArrayUtils.isEmpty(properties)) {
continue;
}
properties = RandomPasswordProcessor.getInstance().removeRandomPasswords(properties, withCacheClear);
provisioningConnectorConfig.setProvisioningProperties(properties);
}
}
示例11
private void validateLocalAuthenticatorConfig(List<String> validationMsg,
Map<String, Property[]> allLocalAuthenticators,
AtomicBoolean isAuthenticatorIncluded,
AuthenticationStep authenticationStep) {
for (LocalAuthenticatorConfig localAuth : authenticationStep.getLocalAuthenticatorConfigs()) {
if (!allLocalAuthenticators.keySet().contains(localAuth.getName())) {
validationMsg.add(String.format(AUTHENTICATOR_NOT_AVAILABLE, localAuth.getName()));
} else if (!isAuthenticatorIncluded.get()) {
Property[] properties = allLocalAuthenticators.get(localAuth.getName());
if (properties.length == 0) {
isAuthenticatorIncluded.set(true);
} else {
for (Property property : properties) {
if (!(IS_HANDLER.equals(property.getName()) && Boolean.valueOf(property.getValue()))) {
isAuthenticatorIncluded.set(true);
}
}
}
}
}
}
示例12
/**
* Validate request path authenticator related configurations and append to the validation msg list.
*
* @param validationMsg validation error messages
* @param requestPathAuthenticatorConfigs request path authentication config
* @param tenantDomain tenant domain
* @throws IdentityApplicationManagementException Identity Application Management Exception when unable to get the
* authenticator params
*/
private void validateRequestPathAuthenticationConfig(List<String> validationMsg,
RequestPathAuthenticatorConfig[] requestPathAuthenticatorConfigs,
String tenantDomain)
throws IdentityApplicationManagementException {
ApplicationManagementService applicationMgtService = ApplicationManagementService.getInstance();
Map<String, Property[]> allRequestPathAuthenticators = Arrays.stream(applicationMgtService
.getAllRequestPathAuthenticators(tenantDomain))
.collect(Collectors.toMap(RequestPathAuthenticatorConfig::getName,
RequestPathAuthenticatorConfig::getProperties));
if (requestPathAuthenticatorConfigs != null) {
for (RequestPathAuthenticatorConfig config : requestPathAuthenticatorConfigs) {
if (!allRequestPathAuthenticators.containsKey(config.getName())) {
validationMsg.add(String.format(AUTHENTICATOR_NOT_AVAILABLE, config.getName()));
}
}
}
}
示例13
/**
* Get Configuration Properties
*
* @return
*/
@Override
public List<Property> getConfigurationProperties() {
List<Property> configProperties = new ArrayList<Property>();
Property oauthEndpoint = new Property();
oauthEndpoint.setDisplayName("Yahoo Authentication Endpoint");
oauthEndpoint.setName(YahooOpenIDAuthenticatorConstants.YAHOO_AUTHZ_URL);
oauthEndpoint.setValue(IdentityApplicationConstants.YAHOO_AUTHZ_URL);
oauthEndpoint.setDescription("Enter value corresponding to yahoo oauth endpoint.");
oauthEndpoint.setDisplayOrder(1);
configProperties.add(oauthEndpoint);
return configProperties;
}
示例14
/**
* Remove random passwords with original passwords when sending password properties to Service Back-end
*
* @param properties
*/
public Property[] removeRandomPasswords(Property[] properties, boolean withCacheClear) {
if (ArrayUtils.isEmpty(properties)) {
return new Property[0];
}
String uuid = IdentityApplicationManagementUtil.getPropertyValue(properties,
IdentityApplicationConstants.UNIQUE_ID_CONSTANT);
if (StringUtils.isBlank(uuid)) {
if (log.isDebugEnabled()) {
log.debug("Cache Key not found for Random Password Container");
}
} else {
properties = removeUniqueIdProperty(properties);
RandomPassword[] randomPasswords = getRandomPasswordContainerFromCache(uuid, withCacheClear);
if (!ArrayUtils.isEmpty(randomPasswords)) {
replaceRandomPasswordsWithOriginalPasswords(properties,
randomPasswords);
}
}
return properties;
}
示例15
private Property[] addUniqueIdProperty(Property[] properties) {
if (ArrayUtils.isEmpty(properties)) {
return new Property[0];
}
String uuid = UUID.randomUUID().toString();
Property uniqueIdProperty = new Property();
uniqueIdProperty.setName(IdentityApplicationConstants.UNIQUE_ID_CONSTANT);
uniqueIdProperty.setValue(uuid);
if (log.isDebugEnabled()) {
log.debug("Adding uniqueId property: " + uuid);
}
properties = (Property[]) ArrayUtils.add(properties, uniqueIdProperty);
return properties;
}
示例16
private Property[] removeUniqueIdProperty(Property[] properties) {
if (ArrayUtils.isEmpty(properties)) {
return new Property[0];
}
for (int i = 0; i < properties.length; i++) {
if (properties[i] == null) {
continue;
}
if (IdentityApplicationConstants.UNIQUE_ID_CONSTANT.equals(properties[i].getName())) {
Property[] propertiesTemp = properties;
if (log.isDebugEnabled()) {
log.debug("Removing uniqueId property: " + properties[i].getName());
}
properties = (Property[]) ArrayUtils.removeElement(properties, properties[i]);
//Removing uniqueId property from existing properties too
propertiesTemp[i] = null;
}
}
return properties;
}
示例17
public static Property getProperty(Property[] properties, String propertyName) {
if (ArrayUtils.isEmpty(properties) || StringUtils.isBlank(propertyName)) {
return null;
}
for (Property property : properties) {
if (property == null) {
continue;
}
if (propertyName.equals(property.getName())) {
return property;
}
}
return null;
}
示例18
/**
* This is used in back end. Property is the type of stub generated property
*
* @param authnConfigs authenticatorConfigs to iterate
* @param authenticatorName authenticator name of which the values are needed
* @param propNameStartsWith the prefix of the property name
* @return the list of values which statrts with the propNameStartsWith.
*/
public static List<String> getPropertyValuesForNameStartsWith(FederatedAuthenticatorConfig[] authnConfigs, String
authenticatorName, String propNameStartsWith) {
List<String> propValueSet = new ArrayList<String>();
for (FederatedAuthenticatorConfig config : authnConfigs) {
if (authenticatorName.equals(config.getName())) {
for (Property prop : config.getProperties()) {
if (prop.getName().startsWith(propNameStartsWith)) {
propValueSet.add(prop.getValue());
}
}
}
}
return propValueSet;
}
示例19
/**
* This is used in back end. Property is the type of stub generated property
*
* @param authnConfigs authenticatorConfigs to iterate
* @param authenticatorName authenticator name of which the values are needed
* @param propNameStartsWith the prefix of the property name
* @return the list of values which statrts with the propNameStartsWith.
*/
public static List<String> getPropertyValuesForNameStartsWith(FederatedAuthenticatorConfig[] authnConfigs, String
authenticatorName, String propNameStartsWith) {
List<String> propValueSet = new ArrayList<>();
for (FederatedAuthenticatorConfig config : authnConfigs) {
if (authenticatorName.equals(config.getName())) {
for (Property prop : config.getProperties()) {
if (prop.getName().startsWith(propNameStartsWith)) {
propValueSet.add(prop.getValue());
}
}
}
}
return propValueSet;
}
示例20
/**
* Remove original passwords with random passwords when sending password properties to UI front-end
* @param properties
*/
public Property[] removeOriginalPasswords(Property[] properties){
if (ArrayUtils.isEmpty(properties)){
return new Property[0];
}
properties = addUniqueIdProperty(properties);
String uuid = IdentityApplicationManagementUtil
.getPropertyValue(properties, IdentityApplicationConstants.UNIQUE_ID_CONSTANT);
String randomPhrase = IdentityApplicationConstants.RANDOM_PHRASE_PREFIX + uuid;
RandomPassword[] randomPasswords = replaceOriginalPasswordsWithRandomPasswords(
randomPhrase, properties);
if (!ArrayUtils.isEmpty(randomPasswords)) {
addPasswordContainerToCache(randomPasswords, uuid);
}
return properties;
}
示例21
private void addSSOUrlAsDestinationUrl(FederatedAuthenticatorConfig federatedAuthenticatorConfig,
String ssoUrl,
List<Property> propertiesList) {
// First find the available configured destination URLs.
List<Property> destinationURLs = Arrays.stream(federatedAuthenticatorConfig.getProperties())
.filter(property -> property.getName()
.startsWith(IdentityApplicationConstants.Authenticator.SAML2SSO.DESTINATION_URL_PREFIX))
.collect(Collectors.toList());
// Check whether the SSO URL is already available as a destination URL
boolean isSAMLSSOUrlNotPresentAsDestination = destinationURLs.stream()
.noneMatch(x -> StringUtils.equals(ssoUrl, x.getValue()));
if (isSAMLSSOUrlNotPresentAsDestination) {
// There are no destination properties matching the default SSO URL.
int propertyNameIndex = destinationURLs.size() + 1;
Property destinationURLProperty = buildDestinationURLProperty(ssoUrl, propertyNameIndex);
propertiesList.add(destinationURLProperty);
}
}
示例22
public IdentityProvider getIdPByAuthenticatorPropertyValue(String property, String value, String tenantDomain,
String authenticatorName) {
Map<String, IdentityProvider> identityProviders = IdPManagementServiceComponent.getFileBasedIdPs();
for (Entry<String, IdentityProvider> entry : identityProviders.entrySet()) {
FederatedAuthenticatorConfig[] federatedAuthenticatorConfigs = entry.getValue().
getFederatedAuthenticatorConfigs();
// Get SAML2 Web SSO authenticator
FederatedAuthenticatorConfig samlAuthenticatorConfig = IdentityApplicationManagementUtil.
getFederatedAuthenticator(federatedAuthenticatorConfigs, authenticatorName);
if (samlAuthenticatorConfig != null) {
Property samlProperty = IdentityApplicationManagementUtil.getProperty(samlAuthenticatorConfig.
getProperties(), property);
if (samlProperty != null) {
if (value.equalsIgnoreCase(samlProperty.getValue())) {
return entry.getValue();
}
}
}
}
return null;
}
示例23
/**
* Use this method to replace original passwords with random passwords before sending to UI front-end
* @param identityProvider
* @return
*/
public static void removeOriginalPasswords(IdentityProvider identityProvider) {
if (identityProvider == null || identityProvider.getProvisioningConnectorConfigs() == null) {
return;
}
for (ProvisioningConnectorConfig provisioningConnectorConfig : identityProvider
.getProvisioningConnectorConfigs()) {
Property[] properties = provisioningConnectorConfig.getProvisioningProperties();
if (ArrayUtils.isEmpty(properties)) {
continue;
}
properties = RandomPasswordProcessor.getInstance().removeOriginalPasswords(properties);
provisioningConnectorConfig.setProvisioningProperties(properties);
}
}
示例24
/**
* Use this method to replace random passwords with original passwords when original passwords are required
* @param identityProvider
* @param withCacheClear
*/
public static void removeRandomPasswords(IdentityProvider identityProvider, boolean withCacheClear) {
if (identityProvider == null || identityProvider.getProvisioningConnectorConfigs() == null) {
return;
}
for (ProvisioningConnectorConfig provisioningConnectorConfig : identityProvider
.getProvisioningConnectorConfigs()) {
Property[] properties = provisioningConnectorConfig.getProvisioningProperties();
if (ArrayUtils.isEmpty(properties)) {
continue;
}
properties = RandomPasswordProcessor.getInstance().removeRandomPasswords(properties, withCacheClear);
provisioningConnectorConfig.setProvisioningProperties(properties);
}
}
示例25
/**
* @param externalIdPConfig
* @param name
* @return
*/
public static Map<String, String> getAuthenticatorPropertyMapFromIdP(
ExternalIdPConfig externalIdPConfig, String name) {
Map<String, String> propertyMap = new HashMap<String, String>();
if (externalIdPConfig != null) {
FederatedAuthenticatorConfig[] authenticatorConfigs = externalIdPConfig
.getIdentityProvider().getFederatedAuthenticatorConfigs();
for (FederatedAuthenticatorConfig authenticatorConfig : authenticatorConfigs) {
if (authenticatorConfig.getName().equals(name)) {
for (Property property : authenticatorConfig.getProperties()) {
propertyMap.put(property.getName(), property.getValue());
}
break;
}
}
}
return propertyMap;
}
示例26
private MetaFederatedAuthenticator createMetaFederatedAuthenticator(FederatedAuthenticatorConfig
authenticatorConfig) {
MetaFederatedAuthenticator metaFederatedAuthenticator = new MetaFederatedAuthenticator();
metaFederatedAuthenticator.setName(authenticatorConfig.getName());
metaFederatedAuthenticator.setAuthenticatorId(base64URLEncode(authenticatorConfig.getName()));
metaFederatedAuthenticator.setDisplayName(authenticatorConfig.getDisplayName());
Property[] properties = authenticatorConfig.getProperties();
List<MetaProperty> metaProperties = Arrays.stream(properties).map(propertyToExternalMeta).collect(Collectors
.toList());
metaFederatedAuthenticator.setProperties(metaProperties);
return metaFederatedAuthenticator;
}
示例27
@Override
public void init(Property[] provisioningProperties) throws IdentityProvisioningException {
scimProvider = new SCIMProvider();
if (provisioningProperties != null && provisioningProperties.length > 0) {
for (Property property : provisioningProperties) {
if (SCIMProvisioningConnectorConstants.SCIM_USER_EP.equals(property.getName())) {
populateSCIMProvider(property, SCIMConfigConstants.ELEMENT_NAME_USER_ENDPOINT);
} else if (SCIMProvisioningConnectorConstants.SCIM_GROUP_EP.equals(property.getName())) {
populateSCIMProvider(property, SCIMConfigConstants.ELEMENT_NAME_GROUP_ENDPOINT);
} else if (SCIMProvisioningConnectorConstants.SCIM_USERNAME.equals(property.getName())) {
populateSCIMProvider(property, SCIMConfigConstants.ELEMENT_NAME_USERNAME);
} else if (SCIMProvisioningConnectorConstants.SCIM_PASSWORD.equals(property.getName())) {
populateSCIMProvider(property, SCIMConfigConstants.ELEMENT_NAME_PASSWORD);
} else if (SCIMProvisioningConnectorConstants.SCIM_USERSTORE_DOMAIN.equals(property.getName())) {
userStoreDomainName = property.getValue() != null ? property.getValue()
: property.getDefaultValue();
}else if (SCIMProvisioningConnectorConstants.SCIM_ENABLE_PASSWORD_PROVISIONING.equals(property.getName())){
populateSCIMProvider(property, SCIMProvisioningConnectorConstants.SCIM_ENABLE_PASSWORD_PROVISIONING);
}else if (SCIMProvisioningConnectorConstants.SCIM_DEFAULT_PASSWORD.equals(property.getName())){
populateSCIMProvider(property, SCIMProvisioningConnectorConstants.SCIM_DEFAULT_PASSWORD);
}
if (IdentityProvisioningConstants.JIT_PROVISIONING_ENABLED.equals(property
.getName()) && "1".equals(property.getValue())) {
jitProvisioningEnabled = true;
}
}
}
}
示例28
private void updateFederatedAuthenticatorConfig(IdentityProvider idp, FederatedAuthenticatorRequest
federatedAuthenticatorRequest) {
if (federatedAuthenticatorRequest != null) {
List<FederatedAuthenticator> federatedAuthenticators = federatedAuthenticatorRequest.getAuthenticators();
String defaultAuthenticator = federatedAuthenticatorRequest.getDefaultAuthenticatorId();
FederatedAuthenticatorConfig defaultAuthConfig = null;
List<FederatedAuthenticatorConfig> fedAuthConfigs = new ArrayList<>();
for (FederatedAuthenticator authenticator : federatedAuthenticators) {
FederatedAuthenticatorConfig authConfig = new FederatedAuthenticatorConfig();
authConfig.setName(base64URLDecode(authenticator.getAuthenticatorId()));
authConfig.setDisplayName(getDisplayNameOfAuthenticator(authConfig.getName()));
authConfig.setEnabled(authenticator.getIsEnabled());
List<org.wso2.carbon.identity.api.server.idp.v1.model.Property> authProperties =
authenticator.getProperties();
if (IdentityApplicationConstants.Authenticator.SAML2SSO.FED_AUTH_NAME.equals(authConfig.getName())) {
validateSamlMetadata(authProperties);
}
if (authProperties != null) {
List<Property> properties = authProperties.stream()
.map(propertyToInternal)
.collect(Collectors.toList());
authConfig.setProperties(properties.toArray(new Property[0]));
}
fedAuthConfigs.add(authConfig);
if (StringUtils.equals(defaultAuthenticator, authenticator.getAuthenticatorId())) {
defaultAuthConfig = authConfig;
}
}
if (StringUtils.isNotBlank(defaultAuthenticator) && defaultAuthConfig == null) {
throw handleException(Response.Status.BAD_REQUEST,
Constants.ErrorMessage.ERROR_CODE_INVALID_DEFAULT_AUTHENTICATOR, null);
}
idp.setFederatedAuthenticatorConfigs(fedAuthConfigs.toArray(new FederatedAuthenticatorConfig[0]));
idp.setDefaultAuthenticatorConfig(defaultAuthConfig);
}
}
示例29
/**
* @param o1
* @param o2
* @return
*/
public static Property[] concatArrays(Property[] o1, Property[] o2) {
Set<Property> properties = new HashSet<Property>(Arrays.asList(o1));
properties.addAll(Arrays.asList(o2));
return properties.toArray(new Property[properties.size()]);
}
示例30
/**
* Create API Federated Authenticator model using internal FederatedAuthenticatorConfig.
*
* @param authenticatorId Federated Authenticator ID.
* @param identityProvider Identity Provider information.
* @return FederatedAuthenticator.
*/
private FederatedAuthenticator createFederatedAuthenticator(String authenticatorId,
IdentityProvider identityProvider) {
FederatedAuthenticatorConfig[] authConfigs = identityProvider.getFederatedAuthenticatorConfigs();
if (ArrayUtils.isEmpty(authConfigs)) {
return null;
}
FederatedAuthenticatorConfig config = null;
boolean isDefaultAuthenticator = false;
String authenticatorName = base64URLDecode(authenticatorId);
for (FederatedAuthenticatorConfig authConfig : authConfigs) {
if (StringUtils.equals(authConfig.getName(), authenticatorName)) {
config = authConfig;
}
}
if (identityProvider.getDefaultAuthenticatorConfig() != null && StringUtils.equals(identityProvider
.getDefaultAuthenticatorConfig().getName(), authenticatorName)) {
isDefaultAuthenticator = true;
}
FederatedAuthenticator federatedAuthenticator = new FederatedAuthenticator();
if (config != null) {
federatedAuthenticator.setAuthenticatorId(authenticatorId);
federatedAuthenticator.setName(config.getName());
federatedAuthenticator.setIsEnabled(config.isEnabled());
federatedAuthenticator.setIsDefault(isDefaultAuthenticator);
List<org.wso2.carbon.identity.api.server.idp.v1.model.Property> properties =
Arrays.stream(config.getProperties()).map(propertyToExternal).collect(Collectors.toList());
federatedAuthenticator.setProperties(properties);
}
return federatedAuthenticator;
}