Search in sources :

Example 11 with OAuth2Definition

use of io.swagger.models.auth.OAuth2Definition in project ORCID-Source by ORCID.

the class MemberSwaggerResource method scan.

/**
     * Scan the classes and add in the OAuth information
     * 
     */
@Override
protected synchronized Swagger scan(Application app) {
    // tell swagger to pick up our jaxb annotations
    Json.mapper().registerModule(new JaxbAnnotationModule());
    Swagger s = super.scan(app);
    OAuth2Definition oauth = new OAuth2Definition();
    oauth.accessCode(this.authEndPoint, this.tokenEndPoint);
    oauth.scope(ScopePathType.READ_LIMITED.value(), "Read Limited record");
    oauth.scope(ScopePathType.PERSON_UPDATE.value(), "Update person");
    oauth.scope(ScopePathType.ACTIVITIES_UPDATE.value(), "Update activities");
    s.securityDefinition("orcid_auth", oauth);
    OAuth2Definition oauthTwoLegs = new OAuth2Definition();
    oauthTwoLegs.application(this.tokenEndPoint);
    oauthTwoLegs.scope(ScopePathType.PREMIUM_NOTIFICATION.value(), "Notifications");
    oauthTwoLegs.scope(ScopePathType.READ_PUBLIC.value(), "Read Public record");
    oauthTwoLegs.scope(ScopePathType.GROUP_ID_RECORD_READ.value(), "Read groups");
    oauthTwoLegs.scope(ScopePathType.GROUP_ID_RECORD_UPDATE.value(), "Update groups");
    s.securityDefinition("orcid_two_legs", oauthTwoLegs);
    return s;
}
Also used : JaxbAnnotationModule(com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule) Swagger(io.swagger.models.Swagger) OAuth2Definition(io.swagger.models.auth.OAuth2Definition)

Aggregations

OAuth2Definition (io.swagger.models.auth.OAuth2Definition)11 Test (org.testng.annotations.Test)9 Swagger (io.swagger.models.Swagger)3 JaxbAnnotationModule (com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule)2 Contact (io.swagger.models.Contact)1 Error (io.swagger.models.Error)1 Info (io.swagger.models.Info)1 Model (io.swagger.models.Model)1 Operation (io.swagger.models.Operation)1 Path (io.swagger.models.Path)1 Person (io.swagger.models.Person)1 Response (io.swagger.models.Response)1 SecurityRequirement (io.swagger.models.SecurityRequirement)1 PathParameter (io.swagger.models.parameters.PathParameter)1 QueryParameter (io.swagger.models.parameters.QueryParameter)1 LongProperty (io.swagger.models.properties.LongProperty)1 RefProperty (io.swagger.models.properties.RefProperty)1 StringProperty (io.swagger.models.properties.StringProperty)1