Search in sources :

Example 6 with IndividualSignature

use of io.pivotal.cla.data.IndividualSignature in project pivotal-cla by pivotalsoftware.

the class IndividualSignatureRepositoryTests method findSignatureForMultipleSigned.

@Test
public void findSignatureForMultipleSigned() {
    IndividualSignature springSignature = createSignature(springCla, user);
    signatures.save(springSignature);
    assertThat(claService.findIndividualSignaturesFor(user, springCla.getName())).isNotNull();
}
Also used : IndividualSignature(io.pivotal.cla.data.IndividualSignature) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 7 with IndividualSignature

use of io.pivotal.cla.data.IndividualSignature in project pivotal-cla by pivotalsoftware.

the class OAuthController method oauth.

@RequestMapping("/login/oauth2/github")
public void oauth(ImportedSignaturesSessionAttr importedSignaturesAttr, HttpServletRequest request, HttpServletResponse response, @RequestParam String code, @RequestParam String state) throws Exception {
    String actualState = (String) request.getSession().getAttribute("state");
    if (actualState == null || !actualState.equals(state)) {
        throw new InvalidSecretState();
    }
    boolean admin = GitHubAuthenticationEntryPoint.isAdmin(state);
    OAuthAccessTokenParams params = new OAuthAccessTokenParams();
    params.setCallbackUrl(UrlBuilder.fromRequest(request).callbackUrl());
    params.setCode(code);
    params.setState(actualState);
    CurrentUserRequest userRequest = new CurrentUserRequest();
    userRequest.setOauthParams(params);
    userRequest.setRequestAdminAccess(admin);
    User user = gitHub.getCurrentUser(userRequest);
    User existingUser = users.findOne(user.getGitHubLogin());
    boolean isNewUser = existingUser == null;
    users.save(user);
    Authentication authentication = Login.loginAs(user);
    if (isNewUser) {
        List<IndividualSignature> individualSignatures = individual.findSignaturesFor(new PageRequest(0, 1), user);
        boolean signed = !individualSignatures.isEmpty();
        if (!signed) {
            List<String> organizations = gitHub.getOrganizations(user.getGitHubLogin());
            signed = !corporate.findSignatures(new PageRequest(0, 1), organizations, user.getEmails()).isEmpty();
        }
        if (signed) {
            importedSignaturesAttr.setValue(true);
        }
    }
    success.onAuthenticationSuccess(request, response, authentication);
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) User(io.pivotal.cla.data.User) Authentication(org.springframework.security.core.Authentication) CurrentUserRequest(io.pivotal.cla.service.github.CurrentUserRequest) OAuthAccessTokenParams(io.pivotal.cla.service.github.OAuthAccessTokenParams) IndividualSignature(io.pivotal.cla.data.IndividualSignature) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 8 with IndividualSignature

use of io.pivotal.cla.data.IndividualSignature in project pivotal-cla by pivotalsoftware.

the class IclaController method claForm.

@RequestMapping("/sign/{claName}/icla")
public String claForm(@AuthenticationPrincipal User user, @ModelAttribute SignClaForm signClaForm, Map<String, Object> model) {
    String claName = signClaForm.getClaName();
    IndividualSignature signed = claService.findIndividualSignaturesFor(user, claName);
    ContributorLicenseAgreement cla = signed == null ? clas.findByNameAndPrimaryTrue(claName) : signed.getCla();
    if (cla == null) {
        throw new ResourceNotFoundException();
    }
    if (cla.getSupersedingCla() != null) {
        cla = cla.getSupersedingCla();
    }
    signClaForm.setSigned(signed != null);
    signClaForm.setName(user.getName());
    signClaForm.setClaId(cla.getId());
    model.put("cla", cla);
    return "cla/icla/sign";
}
Also used : ContributorLicenseAgreement(io.pivotal.cla.data.ContributorLicenseAgreement) IndividualSignature(io.pivotal.cla.data.IndividualSignature) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 9 with IndividualSignature

use of io.pivotal.cla.data.IndividualSignature in project pivotal-cla by pivotalsoftware.

the class ClaService method findIndividualSignaturesFor.

public IndividualSignature findIndividualSignaturesFor(User user, String claName) {
    PageRequest pageable = new PageRequest(0, 1);
    List<IndividualSignature> results = individualSignatureRepository.findSignaturesFor(pageable, user, claName);
    return results.isEmpty() ? null : results.get(0);
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) IndividualSignature(io.pivotal.cla.data.IndividualSignature)

Aggregations

IndividualSignature (io.pivotal.cla.data.IndividualSignature)9 ContributorLicenseAgreement (io.pivotal.cla.data.ContributorLicenseAgreement)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 CorporateSignature (io.pivotal.cla.data.CorporateSignature)2 Date (java.util.Date)2 PageRequest (org.springframework.data.domain.PageRequest)2 MarkdownContent (io.pivotal.cla.data.MarkdownContent)1 User (io.pivotal.cla.data.User)1 ClaPullRequestStatusRequest (io.pivotal.cla.service.ClaPullRequestStatusRequest)1 CurrentUserRequest (io.pivotal.cla.service.github.CurrentUserRequest)1 OAuthAccessTokenParams (io.pivotal.cla.service.github.OAuthAccessTokenParams)1 Before (org.junit.Before)1 Test (org.junit.Test)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1 Authentication (org.springframework.security.core.Authentication)1