use of org.wso2.carbon.identity.api.server.tenant.management.v1.model.AdditionalClaims in project identity-inbound-auth-oauth by wso2-extensions.
the class ClaimProviderImpl method getAdditionalClaims.
@Override
public Map<String, Object> getAdditionalClaims(OAuthAuthzReqMessageContext oAuthAuthzReqMessageContext, OAuth2AuthorizeRespDTO oAuth2AuthorizeRespDTO) throws IdentityOAuth2Exception {
Map<String, Object> additionalClaims = new HashMap<>();
String claimValue;
OIDCSessionState previousSession = getSessionState(oAuthAuthzReqMessageContext);
if (previousSession == null) {
// If there is no previous browser session, generate new sid value.
claimValue = UUID.randomUUID().toString();
if (log.isDebugEnabled()) {
log.debug("sid claim is generated for auth request. ");
}
} else {
// Previous browser session exists, get sid claim from OIDCSessionState.
claimValue = previousSession.getSidClaim();
if (log.isDebugEnabled()) {
log.debug("sid claim is found in the session state");
}
}
additionalClaims.put(OAuthConstants.OIDCClaims.SESSION_ID_CLAIM, claimValue);
oAuth2AuthorizeRespDTO.setOidcSessionId(claimValue);
return additionalClaims;
}
use of org.wso2.carbon.identity.api.server.tenant.management.v1.model.AdditionalClaims in project identity-api-server by wso2.
the class ServerTenantManagementService method createTenantInfoBean.
private Tenant createTenantInfoBean(ChannelVerifiedTenantModel channelVerifiedTenantModel) throws TenantManagementClientException {
Tenant tenant = new Tenant();
Map<String, String> claimsMap = new HashMap<>();
tenant.setActive(true);
tenant.setDomain(StringUtils.lowerCase(channelVerifiedTenantModel.getDomain()));
if (channelVerifiedTenantModel.getOwners() != null && channelVerifiedTenantModel.getOwners().size() > 0 && channelVerifiedTenantModel.getOwners().get(0) != null) {
tenant.setAdminName(channelVerifiedTenantModel.getOwners().get(0).getEmail());
tenant.setAdminFirstName(channelVerifiedTenantModel.getOwners().get(0).getFirstname());
tenant.setAdminLastName(channelVerifiedTenantModel.getOwners().get(0).getLastname());
tenant.setEmail(channelVerifiedTenantModel.getOwners().get(0).getEmail());
tenant.setProvisioningMethod(VERIFIED_LITE_USER);
String password = channelVerifiedTenantModel.getOwners().get(0).getPassword();
String code = channelVerifiedTenantModel.getCode();
if (StringUtils.isBlank(code)) {
throw new TenantManagementClientException(TenantConstants.ErrorMessage.ERROR_CODE_MISSING_REQUIRED_PARAMETER.getCode(), String.format(TenantConstants.ErrorMessage.ERROR_CODE_MISSING_REQUIRED_PARAMETER.getMessage(), "code"));
}
if (channelVerifiedTenantModel.getPurpose() != null) {
claimsMap.put(PURPOSE, channelVerifiedTenantModel.getPurpose().getName());
if (!CollectionUtils.isEmpty(channelVerifiedTenantModel.getPurpose().getAttributes())) {
channelVerifiedTenantModel.getPurpose().getAttributes().forEach(attribute -> claimsMap.put(PURPOSE + "_" + attribute.getKey(), attribute.getValue()));
}
}
tenant.setClaimsMap(claimsMap);
tenant.setAdminPassword(password);
List<AdditionalClaims> additionalClaimsList = channelVerifiedTenantModel.getOwners().get(0).getAdditionalClaims();
if (CollectionUtils.isNotEmpty(additionalClaimsList)) {
tenant.setClaimsMap(createClaimsMapping(additionalClaimsList));
}
} else {
throw new TenantManagementClientException(TenantConstants.ErrorMessage.ERROR_CODE_OWNER_REQUIRED);
}
return tenant;
}
use of org.wso2.carbon.identity.api.server.tenant.management.v1.model.AdditionalClaims in project identity-inbound-auth-oauth by wso2-extensions.
the class ClaimProviderImpl method getAdditionalClaims.
@Override
public Map<String, Object> getAdditionalClaims(OAuthTokenReqMessageContext oAuthTokenReqMessageContext, OAuth2AccessTokenRespDTO oAuth2AccessTokenRespDTO) throws IdentityOAuth2Exception {
Map<String, Object> additionalClaims = new HashMap<>();
String claimValue = null;
String accessCode = oAuthTokenReqMessageContext.getOauth2AccessTokenReqDTO().getAuthorizationCode();
if (StringUtils.isBlank(accessCode)) {
if (log.isDebugEnabled()) {
log.debug("AccessCode is null. Possibly a back end grant");
}
return additionalClaims;
}
AuthorizationGrantCacheEntry authzGrantCacheEntry = getAuthorizationGrantCacheEntryFromCode(accessCode);
if (authzGrantCacheEntry != null) {
claimValue = authzGrantCacheEntry.getOidcSessionId();
}
if (claimValue != null) {
if (log.isDebugEnabled()) {
log.debug("sid claim is found in the session state");
}
additionalClaims.put("sid", claimValue);
}
return additionalClaims;
}
use of org.wso2.carbon.identity.api.server.tenant.management.v1.model.AdditionalClaims in project identity-api-server by wso2.
the class ServerTenantManagementService method createTenantInfoBean.
private Tenant createTenantInfoBean(TenantModel tenantModel) throws TenantManagementClientException {
Tenant tenant = new Tenant();
tenant.setActive(true);
tenant.setDomain(tenantModel.getDomain());
if (tenantModel.getOwners() != null) {
tenant.setAdminName(tenantModel.getOwners().get(0).getUsername());
tenant.setAdminFirstName(tenantModel.getOwners().get(0).getFirstname());
tenant.setAdminLastName(tenantModel.getOwners().get(0).getLastname());
tenant.setEmail(tenantModel.getOwners().get(0).getEmail());
String provisioningMethod = tenantModel.getOwners().get(0).getProvisioningMethod();
if (INLINE_PASSWORD.equalsIgnoreCase(provisioningMethod)) {
String password = tenantModel.getOwners().get(0).getPassword();
if (StringUtils.isBlank(password)) {
throw new TenantManagementClientException(TenantConstants.ErrorMessage.ERROR_CODE_MISSING_REQUIRED_PARAMETER.getCode(), String.format(TenantConstants.ErrorMessage.ERROR_CODE_MISSING_REQUIRED_PARAMETER.getMessage(), "password"));
}
tenant.setAdminPassword(password);
}
tenant.setProvisioningMethod(provisioningMethod);
List<AdditionalClaims> additionalClaimsList = tenantModel.getOwners().get(0).getAdditionalClaims();
if (CollectionUtils.isNotEmpty(additionalClaimsList)) {
tenant.setClaimsMap(createClaimsMapping(additionalClaimsList));
}
} else {
throw new TenantManagementClientException(TenantConstants.ErrorMessage.ERROR_CODE_OWNER_REQUIRED);
}
return tenant;
}
Aggregations