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);
}
}
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);
}
Aggregations