use of org.wso2.carbon.identity.application.common.model.xsd.ServiceProviderProperty in project carbon-identity-framework by wso2.
the class ApplicationDAOImpl method getCertificateContent.
/**
* Retrieves the certificate content from the database using the certificate reference id property of a
* service provider.
*
* @param serviceProviderProperties
* @param connection
* @return
* @throws CertificateRetrievingException
*/
private String getCertificateContent(List<ServiceProviderProperty> serviceProviderProperties, Connection connection) throws CertificateRetrievingException {
String certificateReferenceId = null;
for (ServiceProviderProperty property : serviceProviderProperties) {
if ("CERTIFICATE".equals(property.getName())) {
certificateReferenceId = property.getValue();
}
}
if (certificateReferenceId != null) {
PreparedStatement statementForFetchingCertificate = null;
ResultSet results = null;
try {
statementForFetchingCertificate = connection.prepareStatement(GET_CERTIFICATE_BY_ID);
statementForFetchingCertificate.setInt(1, Integer.parseInt(certificateReferenceId));
results = statementForFetchingCertificate.executeQuery();
String certificateContent = null;
while (results.next()) {
certificateContent = getBlobValue(results.getBinaryStream("CERTIFICATE_IN_PEM"));
}
if (certificateContent != null) {
return certificateContent;
}
} catch (SQLException | IOException e) {
String errorMessage = "An error occurred while retrieving the certificate for the " + "application.";
log.error(errorMessage);
throw new CertificateRetrievingException(errorMessage, e);
} finally {
IdentityApplicationManagementUtil.closeResultSet(results);
IdentityApplicationManagementUtil.closeStatement(statementForFetchingCertificate);
}
}
return null;
}
use of org.wso2.carbon.identity.application.common.model.xsd.ServiceProviderProperty in project carbon-identity-framework by wso2.
the class DefaultLogoutRequestHandler method getRegisteredLogoutReturnUrl.
private String getRegisteredLogoutReturnUrl(String relyingParty, String requestType, String tenantDomain) throws IdentityApplicationManagementException {
if (FrameworkConstants.OIDC.equals(requestType)) {
requestType = FrameworkConstants.OAUTH2;
}
String configuredReturnUrl = ".*";
ApplicationManagementService appMgtService = ApplicationManagementService.getInstance();
ServiceProvider serviceProvider = appMgtService.getServiceProviderByClientId(relyingParty, requestType, tenantDomain);
if (serviceProvider != null && serviceProvider.getSpProperties() != null) {
for (ServiceProviderProperty spProperty : serviceProvider.getSpProperties()) {
if (LOGOUT_RETURN_URL_SP_PROPERTY.equals(spProperty.getName())) {
configuredReturnUrl = spProperty.getValue();
if (log.isDebugEnabled()) {
log.debug("Logout caller path validation is configured for service provider of " + relyingParty);
}
break;
}
}
}
return configuredReturnUrl;
}
use of org.wso2.carbon.identity.application.common.model.xsd.ServiceProviderProperty in project identity-inbound-auth-oauth by wso2-extensions.
the class OAuth2AuthzEndpointTest method provideHandleOAuthAuthorizationRequest1Data.
@DataProvider(name = "provideHandleOAuthAuthorizationRequest1Data")
public Object[][] provideHandleOAuthAuthorizationRequest1Data() {
ServiceProvider sp1 = new ServiceProvider();
ServiceProvider sp2 = new ServiceProvider();
ServiceProvider sp3 = new ServiceProvider();
ServiceProviderProperty property1 = new ServiceProviderProperty();
property1.setName(SP_DISPLAY_NAME);
property1.setValue("myApplication");
ServiceProviderProperty property2 = new ServiceProviderProperty();
property2.setName(SP_NAME);
property2.setValue(APP_NAME);
ServiceProviderProperty[] properties1 = new ServiceProviderProperty[] { property1, property2 };
sp1.setSpProperties(properties1);
ServiceProviderProperty[] properties2 = new ServiceProviderProperty[] { property2 };
sp2.setSpProperties(properties2);
return new Object[][] { { true, sp1, "myApplication" }, { true, sp2, null }, { true, sp3, null }, { false, sp1, null } };
}
use of org.wso2.carbon.identity.application.common.model.xsd.ServiceProviderProperty in project identity-inbound-auth-oauth by wso2-extensions.
the class OAuth2AuthzEndpoint method getSpDisplayName.
private String getSpDisplayName(String clientId) throws OAuthSystemException {
if (getOAuthServerConfiguration().isShowDisplayNameInConsentPage()) {
ServiceProvider serviceProvider = getServiceProvider(clientId);
ServiceProviderProperty[] serviceProviderProperties = serviceProvider.getSpProperties();
for (ServiceProviderProperty serviceProviderProperty : serviceProviderProperties) {
if (DISPLAY_NAME.equals(serviceProviderProperty.getName())) {
return serviceProviderProperty.getValue();
}
}
}
return StringUtils.EMPTY;
}
use of org.wso2.carbon.identity.application.common.model.xsd.ServiceProviderProperty in project identity-inbound-auth-oauth by wso2-extensions.
the class DefaultOIDCClaimsCallbackHandlerTest method testHandleClaimsForOAuthAuthzReqMessageContextNullAccessToken.
@Test
public void testHandleClaimsForOAuthAuthzReqMessageContextNullAccessToken() throws Exception {
JWTClaimsSet.Builder jwtClaimsSetBuilder = new JWTClaimsSet.Builder();
AuthenticatedUser authenticatedUser = getDefaultAuthenticatedUserFederatedUser();
OAuth2AuthorizeReqDTO authorizeReqDTO = new OAuth2AuthorizeReqDTO();
authorizeReqDTO.setUser(authenticatedUser);
authorizeReqDTO.setTenantDomain(TENANT_DOMAIN);
OAuthAuthzReqMessageContext authzReqMessageContext = new OAuthAuthzReqMessageContext(authorizeReqDTO);
authzReqMessageContext.setApprovedScope(APPROVED_SCOPES);
ServiceProvider serviceProvider = new ServiceProvider();
serviceProvider.setApplicationName(SERVICE_PROVIDER_NAME);
ClaimMapping claimMap1 = ClaimMapping.build("http://www.wso2.org/claims/email", "email", "sample@abc.com", true);
ClaimMapping claimMap2 = ClaimMapping.build("http://www.wso2.org/claims/username", "username", "user123", true);
ClaimMapping[] requestedLocalClaimMap = { claimMap1, claimMap2 };
ClaimConfig claimConfig = new ClaimConfig();
claimConfig.setClaimMappings(requestedLocalClaimMap);
serviceProvider.setClaimConfig(claimConfig);
serviceProvider.setSpProperties(new ServiceProviderProperty[] {});
OAuthServerConfiguration mockOAuthServerConfiguration = PowerMockito.mock(OAuthServerConfiguration.class);
mockStatic(OAuthServerConfiguration.class);
when(OAuthServerConfiguration.getInstance()).thenReturn(mockOAuthServerConfiguration);
when(mockOAuthServerConfiguration.getOpenIDConnectSkipeUserConsentConfig()).thenReturn(true);
mockApplicationManagementService(serviceProvider);
JWTClaimsSet jwtClaimsSet = defaultOIDCClaimsCallbackHandler.handleCustomClaims(jwtClaimsSetBuilder, authzReqMessageContext);
assertEquals(jwtClaimsSet.getClaims().size(), 0, "Claims are not successfully set.");
}
Aggregations