Package javax.naming

Examples of javax.naming.AuthenticationException


                } else {
                    clientIdentity = securityService.login(realmName, user, pass);
                }
                ClientSecurity.setIdentity(clientIdentity);
            } catch (LoginException e) {
                throw (AuthenticationException) new AuthenticationException("User could not be authenticated: " + user).initCause(e);
            }
        }
    }
View Full Code Here


                } else {
                    clientIdentity = securityService.login(realmName, user, pass);
                }
                ClientSecurity.setIdentity(clientIdentity);
            } catch (LoginException e) {
                throw (AuthenticationException) new AuthenticationException("User could not be authenticated: " + user).initCause(e);
            }
        }
    }
View Full Code Here

                } else {
                    identity = securityService.login(realmName, user, pass);
                }
                securityService.associate(identity);
            } catch (LoginException e) {
                throw (AuthenticationException) new AuthenticationException("User could not be authenticated: "+user).initCause(e);
            }
        }

        ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class);
        Context context = containerSystem.getJNDIContext();
View Full Code Here

        final AuthenticationResponse res;
        try {
            res = requestAuthorization(req);
        } catch (RemoteException e) {
            throw new AuthenticationException(e.getLocalizedMessage());
        }

        switch (res.getResponseCode()) {
            case ResponseCodes.AUTH_GRANTED:
                client = res.getIdentity();
                break;
            case ResponseCodes.AUTH_REDIRECT:
                client = res.getIdentity();
                server = res.getServer();
                break;
            case ResponseCodes.AUTH_DENIED:
                throw (AuthenticationException) new AuthenticationException("This principle is not authorized.").initCause(res.getDeniedCause());
        }
    }
View Full Code Here

                } else {
                    identity = securityService.login(realmName, user, pass);
                }
                securityService.associate(identity);
            } catch (final LoginException e) {
                throw (AuthenticationException) new AuthenticationException("User could not be authenticated: " + user).initCause(e);
            }
        }

        final ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class);
        Context context = containerSystem.getJNDIContext();
View Full Code Here

         LoginContext lc = new LoginContext(protocol, null, handler, conf);
         lc.login();
      }
      catch(LoginException e)
      {
         AuthenticationException ex = new AuthenticationException("Failed to login using protocol="+protocol);
         ex.setRootCause(e);
         throw ex;
      }

   }
View Full Code Here

      sTargetedGroupDN = upCredentials.getTargetedGroupDN();
    }

    // ensure an authenticated DN
    if (sAuthenticatedDN.length() == 0) {
      throw new AuthenticationException("Invalid credentials.");
    }
   
    // populate the authentication status and profile information
    user.setDistinguishedName(sAuthenticatedDN);
    populateUser(requestContext,user,sTargetedGroupDN);
   
    RoleSet roles = user.getAuthenticationStatus().getAuthenticatedRoles();
    if (roles.hasRole("gptForbiddenAccess")) {
      User activeUser = requestContext.getUser();
      if(activeUser.getAuthenticationStatus().getWasAuthenticated()){
        String activeUserDn = requestContext.getUser().getDistinguishedName();
        String managedUserDn = user.getDistinguishedName();
        if(activeUserDn.equals(managedUserDn)){
        throw new AuthenticationException("Forbidden");
        }
      }else{
        throw new AuthenticationException("Forbidden");
      }
    }
   
  } catch (AuthenticationException e) {
    user.getAuthenticationStatus().reset();
View Full Code Here

    env.put(Context.SECURITY_PROTOCOL,sSecurityProtocol);
  }
  if (sPrincipal.length() > 0) {
    env.put(Context.SECURITY_PRINCIPAL,sPrincipal);
  } else if (bForceCredentials) {
    throw new AuthenticationException("Invalid credentials.");
  }
  if (sPassword.length() > 0) {
    env.put(Context.SECURITY_CREDENTIALS,sPassword);
  } else if (bForceCredentials) {
    throw new AuthenticationException("Invalid credentials.");
  }
 
  // env.put(Context.REFERRAL,"follow");

  // make the initial directory context
View Full Code Here

  user.getAuthenticationStatus().reset();
  DirContext dirContext = getConnectedContext();
 
  // ensure an authenticated DN
  if (sAuthenticatedDN.length() == 0) {
    throw new AuthenticationException("Invalid credentials.");
  }
 
  // populate profile information
  user.setDistinguishedName(sAuthenticatedDN);
  user.setKey(user.getDistinguishedName());
  getQueryFunctions().readUserProfile(dirContext,user);
  user.setName(user.getProfile().getUsername());
 
  // read groups, set authenticated roles
  getQueryFunctions().readUserGroups(dirContext,user);
  Groups userGroups = user.getGroups();
  Roles configuredRoles = getConfiguration().getIdentityConfiguration().getConfiguredRoles();
  RoleSet authenticatedRoles = user.getAuthenticationStatus().getAuthenticatedRoles();
  for (Role role: configuredRoles.values()) {
    if (userGroups.containsKey(role.getDistinguishedName())) {
      authenticatedRoles.addAll(role.getFullRoleSet());
    }
  }
  user.getAuthenticationStatus().setWasAuthenticated(true);
 
  // ensure membership if a targeted metadata management group was specified
  if (targetedGroupDN.length() > 0) {
    if (!userGroups.containsKey(targetedGroupDN)) {
      user.getAuthenticationStatus().reset();
      throw new AuthenticationException("Invalid credentials, not a member of the supplied group.");
    }
  }
 
  // ensure a local reference for the user
  LocalDao localDao = new LocalDao(requestContext);
View Full Code Here

    // throw an exception if authentication failed
    if (bMultipleAuthenticated) {
      // more than one username/password match was found
      String sMsg = "Multiple LDAP credential matches were found for login: "+sUsername;
      LogUtil.getLogger().warning(sMsg);
      throw new AuthenticationException(sMsg);
    } else if (sAuthenticatedDN.length() == 0) {
      // no username/password match was found
      throw new AuthenticationException("Invalid credentials.");
    }
   
  } finally {
    credentials.setDistinguishedName(sAuthenticatedDN);
    if (client != null) client.close();
View Full Code Here

TOP

Related Classes of javax.naming.AuthenticationException

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.