Package com.esri.gpt.framework.security.principal

Examples of com.esri.gpt.framework.security.principal.User


*/
private void checkRole(RequestContext context)
  throws NotAuthorizedException {
 
  // initialize
  User user = context.getUser();
  user.setKey(user.getKey());
  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


  private String getUserEmail(String userName) throws SQLException, IdentityException, CredentialsDeniedException, NamingException {
    if (emailCache.containsKey(userName)) {
      return emailCache.get(userName);
    } else {
      UsernameCredential unCredential = new UsernameCredential(userName);
      User user = new User();
      user.setCredentials(unCredential);
      idAdapter.authenticate(user);
      idAdapter.readUserProfile(user);

      String emailAddress = user.getProfile().getEmailAddress();

      emailCache.put(userName, emailAddress);

      return emailAddress;
    }
View Full Code Here

              if ((attrName != null) && (attrName.size() > 0)) {
                sName = Val.chkStr(attrName.get(0).toString());
              }
            }

              User user = new User();
              user.setDistinguishedName(sDN);
              user.setKey(user.getDistinguishedName());
              user.setName(sName);
              users.add(user);
          }
        }
      } catch (PartialResultException pre) {
        LogUtil.getLogger().finer(pre.toString());
View Full Code Here

* @return the active user profile attributes
*/
public UserAttributeMap getActiveUserAttributes() {
  if (_activeUserAttributes == null) {
    RequestContext rc = extractRequestContext();
    User user = rc.getUser();
    if (user.getAuthenticationStatus().getWasAuthenticated()) {
      _activeUserAttributes = new UserAttributeMap(user.getProfile());
     
      // attempt to reload the user's profile
      IdentityAdapter idAdapter = rc.newIdentityAdapter();
      User userUpdate = new User();
      userUpdate.setKey(user.getKey());
      userUpdate.setLocalID(user.getLocalID());
      userUpdate.setDistinguishedName(user.getDistinguishedName());
      userUpdate.setProfile(_activeUserAttributes);
      try {
        idAdapter.readUserProfile(userUpdate);
      } catch (Throwable t) {
        getLogger().log(Level.SEVERE,"Error reading user profile.",t);
      }
View Full Code Here

* @return the user associated with new registration requests
*/
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

   
    // initialize parameters, recover the password
    String sUsername = getRecoverPasswordCriteria().getUsername();
    String sEmail = getRecoverPasswordCriteria().getEmailAddress();
    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;
View Full Code Here

    // attempt to login if not single sign-on mode
    boolean bSingleSignOn = false;
    if (!bSingleSignOn) {
     
      // authenticate the user, add the successful login message
      User user = extractRequestContext().getUser();
      user.reset();
      user.setCredentials(getNewUser().getCredentials());
      idAdapter.authenticate(user);
      String[] args = new String[1];
      args[0] = user.getName();
      extractMessageBroker().addSuccessMessage("identity.login.success",args);
    } else {

      // navigate to login page if single sign-on mode
      setNavigationOutcome("catalog.identity.login");
View Full Code Here

  throws Exception {
  MessageBroker msgBroker = extractMessageBroker();
  try {
   
    // make a temp user to process the update in case of failure
    User user = extractRequestContext().getUser();
    User userUpdate = new User();
    userUpdate.setKey(user.getKey());
    userUpdate.setLocalID(user.getLocalID());
    userUpdate.setDistinguishedName(user.getDistinguishedName());
    userUpdate.setProfile(getActiveUserAttributes());
   
    // execute the update,
    // update the in memory profile for the active user
    // set the success message and navigation outcome
    IdentityAdapter idAdapter = context.newIdentityAdapter();
    idAdapter.updateUserProfile(userUpdate);
    user.setProfile(userUpdate.getProfile());
    msgBroker.addSuccessMessage("catalog.identity.myProfile.success");
    setNavigationOutcome(ResourceKeys.NAVIGATIONOUTCOME_HOME_DIRECT);
   
  } catch (EmailPolicyException e) {
    msgBroker.addErrorMessage("identity.profile.err.email");
View Full Code Here

*/
protected void authenticate(RequestContext context, Credentials credentials)
  throws CredentialsDeniedException, IdentityException, SQLException {
  getLogger().finer("Authenticating user...");
  IdentityAdapter idAdapter = context.newIdentityAdapter();
  User user = context.getUser();
  user.reset();
  user.setCredentials(credentials);
  try {
    idAdapter.authenticate(user);
  } catch(CredentialsDeniedException e) {
    if (credentials instanceof UsernamePasswordCredentials) {
      String sUser = ((UsernamePasswordCredentials)credentials).getUsername();
View Full Code Here

  if(parts.length == 0) {
    response.sendError(HttpServletResponse.SC_BAD_REQUEST, "{ \"error\":\"Invalid request.\"}");
    return;   
 
  else
    User user = readUserProfile(context,request);
      writeCharacterResponse(response,
      serializeUserAsJson(context,user),"UTF-8",mimeType+";charset=UTF-8");
  }

}
View Full Code Here

TOP

Related Classes of com.esri.gpt.framework.security.principal.User

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.