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

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

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

Loading…
Cancel
Save