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);
}
}