Search in sources :

Example 1 with PCRException

use of com.wso2telco.core.pcrservice.exception.PCRException in project core-util by WSO2Telco.

the class UUIDPCRService method updateServiceProviderMap.

private void updateServiceProviderMap(String appId) throws PCRException {
    if (DEBUG)
        log.debug("Updating Service Provider Map");
    try {
        OAuthConsumerAppDTO apps = authApplicationData.getApplicationData(appId);
        if (DEBUG)
            log.debug("Application List recieved");
        if (apps == null) {
            log.error("Application data not found - updateServiceProviderMap");
            throw new PCRException("Null Application list - updateServiceProviderMap");
        }
        String callbackUrl = apps.getCallbackUrl();
        String sector = SectorUtil.getSectorIdFromUrl(callbackUrl);
        KeyValueBasedPcrDAOImpl keyValueBasedPcrDAOImpl = new KeyValueBasedPcrDAOImpl();
        keyValueBasedPcrDAOImpl.createNewSPEntry(sector, appId, true);
    } catch (Exception e) {
        log.error("error in retrieving application data - updateServiceProviderMap", e);
        throw new PCRException("error in retrieving application data - updateServiceProviderMap");
    }
}
Also used : PCRException(com.wso2telco.core.pcrservice.exception.PCRException) OAuthConsumerAppDTO(org.wso2.carbon.identity.oauth.stub.dto.OAuthConsumerAppDTO) KeyValueBasedPcrDAOImpl(com.wso2telco.core.pcrservice.dao.impl.KeyValueBasedPcrDAOImpl) PCRException(com.wso2telco.core.pcrservice.exception.PCRException)

Example 2 with PCRException

use of com.wso2telco.core.pcrservice.exception.PCRException in project core-util by WSO2Telco.

the class OAuthApplicationDataStubFactory method generateStub.

/**
 * This is used to create a stub which will be triggered through object pool factory, which will create an
 * instance of it.
 *
 * @return OAuth2TokenValidationServiceStub stub that is used to call an external service.
 * @throws PCRException will be thrown when initialization failed.
 */
private OAuthAdminServiceStub generateStub() throws PCRException {
    OAuthAdminServiceStub stub;
    try {
        URL hostURL = new URL(config.getHostUrl());
        // ConfigurationContext myConfigContext =
        // ConfigurationContextFactory.createConfigurationContextFromFileSystem(
        // "repo", CarbonUtils.getCarbonConfigDirPath() + File.separator + "axis2" + File.separator +
        // "axis2.xml");
        stub = new OAuthAdminServiceStub(null, hostURL.toString());
        ServiceClient client = stub._getServiceClient();
        client.getServiceContext().getConfigurationContext().setProperty(HTTPConstants.CACHED_HTTP_CLIENT, httpClient);
        HttpTransportProperties.Authenticator auth = new HttpTransportProperties.Authenticator();
        auth.setPreemptiveAuthentication(true);
        String username = config.getUsername();
        String password = config.getPassword();
        auth.setUsername(username);
        auth.setPassword(password);
        Options options = client.getOptions();
        options.setProperty(HTTPConstants.AUTHENTICATE, auth);
        options.setProperty(HTTPConstants.REUSE_HTTP_CLIENT, Constants.VALUE_TRUE);
        client.setOptions(options);
    } catch (AxisFault axisFault) {
        log.error("Error occurred while creating the OAuth2TokenValidationServiceStub.");
        throw new PCRException("Error occurred while creating the OAuth2TokenValidationServiceStub.", axisFault);
    } catch (MalformedURLException e) {
        log.error("Malformed URL error");
        throw new PCRException("Malformed URL error", e);
    }
    return stub;
}
Also used : AxisFault(org.apache.axis2.AxisFault) Options(org.apache.axis2.client.Options) HttpTransportProperties(org.apache.axis2.transport.http.HttpTransportProperties) MalformedURLException(java.net.MalformedURLException) OAuthAdminServiceStub(org.wso2.carbon.identity.oauth.stub.OAuthAdminServiceStub) ServiceClient(org.apache.axis2.client.ServiceClient) PCRException(com.wso2telco.core.pcrservice.exception.PCRException) URL(java.net.URL)

Example 3 with PCRException

use of com.wso2telco.core.pcrservice.exception.PCRException in project core-util by WSO2Telco.

the class UUIDPCRGenarator method getExistingPCR.

@Override
public Returnable getExistingPCR(RequestDTO dto) throws PCRException {
    try {
        UUIDPCRService uuidpcrService = new UUIDPCRService();
        uuid = uuidpcrService.getExistingPCR(dto);
    } catch (Exception e) {
        log.error(ERROR_IN_RECEIVING_A_PCR, e);
        throw new PCRException(ERROR_IN_RECEIVING_A_PCR);
    }
    return new Returnable() {

        @Override
        public String getID() {
            return uuid;
        }
    };
}
Also used : Returnable(com.wso2telco.core.pcrservice.Returnable) PCRException(com.wso2telco.core.pcrservice.exception.PCRException) PCRException(com.wso2telco.core.pcrservice.exception.PCRException)

Example 4 with PCRException

use of com.wso2telco.core.pcrservice.exception.PCRException in project core-util by WSO2Telco.

the class UUIDPCRGenarator method getPCR.

/* (non-Javadoc)
     * @see com.wso2telco.core.pcrservice.PCRGeneratable#getPCR(com.wso2telco.core.pcrservice.model.RequestDTO)
     */
@Override
public Returnable getPCR(RequestDTO requestDTO) throws PCRException {
    try {
        UUIDPCRService uuidpcrService = new UUIDPCRService();
        uuid = uuidpcrService.getPcr(requestDTO);
    } catch (Exception e) {
        log.error(ERROR_IN_RECEIVING_A_PCR, e);
        throw new PCRException(ERROR_IN_RECEIVING_A_PCR);
    }
    return new Returnable() {

        @Override
        public String getID() {
            // TODO Auto-generated method stub
            return uuid;
        }
    };
}
Also used : Returnable(com.wso2telco.core.pcrservice.Returnable) PCRException(com.wso2telco.core.pcrservice.exception.PCRException) PCRException(com.wso2telco.core.pcrservice.exception.PCRException)

Example 5 with PCRException

use of com.wso2telco.core.pcrservice.exception.PCRException in project core-util by WSO2Telco.

the class UUIDPCRGenarator method getMsisdnByPcr.

@Override
public Returnable getMsisdnByPcr(String sectorId, String pcr) throws PCRException {
    try {
        UUIDPCRService uuidpcrService = new UUIDPCRService();
        uuid = uuidpcrService.getMsisdnByPcr(sectorId, pcr);
    } catch (Exception e) {
        log.error(ERROR_IN_RECIEVING_MSISDN, e);
        throw new PCRException(ERROR_IN_RECIEVING_MSISDN);
    }
    return new Returnable() {

        @Override
        public String getID() {
            return uuid;
        }
    };
}
Also used : Returnable(com.wso2telco.core.pcrservice.Returnable) PCRException(com.wso2telco.core.pcrservice.exception.PCRException) PCRException(com.wso2telco.core.pcrservice.exception.PCRException)

Aggregations

PCRException (com.wso2telco.core.pcrservice.exception.PCRException)7 Returnable (com.wso2telco.core.pcrservice.Returnable)3 KeyValueBasedPcrDAOImpl (com.wso2telco.core.pcrservice.dao.impl.KeyValueBasedPcrDAOImpl)2 OAuthAdminServiceStub (org.wso2.carbon.identity.oauth.stub.OAuthAdminServiceStub)2 OAuthConsumerAppDTO (org.wso2.carbon.identity.oauth.stub.dto.OAuthConsumerAppDTO)2 RequestDTO (com.wso2telco.core.pcrservice.model.RequestDTO)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 AxisFault (org.apache.axis2.AxisFault)1 Options (org.apache.axis2.client.Options)1 ServiceClient (org.apache.axis2.client.ServiceClient)1 ServiceContext (org.apache.axis2.context.ServiceContext)1 HttpTransportProperties (org.apache.axis2.transport.http.HttpTransportProperties)1