Package org.agorava.api.exception

Examples of org.agorava.api.exception.AgoravaException


    private String extract(String response, Pattern p) {
        Matcher matcher = p.matcher(response);
        if (matcher.find() && matcher.groupCount() >= 1) {
            return OAuthEncoder.decode(matcher.group(1));
        } else {
            throw new AgoravaException("Response body is incorrect. Can't extract token and secret from this: '" + response +
                    "'", null);
        }
    }
View Full Code Here


        Class<? extends OAuthAppSettingsBuilder> clazz = getClass();
        try {
            setter = clazz.getMethod(k, String.class);
            setter.invoke(this, value);
        } catch (Exception e) {
            throw new AgoravaException("Unable to invoke setter for " + k + " in class " + clazz, e);
        }

    }
View Full Code Here

        for (Annotation a : clazz.getAnnotations()) {
            if (a.annotationType().isAnnotationPresent(ProviderRelated.class)) {
                if (res == null)
                    res = a;
                else
                    throw new AgoravaException("Class " + getClass() + " have more than one ProviderRelated " +
                            "annotation");
            }
        }
        if (res == null)
            throw new AgoravaException("Class " + getClass() + " doesn't have a ProviderRelated annotation");
        providerAnnotation = res;
        providerName = res.annotationType().getAnnotation(ProviderRelated.class).value();

    }
View Full Code Here

        Preconditions.checkNotNull(plain, "Cannot encode null object");
        String encoded = "";
        try {
            encoded = URLEncoder.encode(plain, CHARSET);
        } catch (UnsupportedEncodingException uee) {
            throw new AgoravaException("Charset not found while encoding string: " + CHARSET, uee);
        }
        for (Map.Entry<String, String> rule : ENCODING_RULES.entrySet()) {
            encoded = applyRule(encoded, rule.getKey(), rule.getValue());
        }
        return encoded;
View Full Code Here

    public static String decode(String encoded) {
        Preconditions.checkNotNull(encoded, "Cannot decode null object");
        try {
            return URLDecoder.decode(encoded, CHARSET);
        } catch (UnsupportedEncodingException uee) {
            throw new AgoravaException("Charset not found while decoding string: " + CHARSET, uee);
        }
    }
View Full Code Here

        } else {
            String authorizationUrl = lifeCycleService.startDanceFor(settings.getQualifier());
            try {
                response.get().sendRedirect(authorizationUrl);
            } catch (IOException e) {
                throw new AgoravaException("Unable to redirect user to: " + authorizationUrl);
            }
            credentials.setStatus(Status.IN_PROGRESS);
            setStatus(AuthenticationStatus.DEFERRED);
        }
    }
View Full Code Here

    @Override
    public OAuthSession buildSessionFor(String providerName) {
        OAuthSession res;
        Annotation qualifier = getServicesToQualifier().get(providerName);
        if (qualifier == null) {
            throw new AgoravaException("Cannot find configured service provider with name : " + providerName);
        }
        return buildSessionFor(qualifier);
    }
View Full Code Here

    @Override
    public String startDanceFor(Class<? extends Annotation> providerClass) {
        Annotation qualifier = getClassToQualifierQualifier().get(providerClass);
        if (qualifier == null) {
            throw new AgoravaException("Cannot find configured service provider with class : " + providerClass);
        }
        return startDanceFor(qualifier);
    }
View Full Code Here

        log.log(INFO, "Qualifiers configured {0}", providerQualifiersConfigured);
        Annotation qual = null;
        try {
            qual = getSingleProviderRelatedQualifier(annotatedMember, false);
        } catch (AgoravaException e) {
            pp.addDefinitionError(new AgoravaException("OAuthAppSettings producers should be annotated with a Service " +
                    "Provider on " + annotatedMember.getJavaMember().getName() + " in " + annotatedMember.getJavaMember()
                    .getDeclaringClass()));
        }

        if (annotatedMember.isAnnotationPresent(OAuthApplication.class)) {
            if (annotatedMember instanceof AnnotatedField) {

                final OAuthApplication app = annotatedMember.getAnnotation(OAuthApplication.class);

                OAuthAppSettingsBuilder builderOAuthApp = null;
                Class<? extends OAuthAppSettingsBuilder> builderClass = app.builder();
                if (builderClass == OAuthAppSettingsBuilder.class) {
                    log.info("You didn't provide a Concrete OAuthAppSettingsBuilder class using the default " +
                            "PropertyOAuthAppSettingsBuilder class");
                    builderClass = PropertyOAuthAppSettingsBuilder.class;
                }
                try {
                    builderOAuthApp = builderClass.newInstance();
                } catch (Exception e) {
                    pp.addDefinitionError(new AgoravaException("Unable to create Settings Builder with class " +
                            builderClass, e));
                }

                builderOAuthApp.qualifier(qual)
                        .params(app.params());

                pp.setProducer(new OAuthAppSettingsProducerWithBuilder(builderOAuthApp, qual));
            } else
                pp.addDefinitionError(new AgoravaException("@OAuthApplication are only supported on Field. Agorava cannot " +
                        "process producer " + annotatedMember.getJavaMember().getName() + " in class " + annotatedMember
                        .getJavaMember().getDeclaringClass()));
        } else {
            final Producer<OAuthAppSettings> oldProducer = pp.getProducer();
            pp.setProducer(new OAuthAppSettingsProducerDecorator(oldProducer, qual));
View Full Code Here

    private void CommonsProcessOAuthTier(ProcessBean<? extends ProviderConfigOauth> pb) {

        Annotated annotated = pb.getAnnotated();
        Set<Annotation> qualifiers = getAnnotationsWithMeta(annotated, ProviderRelated.class);
        if (qualifiers.size() != 1)
            throw new AgoravaException("A RemoteService bean should have one and only one service related Qualifier : " + pb
                    .getAnnotated().toString());

        Class<? extends ProviderConfigOauth> clazz = (Class<? extends ProviderConfigOauth>) pb.getBean().getBeanClass();
        try {
            providerQualifiers2Version.put(getSingleProviderRelatedQualifier(qualifiers, true),
                    clazz.newInstance().getOAuthVersion());
        } catch (Exception e) {
            throw new AgoravaException("Error while retrieving version of OAuth in tier config", e);
        }
    }
View Full Code Here

TOP

Related Classes of org.agorava.api.exception.AgoravaException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.