use of org.wso2.carbon.identity.application.common.model.OutboundProvisioningConfig in project product-is by wso2.
the class OAuth2RoleClaimTestCase method createApplication.
public OAuthConsumerAppDTO createApplication(OAuthConsumerAppDTO appDTO) throws Exception {
OAuthConsumerAppDTO appDtoResult = null;
adminClient.registerOAuthApplicationData(appDTO);
OAuthConsumerAppDTO[] appDtos = adminClient.getAllOAuthApplicationData();
for (OAuthConsumerAppDTO appDto : appDtos) {
if (appDto.getApplicationName().equals(OAuth2Constant.OAUTH_APPLICATION_NAME)) {
appDtoResult = appDto;
consumerKey = appDto.getOauthConsumerKey();
consumerSecret = appDto.getOauthConsumerSecret();
}
}
ServiceProvider serviceProvider = new ServiceProvider();
serviceProvider.setApplicationName(SERVICE_PROVIDER_NAME);
serviceProvider.setDescription(SERVICE_PROVIDER_DESC);
appMgtclient.createApplication(serviceProvider);
serviceProvider = appMgtclient.getApplication(SERVICE_PROVIDER_NAME);
ClaimConfig claimConfig = new ClaimConfig();
Claim emailClaim = new Claim();
emailClaim.setClaimUri(EMAIL_CLAIM_URI);
ClaimMapping emailClaimMapping = new ClaimMapping();
emailClaimMapping.setRequested(true);
emailClaimMapping.setLocalClaim(emailClaim);
emailClaimMapping.setRemoteClaim(emailClaim);
Claim roleClaim = new Claim();
roleClaim.setClaimUri(ROLES_CLAIM_URI);
ClaimMapping roleClaimMapping = new ClaimMapping();
roleClaimMapping.setRequested(true);
roleClaimMapping.setLocalClaim(roleClaim);
roleClaimMapping.setRemoteClaim(roleClaim);
claimConfig.setClaimMappings(new org.wso2.carbon.identity.application.common.model.xsd.ClaimMapping[] { emailClaimMapping, roleClaimMapping });
serviceProvider.setClaimConfig(claimConfig);
serviceProvider.setOutboundProvisioningConfig(new OutboundProvisioningConfig());
List<InboundAuthenticationRequestConfig> authRequestList = new ArrayList<InboundAuthenticationRequestConfig>();
if (consumerKey != null) {
InboundAuthenticationRequestConfig opicAuthenticationRequest = new InboundAuthenticationRequestConfig();
opicAuthenticationRequest.setInboundAuthKey(consumerKey);
opicAuthenticationRequest.setInboundAuthType("oauth2");
if (consumerSecret != null && !consumerSecret.isEmpty()) {
Property property = new Property();
property.setName("oauthConsumerSecret");
property.setValue(consumerSecret);
Property[] properties = { property };
opicAuthenticationRequest.setProperties(properties);
}
authRequestList.add(opicAuthenticationRequest);
}
String passiveSTSRealm = SERVICE_PROVIDER_NAME;
if (passiveSTSRealm != null) {
InboundAuthenticationRequestConfig opicAuthenticationRequest = new InboundAuthenticationRequestConfig();
opicAuthenticationRequest.setInboundAuthKey(passiveSTSRealm);
opicAuthenticationRequest.setInboundAuthType("passivests");
authRequestList.add(opicAuthenticationRequest);
}
String openidRealm = SERVICE_PROVIDER_NAME;
if (openidRealm != null) {
InboundAuthenticationRequestConfig opicAuthenticationRequest = new InboundAuthenticationRequestConfig();
opicAuthenticationRequest.setInboundAuthKey(openidRealm);
opicAuthenticationRequest.setInboundAuthType("openid");
authRequestList.add(opicAuthenticationRequest);
}
if (authRequestList.size() > 0) {
serviceProvider.getInboundAuthenticationConfig().setInboundAuthenticationRequestConfigs(authRequestList.toArray(new InboundAuthenticationRequestConfig[authRequestList.size()]));
}
appMgtclient.updateApplicationData(serviceProvider);
return appDtoResult;
}
use of org.wso2.carbon.identity.application.common.model.OutboundProvisioningConfig in project product-is by wso2.
the class OIDCAbstractIntegrationTest method createApplication.
public ServiceProvider createApplication(ServiceProvider serviceProvider, OIDCApplication application) throws Exception {
log.info("Creating application " + application.getApplicationName());
OAuthConsumerAppDTO appDTO = new OAuthConsumerAppDTO();
appDTO.setApplicationName(application.getApplicationName());
appDTO.setCallbackUrl(application.getCallBackURL());
appDTO.setOAuthVersion(OAuth2Constant.OAUTH_VERSION_2);
appDTO.setGrantTypes("authorization_code implicit password client_credentials refresh_token " + "urn:ietf:params:oauth:grant-type:saml2-bearer iwa:ntlm");
adminClient.registerOAuthApplicationData(appDTO);
OAuthConsumerAppDTO[] appDtos = adminClient.getAllOAuthApplicationData();
for (OAuthConsumerAppDTO appDto : appDtos) {
if (appDto.getApplicationName().equals(application.getApplicationName())) {
application.setClientId(appDto.getOauthConsumerKey());
application.setClientSecret(appDto.getOauthConsumerSecret());
}
}
serviceProvider.setApplicationName(application.getApplicationName());
serviceProvider.setDescription(application.getApplicationName());
appMgtclient.createApplication(serviceProvider);
serviceProvider = appMgtclient.getApplication(application.getApplicationName());
ClaimConfig claimConfig = null;
if (!application.getRequiredClaims().isEmpty()) {
claimConfig = new ClaimConfig();
for (String claimUri : application.getRequiredClaims()) {
Claim claim = new Claim();
claim.setClaimUri(claimUri);
ClaimMapping claimMapping = new ClaimMapping();
claimMapping.setRequested(true);
claimMapping.setLocalClaim(claim);
claimMapping.setRemoteClaim(claim);
claimConfig.addClaimMappings(claimMapping);
}
}
serviceProvider.setClaimConfig(claimConfig);
serviceProvider.setOutboundProvisioningConfig(new OutboundProvisioningConfig());
List<InboundAuthenticationRequestConfig> authRequestList = new ArrayList<>();
if (application.getClientId() != null) {
InboundAuthenticationRequestConfig inboundAuthenticationRequestConfig = new InboundAuthenticationRequestConfig();
inboundAuthenticationRequestConfig.setInboundAuthKey(application.getClientId());
inboundAuthenticationRequestConfig.setInboundAuthType(OAuth2Constant.OAUTH_2);
if (StringUtils.isNotBlank(application.getClientSecret())) {
Property property = new Property();
property.setName(OAuth2Constant.OAUTH_CONSUMER_SECRET);
property.setValue(application.getClientSecret());
Property[] properties = { property };
inboundAuthenticationRequestConfig.setProperties(properties);
}
authRequestList.add(inboundAuthenticationRequestConfig);
}
if (authRequestList.size() > 0) {
serviceProvider.getInboundAuthenticationConfig().setInboundAuthenticationRequestConfigs(authRequestList.toArray(new InboundAuthenticationRequestConfig[authRequestList.size()]));
}
updateApplication(serviceProvider);
return serviceProvider;
}
use of org.wso2.carbon.identity.application.common.model.OutboundProvisioningConfig in project product-is by wso2.
the class OIDCFederatedIdpInitLogoutTest method updateServiceProviderWithOIDCConfigs.
private void updateServiceProviderWithOIDCConfigs(int portOffset, String applicationName, String callbackUrl, String backChannelLogoutUrl, ServiceProvider serviceProvider) throws Exception {
OIDCApplication application = new OIDCApplication(applicationName, OAuth2Constant.TRAVELOCITY_APP_CONTEXT_ROOT, callbackUrl);
OAuthConsumerAppDTO appDTO = getOAuthConsumerAppDTO(application);
appDTO.setBackChannelLogoutUrl(backChannelLogoutUrl);
OAuthConsumerAppDTO[] appDtos = createOIDCConfiguration(portOffset, appDTO);
for (OAuthConsumerAppDTO appDto : appDtos) {
if (appDto.getApplicationName().equals(application.getApplicationName())) {
application.setClientId(appDto.getOauthConsumerKey());
application.setClientSecret(appDto.getOauthConsumerSecret());
}
}
ClaimConfig claimConfig = null;
if (!application.getRequiredClaims().isEmpty()) {
claimConfig = new ClaimConfig();
for (String claimUri : application.getRequiredClaims()) {
Claim claim = new Claim();
claim.setClaimUri(claimUri);
ClaimMapping claimMapping = new ClaimMapping();
claimMapping.setRequested(true);
claimMapping.setLocalClaim(claim);
claimMapping.setRemoteClaim(claim);
claimConfig.addClaimMappings(claimMapping);
}
}
serviceProvider.setClaimConfig(claimConfig);
serviceProvider.setOutboundProvisioningConfig(new OutboundProvisioningConfig());
List<InboundAuthenticationRequestConfig> authRequestList = new ArrayList<>();
if (application.getClientId() != null) {
InboundAuthenticationRequestConfig inboundAuthenticationRequestConfig = new InboundAuthenticationRequestConfig();
inboundAuthenticationRequestConfig.setInboundAuthKey(application.getClientId());
secondaryISClientID = application.getClientId();
inboundAuthenticationRequestConfig.setInboundAuthType(OAuth2Constant.OAUTH_2);
if (StringUtils.isNotBlank(application.getClientSecret())) {
org.wso2.carbon.identity.application.common.model.xsd.Property property = new org.wso2.carbon.identity.application.common.model.xsd.Property();
property.setName(OAuth2Constant.OAUTH_CONSUMER_SECRET);
property.setValue(application.getClientSecret());
secondaryISClientSecret = application.getClientSecret();
org.wso2.carbon.identity.application.common.model.xsd.Property[] properties = { property };
inboundAuthenticationRequestConfig.setProperties(properties);
}
serviceProvider.getInboundAuthenticationConfig().setInboundAuthenticationRequestConfigs(new InboundAuthenticationRequestConfig[] { inboundAuthenticationRequestConfig });
authRequestList.add(inboundAuthenticationRequestConfig);
}
super.updateServiceProvider(PORT_OFFSET_1, serviceProvider);
}
use of org.wso2.carbon.identity.application.common.model.OutboundProvisioningConfig in project product-is by wso2.
the class OIDCIdentityFederationTestCase method updateServiceProviderWithOIDCConfigs.
private void updateServiceProviderWithOIDCConfigs(int portOffset, String applicationName, String callbackUrl, ServiceProvider serviceProvider) throws Exception {
OIDCApplication application = new OIDCApplication(applicationName, OAuth2Constant.TRAVELOCITY_APP_CONTEXT_ROOT, callbackUrl);
OAuthConsumerAppDTO appDTO = getOAuthConsumerAppDTO(application);
OAuthConsumerAppDTO[] appDtos = createOIDCConfiguration(portOffset, appDTO);
for (OAuthConsumerAppDTO appDto : appDtos) {
if (appDto.getApplicationName().equals(application.getApplicationName())) {
application.setClientId(appDto.getOauthConsumerKey());
application.setClientSecret(appDto.getOauthConsumerSecret());
}
}
ClaimConfig claimConfig = null;
if (!application.getRequiredClaims().isEmpty()) {
claimConfig = new ClaimConfig();
for (String claimUri : application.getRequiredClaims()) {
Claim claim = new Claim();
claim.setClaimUri(claimUri);
ClaimMapping claimMapping = new ClaimMapping();
claimMapping.setRequested(true);
claimMapping.setLocalClaim(claim);
claimMapping.setRemoteClaim(claim);
claimConfig.addClaimMappings(claimMapping);
}
}
serviceProvider.setClaimConfig(claimConfig);
serviceProvider.setOutboundProvisioningConfig(new OutboundProvisioningConfig());
List<InboundAuthenticationRequestConfig> authRequestList = new ArrayList<>();
if (application.getClientId() != null) {
InboundAuthenticationRequestConfig inboundAuthenticationRequestConfig = new InboundAuthenticationRequestConfig();
inboundAuthenticationRequestConfig.setInboundAuthKey(application.getClientId());
secondaryISClientID = application.getClientId();
inboundAuthenticationRequestConfig.setInboundAuthType(OAuth2Constant.OAUTH_2);
if (StringUtils.isNotBlank(application.getClientSecret())) {
org.wso2.carbon.identity.application.common.model.xsd.Property property = new org.wso2.carbon.identity.application.common.model.xsd.Property();
property.setName(OAuth2Constant.OAUTH_CONSUMER_SECRET);
property.setValue(application.getClientSecret());
secondaryISClientSecret = application.getClientSecret();
org.wso2.carbon.identity.application.common.model.xsd.Property[] properties = { property };
inboundAuthenticationRequestConfig.setProperties(properties);
}
serviceProvider.getInboundAuthenticationConfig().setInboundAuthenticationRequestConfigs(new InboundAuthenticationRequestConfig[] { inboundAuthenticationRequestConfig });
authRequestList.add(inboundAuthenticationRequestConfig);
}
super.updateServiceProvider(PORT_OFFSET_1, serviceProvider);
}
use of org.wso2.carbon.identity.application.common.model.OutboundProvisioningConfig in project product-is by wso2.
the class OAuth2ServiceAbstractIntegrationTest method createApplication.
/**
* Create Application with a given appDTO
*
* @return OAuthConsumerAppDTO
* @throws Exception
*/
public OAuthConsumerAppDTO createApplication(OAuthConsumerAppDTO appDTO) throws Exception {
OAuthConsumerAppDTO appDtoResult = null;
adminClient.registerOAuthApplicationData(appDTO);
OAuthConsumerAppDTO[] appDtos = adminClient.getAllOAuthApplicationData();
for (OAuthConsumerAppDTO appDto : appDtos) {
if (appDto.getApplicationName().equals(OAuth2Constant.OAUTH_APPLICATION_NAME)) {
appDtoResult = appDto;
consumerKey = appDto.getOauthConsumerKey();
consumerSecret = appDto.getOauthConsumerSecret();
}
}
ServiceProvider serviceProvider = new ServiceProvider();
serviceProvider.setApplicationName(SERVICE_PROVIDER_NAME);
serviceProvider.setDescription(SERVICE_PROVIDER_DESC);
serviceProvider.setManagementApp(true);
appMgtclient.createApplication(serviceProvider);
serviceProvider = appMgtclient.getApplication(SERVICE_PROVIDER_NAME);
serviceProvider = setServiceProviderClaimConfig(serviceProvider);
serviceProvider.setOutboundProvisioningConfig(new OutboundProvisioningConfig());
List<InboundAuthenticationRequestConfig> authRequestList = new ArrayList<>();
if (consumerKey != null) {
InboundAuthenticationRequestConfig opicAuthenticationRequest = new InboundAuthenticationRequestConfig();
opicAuthenticationRequest.setInboundAuthKey(consumerKey);
opicAuthenticationRequest.setInboundAuthType("oauth2");
if (consumerSecret != null && !consumerSecret.isEmpty()) {
Property property = new Property();
property.setName("oauthConsumerSecret");
property.setValue(consumerSecret);
Property[] properties = { property };
opicAuthenticationRequest.setProperties(properties);
}
authRequestList.add(opicAuthenticationRequest);
}
String passiveSTSRealm = SERVICE_PROVIDER_NAME;
if (passiveSTSRealm != null) {
InboundAuthenticationRequestConfig opicAuthenticationRequest = new InboundAuthenticationRequestConfig();
opicAuthenticationRequest.setInboundAuthKey(passiveSTSRealm);
opicAuthenticationRequest.setInboundAuthType("passivests");
authRequestList.add(opicAuthenticationRequest);
}
String openidRealm = SERVICE_PROVIDER_NAME;
if (openidRealm != null) {
InboundAuthenticationRequestConfig opicAuthenticationRequest = new InboundAuthenticationRequestConfig();
opicAuthenticationRequest.setInboundAuthKey(openidRealm);
opicAuthenticationRequest.setInboundAuthType("openid");
authRequestList.add(opicAuthenticationRequest);
}
if (authRequestList.size() > 0) {
serviceProvider.getInboundAuthenticationConfig().setInboundAuthenticationRequestConfigs(authRequestList.toArray(new InboundAuthenticationRequestConfig[authRequestList.size()]));
}
appMgtclient.updateApplicationData(serviceProvider);
return appDtoResult;
}
Aggregations