Package com.esri.gpt.framework.security.credentials

Examples of com.esri.gpt.framework.security.credentials.UsernamePasswordCredentials


* Checks if manage user role is enabled
* @return manageUser enabled if true
*/
public boolean isManageUser() {
  RequestContext rc = getContextBroker().extractRequestContext();
  UsernamePasswordCredentials upc = rc.getIdentityConfiguration().getSimpleConfiguration().getServiceAccountCredentials();
  if(upc !=null) return _manageUser;
 
  StringAttributeMap sNavParameters = rc.getCatalogConfiguration().getParameters();
  if(sNavParameters.containsKey("ldap.identity.manage.userRoleEnabled")){ 
    String hasManageUser = Val.chkStr(sNavParameters.getValue("ldap.identity.manage.userRoleEnabled"));
View Full Code Here


  user.setLocalID(user.getLocalID());
  user.setDistinguishedName(user.getDistinguishedName());
  user.setName(user.getName());
 
  // establish credentials
  UsernamePasswordCredentials creds = new UsernamePasswordCredentials();
  creds.setUsername(user.getName());
  user.setCredentials(creds);
 
  user.setAuthenticationStatus(user.getAuthenticationStatus())
  assertAdministratorRole(user);
}
View Full Code Here

        } catch (Exception e) {
          this.getLogger().log(Level.SEVERE,
              "The simple account password failed to decrypt.", e);
        }
      }
      UsernamePasswordCredentials creds = new UsernamePasswordCredentials( sUser, sPwd);
      creds.setDistinguishedName(sDN);
      idConfig.setCatalogAdminDN(creds.getDistinguishedName());
      idConfig.getSimpleConfiguration().setServiceAccountCredentials(creds);
    }

    // roles
    Node ndRoles = (Node) xpath.evaluate("roles", ndSimple, XPathConstants.NODE);
    if (ndRoles != null) {
      Roles roles = idConfig.getConfiguredRoles();
      NodeList nlRoles = (NodeList) xpath.evaluate("role", ndRoles, XPathConstants.NODESET);
      for (int i = 0; i < nlRoles.getLength(); i++) {
        Node ndRole = nlRoles.item(i);
        Role role = new Role();
        role.setKey(xpath.evaluate("@key", ndRole));
        roles.add(role);
      }
      for (Role role : roles.values()) {
        role.buildFullRoleSet(roles);
      }
    }

  }

  // LDAP adapter configuration
  if (ndLdap != null) {

    // connection properties & service account
    Node ndCon = (Node) xpath.evaluate("ldapConnectionProperties", ndLdap,
        XPathConstants.NODE);
    if (ndCon != null) {
      LdapConnectionProperties props = ldapConfig.getConnectionProperties();
      props.setProviderUrl(xpath.evaluate("@providerURL", ndCon));
      props.setInitialContextFactoryName(xpath.evaluate(
          "@initialContextFactoryName", ndCon));
      props.setSecurityAuthenticationLevel(xpath.evaluate(
          "@securityAuthentication", ndCon));
      props.setSecurityProtocol(xpath.evaluate("@securityProtocol", ndCon));

      Node ndService = (Node) xpath.evaluate("ldapServiceAccount", ndCon, XPathConstants.NODE);
      if (ndService != null) {
        String sUser = xpath.evaluate("@securityPrincipal", ndService);
        String sPwd = xpath.evaluate("@securityCredentials", ndService);
        boolean bEncrypted = Val.chkBool(xpath.evaluate("@encrypted", ndService), false);
        if (bEncrypted) {
          try {
            String sDecrypted = PC1_Encryptor.decrypt(sPwd);
            sPwd = sDecrypted;
          } catch (Exception e) {
            this.getLogger().log(Level.SEVERE, "The securityCredentials failed to decrypt.", e);
          }
        }
        UsernamePasswordCredentials creds = new UsernamePasswordCredentials(sUser, sPwd);
        props.setServiceAccountCredentials(creds);
        idConfig.setCatalogAdminDN(xpath.evaluate("@catalogAdminDN", ndService));
      }
    }
View Full Code Here

/**
* Creates instance of the request.
*/
public HarvestRequest() {
  setCredentials(new UsernamePasswordCredentials());
}
View Full Code Here

* Creates instance of the request.
* @param credentials credentials for accessing service
*/
public HarvestRequest(UsernamePasswordCredentials credentials) {
  setCredentials(
    credentials!=null? credentials: new UsernamePasswordCredentials());
}
View Full Code Here

* @param credentials the credentials
*/
public void setServiceAccountCredentials(UsernamePasswordCredentials credentials) {
  _serviceAccountCredentials = credentials;
  if (_serviceAccountCredentials == null) {
    _serviceAccountCredentials = new UsernamePasswordCredentials();
  }
}
View Full Code Here

*/
public String toString() {
  StringBuffer sb = new StringBuffer(getClass().getName()).append(" (\n");
  Credentials cred = getServiceAccountCredentials();
  if ((cred != null) && (cred instanceof UsernamePasswordCredentials)) {
    UsernamePasswordCredentials upCred = (UsernamePasswordCredentials)cred;
    int nPwdLen = 0;
    if (upCred.getPassword() != null) {
      nPwdLen = upCred.getPassword().length();
    }
    sb.append(" serviceAccount(");
    sb.append("securityPrincipal=\"").append(upCred.getUsername()).append("\"");
    sb.append(" securityCredentials=\"");
    for (int i=0;i<nPwdLen;i++) sb.append("*");
    sb.append("\")\n");
  }
  sb.append(") ===== end ").append(getClass().getName());
View Full Code Here

*/
public User getNewUser() {
  if (_newUser == null) {
    IdentityConfiguration idConfig = getIdentityConfiguration();
    _newUser = new User();
    _newUser.setCredentials(new UsernamePasswordCredentials());
    _newUser.setProfile(new UserAttributeMap(idConfig.getUserAttributeMap()));
  }
  return _newUser;
}
View Full Code Here

    IdentityAdapter idAdapter = context.newIdentityAdapter();
    User user = idAdapter.recoverPassword(getRecoverPasswordCriteria());
    if (user != null) {
     
      // get the new password
      UsernamePasswordCredentials upCred;
      upCred = user.getCredentials().getUsernamePasswordCredentials();
      String sPassword = upCred.getPassword();
     
      // send mail with the new password
      String[] args = new String[2];
      args[0] = sUsername;
      args[1] = sPassword;
View Full Code Here

* @throws IOException if an IO exception occurs
* @throws CredentialsDeniedException if empty or non-basic credentials were located
*/
protected UsernamePasswordCredentials getCredentials(HttpServletRequest request)
  throws IOException, CredentialsDeniedException {
  UsernamePasswordCredentials creds = null;
  String sAuthorization = request.getHeader("Authorization");
  getLogger().finer("Authorization header="+sAuthorization);
  if (sAuthorization != null) {
    creds = new UsernamePasswordCredentials();
    if (sAuthorization.startsWith("Basic ")) {
     
      // look for a Basic encoded username:password
      // (ignore Digest we can't handle it at the moment,
      //  requires password retrieval from LDAP)
      sAuthorization = sAuthorization.substring(6);
      if (sAuthorization.length() > 0) {
        String sDecoded = Base64.decode(sAuthorization,"UTF-8");
        int nIdx = sDecoded.indexOf(':');
        if (nIdx > 0) {
          creds.setUsername(sDecoded.substring(0,nIdx));
          creds.setPassword(sDecoded.substring(nIdx+1));
        }
      }
    }
    getLogger().finer("Authorization username="+creds.getUsername());
    if ((creds.getUsername().length() == 0) ||
        (creds.getPassword().length() == 0)) {
      throw new CredentialsDeniedException("Invalid credentials.");
    }
  }
  return creds;
}
View Full Code Here

TOP

Related Classes of com.esri.gpt.framework.security.credentials.UsernamePasswordCredentials

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.