Package org.martinlaw.auth

Examples of org.martinlaw.auth.OpenidActivation


    public String activate(@RequestParam("token") String token, HttpServletRequest request, HttpServletResponse response) throws IOException {
    HttpSession session = request.getSession();
    if (token == null) {
      session.setAttribute(MartinlawConstants.OPENID_ACTIVATION_MESSAGE, TOKEN_NOT_FOUND);
    } else {
      OpenidActivation activation = getBusinessObjectService().findBySinglePrimaryKey(OpenidActivation.class, token);
      if (activation == null) {
        session.setAttribute(MartinlawConstants.OPENID_ACTIVATION_MESSAGE, INVALID_TOKEN);
      } else if (activation.getActivated() == null)  {
        EntityExternalIdentifierBo idBo = new EntityExternalIdentifierBo();
        idBo.setEntityId(activation.getEntityId());
        idBo.setExternalIdentifierTypeCode(MartinlawConstants.OPENID_TYPE_CODE);
        idBo.setExternalId(activation.getOpenid());
        getIdentityService().addExternalIdentifierToEntity(EntityExternalIdentifierBo.to(idBo));
       
        session.setAttribute(MartinlawConstants.OPENID_ACTIVATION_MESSAGE, ACTIVATION_SUCCESS);
        activation.setActivated(new Timestamp(System.currentTimeMillis()));
        getBusinessObjectService().save(activation);
      } else {
        session.setAttribute(MartinlawConstants.OPENID_ACTIVATION_MESSAGE, ACCOUNT_ALREADY_ACTIVATED);
      }
    }
View Full Code Here


   */
  @Test
  public void testActivate_success() throws IOException {
    final String token = "invalid-token";
    // simulate finding an activation with the token provided
    OpenidActivation activation = new OpenidActivation();
    when(boSvc.findBySinglePrimaryKey(OpenidActivation.class, token)).thenReturn(activation);
   
    activationController.activate(token, request, null);
   
    verify(idSvc).addExternalIdentifierToEntity(any(EntityExternalIdentifier.class));
View Full Code Here

   */
  @Test
  public void testActivate_already_activated() throws IOException {
    final String token = "invalid-token";
    // simulate finding an activated activation with the token provided
    OpenidActivation activation = new OpenidActivation();
    activation.setActivated(new Timestamp(System.currentTimeMillis()));
    when(boSvc.findBySinglePrimaryKey(OpenidActivation.class, token)).thenReturn(activation);
   
    activationController.activate(token, request, null);

    verify(session).setAttribute(
View Full Code Here

TOP

Related Classes of org.martinlaw.auth.OpenidActivation

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.