Changeset 5972 for ComponentRegistry


Ignore:
Timestamp:
02/12/15 13:52:06 (9 years ago)
Author:
Twan Goosen
Message:

Added new GET method /authentication for retrieving current auth state

Location:
ComponentRegistry/branches/ComponentRegistry-2.0/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • ComponentRegistry/branches/ComponentRegistry-2.0/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/ComponentRegistryRestService.java

    r5939 r5972  
    1616import clarin.cmdi.componentregistry.impl.database.GroupService;
    1717import clarin.cmdi.componentregistry.impl.database.ValidationException;
     18import clarin.cmdi.componentregistry.model.AuthenticationInfo;
    1819import clarin.cmdi.componentregistry.model.BaseDescription;
    1920import clarin.cmdi.componentregistry.model.Comment;
     
    7071import javax.ws.rs.core.UriInfo;
    7172import javax.xml.bind.JAXBException;
     73import org.json.JSONException;
     74import org.json.JSONObject;
    7275
    7376import org.slf4j.Logger;
     
    19961999        }
    19972000    }
     2001
     2002    @GET
     2003    @Path("/authentication")
     2004    @Produces({MediaType.TEXT_XML, MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
     2005    @ApiOperation(value = "Information on the current authentication state")
     2006    public AuthenticationInfo getAuthenticationInformation() throws JSONException, AuthenticationRequiredException {
     2007        final Principal userPrincipal = security.getUserPrincipal();
     2008
     2009        if (userPrincipal == null) {
     2010            return new AuthenticationInfo(false);
     2011        } else {
     2012            return new AuthenticationInfo(getUserCredentials(userPrincipal));
     2013        }
     2014    }
    19982015}
Note: See TracChangeset for help on using the changeset viewer.