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

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


  try {
  String[] parts = request.getRequestURI().toString().split("/");
    String member = Val.chkStr(request.getParameter("member"));
    String attempt = Val.chkStr(request.getParameter("attempt"));
    IdentityAdapter idAdapter = context.newIdentityAdapter();
    User user = new User();
    user.setDistinguishedName(member);
    idAdapter.readUserProfile(user);
    boolean isSelf = checkSelf(context,member);
    if((isSelf && attempt.equals("2")) || !isSelf){     
      if(parts.length > 0) {
        String groupIdentifier = URLDecoder.decode(parts[5].trim(),"UTF-8");
View Full Code Here


  try {
  String[] parts = request.getRequestURI().toString().split("/")
  String member = Val.chkStr(request.getParameter("member"));
    String attempt = Val.chkStr(request.getParameter("attempt"));
    IdentityAdapter idAdapter = context.newIdentityAdapter();
    User user = new User();
    user.setDistinguishedName(member);
    idAdapter.readUserProfile(user);
    if(parts.length > 0) {
    String groupIdentifier = URLDecoder.decode(parts[5].trim(),"UTF-8");
    if(!groupIdentifier.endsWith(groupDIT)){
        IdentityConfiguration idConfig = context.getIdentityConfiguration();  
View Full Code Here

  if(parts.length > 0) {
    String userIdentifier = URLDecoder.decode(parts[5].trim(),"UTF-8");
    if(userIdentifier.endsWith(userDIT)){ 
      String attempt = Val.chkStr(request.getParameter("attempt"));
        IdentityAdapter idAdapter = context.newIdentityAdapter();
        User user = new User();
        user.setDistinguishedName(userIdentifier);
        idAdapter.readUserProfile(user);   
        idAdapter.readUserGroups(user);
       
        boolean isSelf = checkSelf(context,userIdentifier);
        if((isSelf && attempt.equals("2")) || !isSelf){
View Full Code Here

* @param managedUserDn
* @return true if managed user is same as active user
*/
protected boolean checkSelf(RequestContext context,String managedUserDn){
  boolean isSelf = false;
  User user = context.getUser();
  if(user.getDistinguishedName().equals(managedUserDn)){
    isSelf = true;
  }
  return isSelf;
}
View Full Code Here

*/
protected 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

*/
protected User readUserProfile(RequestContext context,HttpServletRequest request)
    throws Exception {
 
  IdentityAdapter idAdapter = context.newIdentityAdapter();
  User user = new User();
  String[] parts = request.getRequestURI().toString().split("/");   
  String sEncoding = request.getCharacterEncoding();
    if ((sEncoding == null) || (sEncoding.trim().length() == 0)) {
       sEncoding = "UTF-8";
    }

  if(parts.length > 0) {
    String userIdentifier = Val.chkStr(URLDecoder.decode(parts[5].trim(),"UTF-8"));
    if(userIdentifier.endsWith(userDIT)){
      user.setDistinguishedName(userIdentifier);
      DistinguishedNameCredential dnCredential = new DistinguishedNameCredential();
      dnCredential.setDistinguishedName(userIdentifier);
      user.setCredentials(dnCredential);
    }else if(userIdentifier.length() > 0) {
      user.setCredentials(new UsernameCredential(userIdentifier));
    }
    ((LdapIdentityAdapter)idAdapter).populateUser(context, user);
    return user;
  }else{   
    throw new Exception("error")
View Full Code Here

      String msg = "An authorization policy was not configured.";
      throw new ConfigurationException(msg);
    }
   
    // check the user, ensure an authenticated user if required
    User user = context.getRequestContext().getUser();
    boolean userWasAuthenticated = false;
    if ((user != null) && user.getAuthenticationStatus().getWasAuthenticated()) {
      userWasAuthenticated = true;
    }
    if (operation.getAuthPolicy().getAuthenticationRequired() && !userWasAuthenticated) {
      throw new NotAuthorizedException("Not authorized.");
    }
   
    // determine the principals
    AsnPrincipals principals = null;
    boolean isWrite = false;
    if (action.equals(AsnAuthorizer.ACTION_CREATE)) {
      isWrite = true;
      principals = operation.getAuthPolicy().getCreatePrincipals();
      if (principals == null) {
        String msg = "Create principals were not configured.";
        throw new ConfigurationException(msg);
      }
     
    } else if (action.equals(AsnAuthorizer.ACTION_DELETE)) {
      isWrite = true;
      principals = operation.getAuthPolicy().getDeletePrincipals();
      if (principals == null) {
        String msg = "Delete principals were not configured.";
        throw new ConfigurationException(msg);
      }
     
    } else if (action.equals(AsnAuthorizer.ACTION_ENABLE) ||
               action.equals(AsnAuthorizer.ACTION_DISABLE)) {
      isWrite = true;
      principals = operation.getAuthPolicy().getEnableDisablePrincipals();
      if (principals == null) {
        String msg = "Enable/Disable principals were not configured.";
        throw new ConfigurationException(msg);
      }
     
    } else if (action.equals(AsnAuthorizer.ACTION_QUERY)) {
      principals = operation.getAuthPolicy().getQueryPrincipals();
      if (principals == null) {
        String msg = "Query principals were not configured.";
        throw new ConfigurationException(msg);
      }
     
    } else if (action.equals(AsnAuthorizer.ACTION_UPDATE)) {
      isWrite = true;
      principals = operation.getAuthPolicy().getQueryPrincipals();
      if (principals == null) {
        String msg = "Query principals were not configured.";
        throw new ConfigurationException(msg);
      }
    }
   
    // hard check to ensure an authenticated user for any modifications
    // (regardless of configuration)
    if (isWrite && !userWasAuthenticated) {
      throw new AsnInsufficientPrivilegeException();
    }
   
    // check "any user" user privilege
    if (principals.contains(AsnConstants.PRINCIPAL_ANY)) {
      return;
    }
   
    // check administrator privilege
    if (userWasAuthenticated) {
      if (principals.contains(AsnConstants.PRINCIPAL_ADMINISTRATOR)) {
        RoleSet roles = user.getAuthenticationStatus().getAuthenticatedRoles();
        if (roles.hasRole("gptAdministrator")) {
          return;
        }
      }
    }
   
    // check for ownership
    if (userWasAuthenticated && (assertion != null) && assertion.getWasReadFromIndex()) {
      if (principals.contains(AsnConstants.PRINCIPAL_OWNER)) {
        String asnUserKey = Val.chkStr(assertion.getUserPart().getKey());
        String userKey = Val.chkStr(user.getKey());
        if ((asnUserKey.length() > 0) && asnUserKey.equals(userKey)) {
          return;
        }
      }
    }
View Full Code Here

    if (policy == null) {
      return false;
    }
   
    // check the user, ensure an authenticated user if required
    User user = context.getRequestContext().getUser();
    boolean userWasAuthenticated = false;
    if ((user != null) && user.getAuthenticationStatus().getWasAuthenticated()) {
      userWasAuthenticated = true;
    }
    if (policy.getAuthenticationRequired() && !userWasAuthenticated) {
      return false;
    }
   
    // determine the write principals (creation or modification)
    AsnPrincipals principals = null;
    boolean isWrite = false;
    if (action.equals(AsnAuthorizer.ACTION_CREATE)) {
      isWrite = true;
      principals = policy.getCreatePrincipals();
    } else if (action.equals(AsnAuthorizer.ACTION_DELETE)) {
      isWrite = true;
      principals = policy.getDeletePrincipals();
      if (assertion == null) return false;
    } else if (action.equals(AsnAuthorizer.ACTION_DISABLE)) {
      isWrite = true;
      principals = policy.getEnableDisablePrincipals();
      if (assertion == null) return false;
      if (!assertion.getSystemPart().getEnabled()) return false;
    } else if (action.equals(AsnAuthorizer.ACTION_ENABLE)){
      isWrite = true;
      principals = policy.getEnableDisablePrincipals();
      if (assertion.getSystemPart().getEnabled()) return false;
      if (assertion == null) return false;
    } else if (action.equals(AsnAuthorizer.ACTION_QUERY)) {
      principals = policy.getQueryPrincipals();
    } else if (action.equals(AsnAuthorizer.ACTION_UPDATE)) {
      isWrite = true;
      principals = policy.getQueryPrincipals();
      if (assertion == null) return false;
      if (!assertion.getSystemPart().getEnabled()) return false;
    }
    if ((policy == null) || (principals == null)) {
      return false;
    }
   
    // hard check to ensure an authenticated user for any modifications
    // (regardless of configuration)
    if (isWrite && !userWasAuthenticated) {
      return false;
    }
   
    // check "any user" user privilege
    if (principals.contains(AsnConstants.PRINCIPAL_ANY)) {
      return true;
    }
   
    // check administrator privilege
    if (userWasAuthenticated) {
      if (principals.contains(AsnConstants.PRINCIPAL_ADMINISTRATOR)) {
        RoleSet roles = user.getAuthenticationStatus().getAuthenticatedRoles();
        if (roles.hasRole("gptAdministrator")) {
          return true;
        }
      }
    }
   
    // check for ownership
    if (userWasAuthenticated && (assertion != null) && assertion.getWasReadFromIndex()) {
      if (principals.contains(AsnConstants.PRINCIPAL_OWNER)) {
        String asnUserKey = Val.chkStr(assertion.getUserPart().getKey());
        String userKey = Val.chkStr(user.getKey());
        if ((asnUserKey.length() > 0) && asnUserKey.equals(userKey)) {
          return true;
        }
      }
    }
View Full Code Here

    throws NotAuthorizedException, AsnUnestablishedUserException {
   
    // initialize
    this.setWasUserEstablished(false);
    AsnOperation operation = context.getOperation();
    User user = context.getRequestContext().getUser();
   
    // establish the user part of the operation
    if (operation.getUserPart() == null) {
      operation.setUserPart(new AsnUserPart());
    }
    operation.getUserPart().setIPAddress(context.getRequestOptions().getIPAddress());
    AsnAuthPolicy authPolicy = operation.getAuthPolicy();
    if (authPolicy.getAuthenticationRequired()) {
      if ((user == null) || !user.getAuthenticationStatus().getWasAuthenticated()) {
        throw new NotAuthorizedException("Not authorized.");
      }
    }
    if ((user == null) || !user.getAuthenticationStatus().getWasAuthenticated()) {
      operation.getUserPart().setName(AsnConstants.ANONYMOUS_USERNAME);
      this.setWasUserEstablished(true);
    } else {
      String key = Val.chkStr(user.getKey());
      if (key.length() > 0) {
        operation.getUserPart().setKey(key);
        if (user.getLocalID() >= 0) {
          operation.getUserPart().setID(""+user.getLocalID());
          String name = Val.chkStr(user.getName());
          if (name.length() > 0) {
            operation.getUserPart().setName(name);
            this.setWasUserEstablished(true);
          }
        }
View Full Code Here

      LOGGER.finer("Checking resource URL: "+resourceUrl);
      RequestContext rc = null;
      String samlToken = null;
      try {
        rc = RequestContext.extract(request);
        User user = rc.getUser();
        IntegrationResponse resp = null;
        IntegrationContextFactory icf = new IntegrationContextFactory();
        if (icf.isIntegrationEnabled()) {
          IntegrationContext ic = icf.newIntegrationContext();
          if (ic != null) {
            resp = ic.checkUrl(resourceUrl,user,null,null,null);
         
            if ((resp != null) && resp.isLicensed()) {
              if ((user != null) && (user.getProfile() != null)) {
                if (user.getProfile().containsKey(SDI_SECURITY_TOKEN)) {
                  samlToken = ic.getBase64EncodedToken(user);
                }
              }
            }
           
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.