Fixing the issue where client type is not honoured in dynamic client registration service

revert-70aa11f8
prabathabey 9 years ago
parent 10fd6f51d1
commit 8578ff60ca

@ -41,7 +41,9 @@ import org.wso2.carbon.identity.sso.saml.dto.SAMLSSOServiceProviderDTO;
import org.wso2.carbon.registry.core.Registry; import org.wso2.carbon.registry.core.Registry;
import org.wso2.carbon.utils.multitenancy.MultitenantUtils; import org.wso2.carbon.utils.multitenancy.MultitenantUtils;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List;
/** /**
* Implementation of DynamicClientRegistrationService. * Implementation of DynamicClientRegistrationService.
@ -60,9 +62,12 @@ public class DynamicClientRegistrationServiceImpl implements DynamicClientRegist
private static final int STEP_ORDER = 1; private static final int STEP_ORDER = 1;
private static final String OAUTH_VERSION = "OAuth-2.0"; private static final String OAUTH_VERSION = "OAuth-2.0";
private static final String APPLICATION_TYPE_WEBAPP = "webapp";
private static final String APPLICATION_TYPE_DEVICE = "device";
@Override @Override
public OAuthApplicationInfo registerOAuthApplication(RegistrationProfile profile) throws public OAuthApplicationInfo registerOAuthApplication(
DynamicClientRegistrationException { RegistrationProfile profile) throws DynamicClientRegistrationException {
OAuthApplicationInfo oAuthApplicationInfo = new OAuthApplicationInfo(); OAuthApplicationInfo oAuthApplicationInfo = new OAuthApplicationInfo();
String applicationName = profile.getClientName(); String applicationName = profile.getClientName();
@ -78,9 +83,7 @@ public class DynamicClientRegistrationServiceImpl implements DynamicClientRegist
OAuthApplicationInfo info; OAuthApplicationInfo info;
try { try {
info = this.createOAuthApplication(profile); info = this.createOAuthApplication(profile);
} catch (DynamicClientRegistrationException e) { } catch (DynamicClientRegistrationException | IdentityException e) {
throw new DynamicClientRegistrationException("Can not create OAuth application : " + applicationName, e);
} catch (IdentityException e) {
throw new DynamicClientRegistrationException("Can not create OAuth application : " + applicationName, e); throw new DynamicClientRegistrationException("Can not create OAuth application : " + applicationName, e);
} }
@ -199,8 +202,7 @@ public class DynamicClientRegistrationServiceImpl implements DynamicClientRegist
// Set the OAuthApp in InboundAuthenticationConfig // Set the OAuthApp in InboundAuthenticationConfig
InboundAuthenticationConfig inboundAuthenticationConfig = InboundAuthenticationConfig inboundAuthenticationConfig =
new InboundAuthenticationConfig(); new InboundAuthenticationConfig();
InboundAuthenticationRequestConfig[] inboundAuthenticationRequestConfigs = new List<InboundAuthenticationRequestConfig> inboundAuthenticationRequestConfigs = new ArrayList<>();
InboundAuthenticationRequestConfig[2];
InboundAuthenticationRequestConfig inboundAuthenticationRequestConfig = new InboundAuthenticationRequestConfig inboundAuthenticationRequestConfig = new
InboundAuthenticationRequestConfig(); InboundAuthenticationRequestConfig();
@ -215,15 +217,18 @@ public class DynamicClientRegistrationServiceImpl implements DynamicClientRegist
inboundAuthenticationRequestConfig.setProperties(properties); inboundAuthenticationRequestConfig.setProperties(properties);
} }
if (APPLICATION_TYPE_WEBAPP.equals(profile.getApplicationType())) {
SAMLSSOServiceProviderDTO samlssoServiceProviderDTO = new SAMLSSOServiceProviderDTO(); SAMLSSOServiceProviderDTO samlssoServiceProviderDTO = new SAMLSSOServiceProviderDTO();
samlssoServiceProviderDTO.setIssuer(MDM); samlssoServiceProviderDTO.setIssuer(applicationName);
SAMLSSOConfigAdmin configAdmin = new SAMLSSOConfigAdmin(getConfigSystemRegistry()); SAMLSSOConfigAdmin configAdmin = new SAMLSSOConfigAdmin(getConfigSystemRegistry());
configAdmin.addRelyingPartyServiceProvider(samlssoServiceProviderDTO); configAdmin.addRelyingPartyServiceProvider(samlssoServiceProviderDTO);
InboundAuthenticationRequestConfig samlAuthenticationRequest = new InboundAuthenticationRequestConfig(); InboundAuthenticationRequestConfig samlAuthenticationRequest = new InboundAuthenticationRequestConfig();
samlAuthenticationRequest.setInboundAuthKey(MDM); samlAuthenticationRequest.setInboundAuthKey(applicationName);
samlAuthenticationRequest.setInboundAuthType(SAML_SSO); samlAuthenticationRequest.setInboundAuthType(SAML_SSO);
inboundAuthenticationRequestConfigs.add(samlAuthenticationRequest);
}
LocalAuthenticatorConfig localAuth = new LocalAuthenticatorConfig(); LocalAuthenticatorConfig localAuth = new LocalAuthenticatorConfig();
localAuth.setName(BASIC_AUTHENTICATOR); localAuth.setName(BASIC_AUTHENTICATOR);
@ -240,13 +245,13 @@ public class DynamicClientRegistrationServiceImpl implements DynamicClientRegist
LocalAndOutboundAuthenticationConfig localOutboundAuthConfig = new LocalAndOutboundAuthenticationConfig(); LocalAndOutboundAuthenticationConfig localOutboundAuthConfig = new LocalAndOutboundAuthenticationConfig();
localOutboundAuthConfig.setAuthenticationType(LOCAL); localOutboundAuthConfig.setAuthenticationType(LOCAL);
localOutboundAuthConfig.setAuthenticationSteps(new AuthenticationStep[]{authStep}); localOutboundAuthConfig.setAuthenticationSteps(new AuthenticationStep[]{authStep});
createdServiceProvider.setLocalAndOutBoundAuthenticationConfig(localOutboundAuthConfig);
inboundAuthenticationRequestConfigs[0] = inboundAuthenticationRequestConfig; inboundAuthenticationRequestConfigs.add(inboundAuthenticationRequestConfig);
inboundAuthenticationRequestConfigs[1] = samlAuthenticationRequest;
inboundAuthenticationConfig inboundAuthenticationConfig
.setInboundAuthenticationRequestConfigs(inboundAuthenticationRequestConfigs); .setInboundAuthenticationRequestConfigs(inboundAuthenticationRequestConfigs.toArray(
new InboundAuthenticationRequestConfig[inboundAuthenticationRequestConfigs.size()]));
createdServiceProvider.setInboundAuthenticationConfig(inboundAuthenticationConfig); createdServiceProvider.setInboundAuthenticationConfig(inboundAuthenticationConfig);
createdServiceProvider.setLocalAndOutBoundAuthenticationConfig(localOutboundAuthConfig);
// Update the Service Provider app to add OAuthApp as an Inbound Authentication Config // Update the Service Provider app to add OAuthApp as an Inbound Authentication Config
appMgtService.updateApplication(createdServiceProvider, tenantDomain, userName); appMgtService.updateApplication(createdServiceProvider, tenantDomain, userName);

@ -23,7 +23,7 @@ package org.wso2.carbon.dynamic.client.registration.profile;
* *
* */ * */
public class RegistrationProfile { public class RegistrationProfile {
//todo mark mandatory fields
private String applicationType; private String applicationType;
private String[] redirectUris; private String[] redirectUris;
private String clientName; private String clientName;
@ -42,6 +42,8 @@ public class RegistrationProfile {
private String grantType; private String grantType;
private boolean saasApp; private boolean saasApp;
private String audience; private String audience;
private String recepientValidationURL;
private String assertionConsumerURL;
public String getRecepientValidationURL() { public String getRecepientValidationURL() {
return recepientValidationURL; return recepientValidationURL;
@ -59,9 +61,6 @@ public class RegistrationProfile {
this.assertionConsumerURL = assertionConsumerURL; this.assertionConsumerURL = assertionConsumerURL;
} }
private String recepientValidationURL;
private String assertionConsumerURL;
public String getAudience() { public String getAudience() {
return audience; return audience;
} }

Loading…
Cancel
Save