Java Code Examples for org.wso2.carbon.identity.oauth.dto.OAuthConsumerAppDTO#setCallbackUrl()

The following examples show how to use org.wso2.carbon.identity.oauth.dto.OAuthConsumerAppDTO#setCallbackUrl() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OAuthAdminService.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
/**
 * Get OAuth application data by the consumer key.
 *
 * @param consumerKey Consumer Key
 * @return <code>OAuthConsumerAppDTO</code> with application information
 * @throws Exception Error when reading application information from persistence store.
 */
public OAuthConsumerAppDTO getOAuthApplicationData(String consumerKey) throws IdentityOAuthAdminException {
    OAuthConsumerAppDTO dto = new OAuthConsumerAppDTO();
    OAuthAppDAO dao = new OAuthAppDAO();
    try {
        OAuthAppDO app = dao.getAppInformation(consumerKey);
        if (app != null) {
            dto.setApplicationName(app.getApplicationName());
            dto.setCallbackUrl(app.getCallbackUrl());
            dto.setOauthConsumerKey(app.getOauthConsumerKey());
            dto.setOauthConsumerSecret(app.getOauthConsumerSecret());
            dto.setOAuthVersion(app.getOauthVersion());
            dto.setGrantTypes(app.getGrantTypes());
        }
        return dto;
    } catch (InvalidOAuthClientException | IdentityOAuth2Exception e) {
        throw new IdentityOAuthAdminException("Error while retrieving the app information using consumer key", e);
    }

}
 
Example 2
Source File: OAuthAdminService.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
/**
 * Get OAuth application data by the application name.
 *
 * @param appName OAuth application name
 * @return <code>OAuthConsumerAppDTO</code> with application information
 * @throws Exception Error when reading application information from persistence store.
 */
public OAuthConsumerAppDTO getOAuthApplicationDataByAppName(String appName) throws IdentityOAuthAdminException {
    OAuthConsumerAppDTO dto = new OAuthConsumerAppDTO();
    OAuthAppDAO dao = new OAuthAppDAO();
    try {
        OAuthAppDO app = dao.getAppInformationByAppName(appName);
        if (app != null) {
            dto.setApplicationName(app.getApplicationName());
            dto.setCallbackUrl(app.getCallbackUrl());
            dto.setOauthConsumerKey(app.getOauthConsumerKey());
            dto.setOauthConsumerSecret(app.getOauthConsumerSecret());
            dto.setOAuthVersion(app.getOauthVersion());
            dto.setGrantTypes(app.getGrantTypes());
        }
        return dto;
    }catch (InvalidOAuthClientException | IdentityOAuth2Exception e){
        throw new IdentityOAuthAdminException("Error while retrieving the app information by app name", e);
    }
}
 
Example 3
Source File: ApiModelToOAuthConsumerApp.java    From identity-api-server with Apache License 2.0 5 votes vote down vote up
@Override
public OAuthConsumerAppDTO apply(String appName, OpenIDConnectConfiguration oidcModel) {

    OAuthConsumerAppDTO consumerAppDTO = new OAuthConsumerAppDTO();

    consumerAppDTO.setApplicationName(appName);
    consumerAppDTO.setOauthConsumerKey(oidcModel.getClientId());
    consumerAppDTO.setOauthConsumerSecret(oidcModel.getClientSecret());

    consumerAppDTO.setCallbackUrl(getCallbackUrl(oidcModel.getCallbackURLs()));

    consumerAppDTO.setOAuthVersion(OAuthConstants.OAuthVersions.VERSION_2);
    consumerAppDTO.setUsername(ContextLoader.getUsernameFromContext());

    consumerAppDTO.setGrantTypes(getGrantTypes(oidcModel));
    consumerAppDTO.setScopeValidators(getScopeValidators(oidcModel));

    consumerAppDTO.setBypassClientCredentials(oidcModel.getPublicClient());
    consumerAppDTO.setRequestObjectSignatureValidationEnabled(oidcModel.getValidateRequestObjectSignature());
    consumerAppDTO.setTokenBindingType(oidcModel.getAccessTokenBindingType());

    updateAllowedOrigins(consumerAppDTO, oidcModel.getAllowedOrigins());
    updatePkceConfigurations(consumerAppDTO, oidcModel.getPkce());
    updateAccessTokenConfiguration(consumerAppDTO, oidcModel.getAccessToken());
    updateRefreshTokenConfiguration(consumerAppDTO, oidcModel.getRefreshToken());
    updateIdTokenConfiguration(consumerAppDTO, oidcModel.getIdToken());
    updateOidcLogoutConfiguration(consumerAppDTO, oidcModel.getLogout());

    return consumerAppDTO;
}
 
Example 4
Source File: RegistrationServiceImpl.java    From carbon-apimgt with Apache License 2.0 5 votes vote down vote up
/**
 * Method to create a OAuth App with client credentials
 *
 * @param appName    application name
 * @param grantTypes grant types
 * @param userName   username of the application
 * @return created Oauth App
 */
private OAuthConsumerAppDTO createOAuthApp(String appName, OAuthApplicationInfo applicationInfo,
        String grantTypes, String userName) {
    OAuthConsumerAppDTO createdApp = null;
    OAuthAdminService oauthAdminService = new OAuthAdminService();
    OAuthConsumerAppDTO oauthConsumerAppDTO = new OAuthConsumerAppDTO();
    oauthConsumerAppDTO.setApplicationName(appName);
    if (StringUtils.isNotBlank(applicationInfo.getCallBackURL())) {
        oauthConsumerAppDTO.setCallbackUrl(applicationInfo.getCallBackURL());
    }
    oauthConsumerAppDTO.setUsername(userName);
    oauthConsumerAppDTO.setOAuthVersion(OAuthConstants.OAuthVersions.VERSION_2);
    oauthConsumerAppDTO.setGrantTypes(grantTypes.trim());
    try {
        boolean isHashDisabled = OAuth2Util.isHashDisabled();
        if (isHashDisabled) {
            //Creating the Oauth app
            oauthAdminService.registerOAuthApplicationData(oauthConsumerAppDTO);

            //Retrieving the created OAuth application
            createdApp = oauthAdminService.getOAuthApplicationDataByAppName
                    (oauthConsumerAppDTO.getApplicationName());
        } else {
            createdApp = oauthAdminService.registerAndRetrieveOAuthApplicationData(oauthConsumerAppDTO);
        }
    } catch (IdentityOAuthAdminException e) {
        log.error("Error occurred while creating the OAuth app", e);
    }
    if (log.isDebugEnabled()) {
        log.debug("Created OAuth App " + appName);
    }
    return createdApp;
}
 
Example 5
Source File: SessionDataPublisherImpl.java    From carbon-apimgt with Apache License 2.0 5 votes vote down vote up
/**
 * Method to build a OAuthConsumerAppDTO type object
 * @param appDO required param
 * @return OAuthConsumerAppDTO type object
 */
private OAuthConsumerAppDTO buildConsumerAppDTO(OAuthAppDO appDO) {

    OAuthConsumerAppDTO dto = new OAuthConsumerAppDTO();
    dto.setApplicationName(appDO.getApplicationName());
    dto.setCallbackUrl(appDO.getCallbackUrl());
    dto.setOauthConsumerKey(appDO.getOauthConsumerKey());
    dto.setOauthConsumerSecret(appDO.getOauthConsumerSecret());
    dto.setOAuthVersion(appDO.getOauthVersion());
    dto.setGrantTypes(appDO.getGrantTypes());
    dto.setScopeValidators(appDO.getScopeValidators());
    dto.setUsername(appDO.getAppOwner().toFullQualifiedUsername());
    dto.setState(appDO.getState());
    dto.setPkceMandatory(appDO.isPkceMandatory());
    dto.setPkceSupportPlain(appDO.isPkceSupportPlain());
    dto.setUserAccessTokenExpiryTime(appDO.getUserAccessTokenExpiryTime());
    dto.setApplicationAccessTokenExpiryTime(appDO.getApplicationAccessTokenExpiryTime());
    dto.setRefreshTokenExpiryTime(appDO.getRefreshTokenExpiryTime());
    dto.setIdTokenExpiryTime(appDO.getIdTokenExpiryTime());
    dto.setAudiences(appDO.getAudiences());
    dto.setRequestObjectSignatureValidationEnabled(appDO.isRequestObjectSignatureValidationEnabled());
    dto.setIdTokenEncryptionEnabled(appDO.isIdTokenEncryptionEnabled());
    dto.setIdTokenEncryptionAlgorithm(appDO.getIdTokenEncryptionAlgorithm());
    dto.setIdTokenEncryptionMethod(appDO.getIdTokenEncryptionMethod());
    dto.setBackChannelLogoutUrl(appDO.getBackChannelLogoutUrl());
    dto.setTokenType(appDO.getTokenType());
    dto.setBypassClientCredentials(appDO.isBypassClientCredentials());
    return dto;
}