Search in sources :

Example 1 with CibaClientException

use of org.wso2.carbon.identity.oauth.ciba.exceptions.CibaClientException in project identity-inbound-auth-oauth by wso2-extensions.

the class CibaAuthServiceImpl method buildAuthCodeResponse.

/**
 * Builds and returns CibaAuthCodeResponse.
 *
 * @param cibaAuthCodeDO      DO with information regarding authenticationRequest.
 * @param cibaAuthCodeRequest Auth Code request object.
 * @throws CibaCoreException   Exception thrown from CibaCore Component.
 * @throws CibaClientException Client exception thrown from CibaCore Component.
 */
private CibaAuthCodeResponse buildAuthCodeResponse(CibaAuthCodeRequest cibaAuthCodeRequest, CibaAuthCodeDO cibaAuthCodeDO) throws CibaCoreException, CibaClientException {
    String clientID = cibaAuthCodeRequest.getIssuer();
    try {
        CibaAuthCodeResponse cibaAuthCodeResponse = new CibaAuthCodeResponse();
        String user = cibaAuthCodeRequest.getUserHint();
        OAuthAppDO appDO = OAuth2Util.getAppInformationByClientId(clientID);
        String callbackUri = appDO.getCallbackUrl();
        cibaAuthCodeResponse.setAuthReqId(cibaAuthCodeDO.getAuthReqId());
        cibaAuthCodeResponse.setCallBackUrl(callbackUri);
        cibaAuthCodeResponse.setUserHint(user);
        cibaAuthCodeResponse.setClientId(clientID);
        cibaAuthCodeResponse.setScopes(cibaAuthCodeRequest.getScopes());
        cibaAuthCodeResponse.setExpiresIn(cibaAuthCodeDO.getExpiresIn());
        if (StringUtils.isNotBlank(cibaAuthCodeRequest.getBindingMessage())) {
            cibaAuthCodeResponse.setBindingMessage(cibaAuthCodeRequest.getBindingMessage());
        }
        if (StringUtils.isNotBlank(cibaAuthCodeRequest.getTransactionContext())) {
            cibaAuthCodeResponse.setTransactionDetails(cibaAuthCodeRequest.getTransactionContext());
        }
        if (log.isDebugEnabled()) {
            log.debug("Successful in creating AuthCodeResponse for the client: " + clientID);
        }
        return cibaAuthCodeResponse;
    } catch (IdentityOAuth2Exception e) {
        throw new CibaCoreException("Error in creating AuthCodeResponse for the client: " + clientID, e);
    } catch (InvalidOAuthClientException e) {
        throw new CibaClientException("Error in creating AuthCodeResponse for the client: " + clientID, e);
    }
}
Also used : OAuthAppDO(org.wso2.carbon.identity.oauth.dao.OAuthAppDO) IdentityOAuth2Exception(org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception) CibaClientException(org.wso2.carbon.identity.oauth.ciba.exceptions.CibaClientException) CibaAuthCodeResponse(org.wso2.carbon.identity.oauth.ciba.model.CibaAuthCodeResponse) CibaCoreException(org.wso2.carbon.identity.oauth.ciba.exceptions.CibaCoreException) InvalidOAuthClientException(org.wso2.carbon.identity.oauth.common.exception.InvalidOAuthClientException)

Example 2 with CibaClientException

use of org.wso2.carbon.identity.oauth.ciba.exceptions.CibaClientException in project identity-inbound-auth-oauth by wso2-extensions.

the class CibaAuthServiceImpl method generateAuthCodeResponse.

@Override
public CibaAuthCodeResponse generateAuthCodeResponse(CibaAuthCodeRequest cibaAuthCodeRequest) throws CibaCoreException, CibaClientException {
    CibaAuthCodeDO cibaAuthCodeDO = generateCibaAuthCodeDO(cibaAuthCodeRequest);
    CibaDAOFactory.getInstance().getCibaAuthMgtDAO().persistCibaAuthCode(cibaAuthCodeDO);
    return buildAuthCodeResponse(cibaAuthCodeRequest, cibaAuthCodeDO);
}
Also used : CibaAuthCodeDO(org.wso2.carbon.identity.oauth.ciba.model.CibaAuthCodeDO)

Aggregations

CibaClientException (org.wso2.carbon.identity.oauth.ciba.exceptions.CibaClientException)1 CibaCoreException (org.wso2.carbon.identity.oauth.ciba.exceptions.CibaCoreException)1 CibaAuthCodeDO (org.wso2.carbon.identity.oauth.ciba.model.CibaAuthCodeDO)1 CibaAuthCodeResponse (org.wso2.carbon.identity.oauth.ciba.model.CibaAuthCodeResponse)1 InvalidOAuthClientException (org.wso2.carbon.identity.oauth.common.exception.InvalidOAuthClientException)1 OAuthAppDO (org.wso2.carbon.identity.oauth.dao.OAuthAppDO)1 IdentityOAuth2Exception (org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception)1