Package com.atlassian.connect.play.java.model

Examples of com.atlassian.connect.play.java.model.AcHostModel


        getAttributeAsText(remoteApp, "key");

        final String clientKey = getAttributeAsText(remoteApp, "clientKey");
        final String baseUrl = getAttributeAsText(remoteApp, "baseUrl");

        final AcHostModel acHost = AcHostModel.findByKey(clientKey)
                .orElse(new Supplier<Option<AcHostModel>>()
                {
                    @Override
                    public Option<AcHostModel> get()
                    {
                        return AcHostModel.findByUrl(baseUrl);
                    }
                })
                .getOrElse(new AcHostModel());

        acHost.key = clientKey;
        acHost.baseUrl = baseUrl;
        acHost.publicKey = getAttributeAsText(remoteApp, "publicKey");
        acHost.name = getAttributeAsText(remoteApp, "productType");
View Full Code Here


    private void init(String baseUrl) throws URISyntaxException {
        jwtAuthorizationGenerator = new JwtAuthorizationGenerator(jwtWriterFactory, 60 * 3);
        aUrl = baseUrl + "/foo";
        FakeApplication fakeApplication = Helpers.fakeApplication();
        Helpers.start(fakeApplication);
        acHost = new AcHostModel();
        acHost.sharedSecret = NOT_SO_SECRET_SECRET;
        acHost.baseUrl = baseUrl;

        when(jwtWriterFactory.macSigningWriter(any(SigningAlgorithm.class), anyString())).thenReturn(jwtWriter);

View Full Code Here

        if (remoteApp == null) {
            return Promise.pure((Result) badRequest("can't extract registration request json"));
        }

        final AcHostModel acHost = AcHostModel.fromJson(remoteApp);

        Promise<Void> hostRegistered = AC.registerHost(acHost);
        Promise<Result> resultPromise = hostRegistered.map(new F.Function<Void, Result>() {
            @Override
            public Result apply(Void nada) throws Throwable {
                return ok();
            }
        });

        return resultPromise.recover(new F.Function<Throwable, Result>() {
            @Override
            public Result apply(Throwable throwable) throws Throwable {
                LOGGER.warn("Failed to register host (key = " + acHost.getKey() + ")", throwable);

                if (throwable instanceof PublicKeyVerificationFailureException) {
                    return internalServerError("failed to fetch public key from host for verification");
                }
                return badRequest("Unable to register host. Request invalid"); // TODO: better analysis of failure and feedback to caller
View Full Code Here

public class DefaultAcHostRepository implements AcHostRepository {

    @Override
    public void save(AcHost acHost) throws Throwable {
        final AcHostModel acHostModel = AcHostModel.fromAcHost(acHost);

        // TODO: Not sure how to do this with annotations in play. Currently this is not a container managed repo
        JPA.withTransaction(new F.Function0<Void>() {
            @Override
            public Void apply() throws Throwable {
                if (acHostModel.getId() != null) {
                    JPA.em().merge(acHostModel);
                }
                else {
                    AcHostModel.create(acHostModel);
                }
View Full Code Here

    private void init(String baseUrl) throws URISyntaxException {
        jwtAuthorizationGenerator = new JwtAuthorizationGenerator(jwtWriterFactory, 60 * 3);
        aUrl = baseUrl + "/foo";
        FakeApplication fakeApplication = Helpers.fakeApplication();
        Helpers.start(fakeApplication);
        acHost = new AcHostModel();
        acHost.sharedSecret = NOT_SO_SECRET_SECRET;
        acHost.baseUrl = baseUrl;

        when(jwtWriterFactory.macSigningWriter(any(SigningAlgorithm.class), anyString())).thenReturn(jwtWriter);

View Full Code Here


    @Before
    public void init() {
        acHostService = new AcHostServiceImpl(httpClient, acHostRepository);
        acHostModel = new AcHostModel();
        acHostModel.publicKey = TEST_PUBLIC_KEY;
        acHostModel.baseUrl = BASE_URL;

        when(httpClient.url(anyString(), any(AcHost.class), anyBoolean())).thenReturn(requestHolder);
        when(requestHolder.get()).thenReturn(Promise.pure(response));
View Full Code Here

        getAttributeAsText(remoteApp, "key");

        final String clientKey = getAttributeAsText(remoteApp, "clientKey");
        final String baseUrl = getAttributeAsText(remoteApp, "baseUrl");

        final AcHostModel acHost = AcHostModel.findByKey(clientKey)
                .orElse(new Supplier<Option<AcHostModel>>()
                {
                    @Override
                    public Option<AcHostModel> get()
                    {
                        return AcHostModel.findByUrl(baseUrl);
                    }
                })
                .getOrElse(new AcHostModel());

        acHost.key = clientKey;
        acHost.baseUrl = baseUrl;
        acHost.publicKey = getAttributeAsText(remoteApp, "publicKey");
        acHost.name = getAttributeAsText(remoteApp, "productType");
View Full Code Here

TOP

Related Classes of com.atlassian.connect.play.java.model.AcHostModel

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.