@Override
  public Account toEntityModel() {
    AccountImpl accountImpl = new AccountImpl();

    accountImpl.setMvccVersion(mvccVersion);
    accountImpl.setAccountId(accountId);
    accountImpl.setCompanyId(companyId);
    accountImpl.setUserId(userId);

    if (userName == null) {
      accountImpl.setUserName(StringPool.BLANK);
    } else {
      accountImpl.setUserName(userName);
    }

    if (createDate == Long.MIN_VALUE) {
      accountImpl.setCreateDate(null);
    } else {
      accountImpl.setCreateDate(new Date(createDate));
    }

    if (modifiedDate == Long.MIN_VALUE) {
      accountImpl.setModifiedDate(null);
    } else {
      accountImpl.setModifiedDate(new Date(modifiedDate));
    }

    accountImpl.setParentAccountId(parentAccountId);

    if (name == null) {
      accountImpl.setName(StringPool.BLANK);
    } else {
      accountImpl.setName(name);
    }

    if (legalName == null) {
      accountImpl.setLegalName(StringPool.BLANK);
    } else {
      accountImpl.setLegalName(legalName);
    }

    if (legalId == null) {
      accountImpl.setLegalId(StringPool.BLANK);
    } else {
      accountImpl.setLegalId(legalId);
    }

    if (legalType == null) {
      accountImpl.setLegalType(StringPool.BLANK);
    } else {
      accountImpl.setLegalType(legalType);
    }

    if (sicCode == null) {
      accountImpl.setSicCode(StringPool.BLANK);
    } else {
      accountImpl.setSicCode(sicCode);
    }

    if (tickerSymbol == null) {
      accountImpl.setTickerSymbol(StringPool.BLANK);
    } else {
      accountImpl.setTickerSymbol(tickerSymbol);
    }

    if (industry == null) {
      accountImpl.setIndustry(StringPool.BLANK);
    } else {
      accountImpl.setIndustry(industry);
    }

    if (type == null) {
      accountImpl.setType(StringPool.BLANK);
    } else {
      accountImpl.setType(type);
    }

    if (size == null) {
      accountImpl.setSize(StringPool.BLANK);
    } else {
      accountImpl.setSize(size);
    }

    accountImpl.resetOriginalValues();

    return accountImpl;
  }
  @Override
  public Object clone() {
    AccountImpl accountImpl = new AccountImpl();

    accountImpl.setAccountId(getAccountId());
    accountImpl.setCompanyId(getCompanyId());
    accountImpl.setUserId(getUserId());
    accountImpl.setUserName(getUserName());
    accountImpl.setCreateDate(getCreateDate());
    accountImpl.setModifiedDate(getModifiedDate());
    accountImpl.setParentAccountId(getParentAccountId());
    accountImpl.setName(getName());
    accountImpl.setLegalName(getLegalName());
    accountImpl.setLegalId(getLegalId());
    accountImpl.setLegalType(getLegalType());
    accountImpl.setSicCode(getSicCode());
    accountImpl.setTickerSymbol(getTickerSymbol());
    accountImpl.setIndustry(getIndustry());
    accountImpl.setType(getType());
    accountImpl.setSize(getSize());

    accountImpl.resetOriginalValues();

    return accountImpl;
  }
Ejemplo n.º 3
0
 /**
  * {@inheritDoc}
  *
  * @see com.cloudapp.api.CloudAppAccount#createAccount(java.lang.String, java.lang.String,
  *     boolean)
  */
 public CloudAppAccount createAccount(String email, String password, boolean acceptTOS)
     throws CloudAppException {
   return account.createAccount(email, password, acceptTOS);
 }
  // authentication response
  public Account verifyResponse(HttpServletRequest httpReq) throws ServletException {

    try {
      // extract the parameters from the authentication response
      // (which comes in as a HTTP request from the OpenID provider)
      ParameterList response = new ParameterList(httpReq.getParameterMap());

      // retrieve the previously stored discovery information
      DiscoveryInformation discovered =
          (DiscoveryInformation) httpReq.getSession().getAttribute("openid-disc");

      // extract the receiving URL from the HTTP request
      StringBuffer receivingURL = httpReq.getRequestURL();
      String queryString = httpReq.getQueryString();
      if (queryString != null && queryString.length() > 0)
        receivingURL.append("?").append(httpReq.getQueryString());

      // verify the response; ConsumerManager needs to be the same
      // (static) instance used to place the authentication request
      VerificationResult verification =
          manager.verify(receivingURL.toString(), response, discovered);

      // examine the verification result and extract the verified
      // identifier
      Identifier verified = verification.getVerifiedId();
      if (verified != null) {
        // success

        String accountName = AccountImpl.escape(verified.getIdentifier());
        AbstractAccount account = (AbstractAccount) OpenIDRealm.instance.getAccount(accountName);
        if (account == null) {
          Database db = OpenIDRealm.instance.getDatabase();
          org.exist.security.Subject currentSubject = db.getSubject();
          try {
            db.setSubject(db.getSecurityManager().getSystemSubject());

            // XXX: set OpenID group by default
            account =
                (AbstractAccount)
                    OpenIDRealm.instance.addAccount(
                        new UserAider(OpenIDRealm.instance.getId(), accountName));
          } finally {
            db.setSubject(currentSubject);
          }
        }

        org.exist.security.Subject principal = new SubjectAccreditedImpl(account, verified);

        AuthSuccess authSuccess = (AuthSuccess) verification.getAuthResponse();
        authSuccess.getExtensions();

        if (authSuccess.hasExtension(SRegMessage.OPENID_NS_SREG)) {
          MessageExtension ext = authSuccess.getExtension(SRegMessage.OPENID_NS_SREG);
          if (ext instanceof SRegResponse) {
            SRegResponse sregResp = (SRegResponse) ext;
            for (Iterator iter = sregResp.getAttributeNames().iterator(); iter.hasNext(); ) {
              String name = (String) iter.next();
              if (LOG.isDebugEnabled()) LOG.debug(name + " : " + sregResp.getParameterValue(name));
              principal.setMetadataValue(
                  AXSchemaType.valueOfNamespace(name), sregResp.getParameterValue(name));
            }
          }
        }
        if (authSuccess.hasExtension(AxMessage.OPENID_NS_AX)) {
          FetchResponse fetchResp =
              (FetchResponse) authSuccess.getExtension(AxMessage.OPENID_NS_AX);

          List aliases = fetchResp.getAttributeAliases();
          for (Iterator iter = aliases.iterator(); iter.hasNext(); ) {
            String alias = (String) iter.next();
            List values = fetchResp.getAttributeValues(alias);
            if (values.size() > 0) {
              if (LOG.isDebugEnabled()) LOG.debug(alias + " : " + values.get(0));
              principal.setMetadataValue(AXSchemaType.valueOfAlias(alias), (String) values.get(0));
            }
          }
        }
        // update metadata
        Database db = OpenIDRealm.instance.getDatabase();
        org.exist.security.Subject currentSubject = db.getSubject();
        try {
          db.setSubject(db.getSecurityManager().getSystemSubject());

          OpenIDRealm.instance.updateAccount(principal);
        } finally {
          db.setSubject(currentSubject);
        }

        OpenIDUtility.registerUser(principal);
        return principal;
      }
    } catch (OpenIDException e) {
      LOG.error(e);
    } catch (ConfigurationException e) {
      LOG.error(e);
    } catch (PermissionDeniedException e) {
      LOG.error(e);
    } catch (EXistException e) {
      LOG.error(e);
    }

    return null;
  }
Ejemplo n.º 5
0
 /**
  * {@inheritDoc}
  *
  * @see com.cloudapp.api.CloudAppAccount#setPassword(java.lang.String, java.lang.String)
  */
 public CloudAppAccount setPassword(String newPassword, String currentPassword)
     throws CloudAppException {
   return account.setPassword(newPassword, currentPassword);
 }
Ejemplo n.º 6
0
 /**
  * {@inheritDoc}
  *
  * @see com.cloudapp.api.CloudAppAccount#resetPassword(java.lang.String)
  */
 public void resetPassword(String email) throws CloudAppException {
   account.resetPassword(email);
 }
Ejemplo n.º 7
0
 /**
  * {@inheritDoc}
  *
  * @see com.cloudapp.api.CloudAppAccount#setEmail(java.lang.String, java.lang.String)
  */
 public CloudAppAccount setEmail(String newEmail, String currentPassword)
     throws CloudAppException {
   return account.setEmail(newEmail, currentPassword);
 }
Ejemplo n.º 8
0
 /**
  * {@inheritDoc}
  *
  * @see
  *     com.cloudapp.api.CloudAppAccount#setDefaultSecurity(com.cloudapp.api.CloudAppAccount.DefaultSecurity)
  */
 public CloudAppAccount setDefaultSecurity(DefaultSecurity security) throws CloudAppException {
   return account.setDefaultSecurity(security);
 }
Ejemplo n.º 9
0
 /**
  * {@inheritDoc}
  *
  * @see com.cloudapp.api.CloudAppAccount#getAccountStats()
  */
 public CloudAppAccountStats getAccountStats() throws CloudAppException {
   return account.getAccountStats();
 }
Ejemplo n.º 10
0
 /**
  * {@inheritDoc}
  *
  * @see com.cloudapp.api.CloudAppAccount#getAccountDetails()
  */
 public CloudAppAccount getAccountDetails() throws CloudAppException {
   return account.getAccountDetails();
 }
Ejemplo n.º 11
0
 /**
  * {@inheritDoc}
  *
  * @see com.cloudapp.api.CloudAppAccount#setCustomDomain(java.lang.String, java.lang.String)
  */
 public CloudAppAccount setCustomDomain(String domain, String domainHomePage)
     throws CloudAppException {
   return account.setCustomDomain(domain, domainHomePage);
 }