Package org.dspace.app.cris.model.ws

Examples of org.dspace.app.cris.model.ws.User


        return clazz.isAssignableFrom(arg0);
    }

    public void validate(Object arg0, Errors arg1)
    {
        User ws = (User) arg0;

        if (ws.getTypeDef().equals(User.TYPENORMAL))
        {
            ValidationUtils.rejectIfEmptyOrWhitespace(arg1,
                    "normalAuth.username", "error.form.ws.username.mandatory",
                    "Username is mandatory");
            ValidationUtils.rejectIfEmptyOrWhitespace(arg1,
                    "normalAuth.password", "error.form.ws.password.mandatory",
                    "Password is mandatory");
        }
        else
        {
            ValidationUtils.rejectIfEmptyOrWhitespace(arg1,
                    "specialAuth.token", "error.form.ws.token.mandatory",
                    "Token is mandatory");
            ValidationUtils.rejectIfEmptyOrWhitespace(arg1,
                    "specialAuth.fromIP", "error.form.ws.fromip.mandatory",
                    "Single IP is mandatory");

            Long froms = null;
            Long tos = null;
            if (ws.getFromIP() != null && !ws.getFromIP().isEmpty())
            {
                if (!validator.isValidInet4Address(ws.getFromIP()))
                {
                    arg1.reject("specialAuth.fromIP", "from IP not well formed");
                }
                else
                {
                    try
                    {
                        froms = AddressUtils.ipToLong(InetAddress.getByName(ws.getFromIP()));
                    }
                    catch (UnknownHostException e)
                    {
                        arg1.reject("specialAuth.fromIP",
                                "Unknown host exception");
                    }
                }

                if (ws.getToIP() != null && !ws.getToIP().isEmpty())
                {
                    if (!validator.isValidInet4Address(ws.getToIP()))
                    {
                        arg1.reject("specialAuth.ToIP", "to IP not well formed");
                    }
                    else
                    {
                        try
                        {
                            tos = AddressUtils.ipToLong(InetAddress.getByName(ws.getToIP()));
                                   
                        }
                        catch (UnknownHostException e)
                        {
                            arg1.reject("specialAuth.toIP",
View Full Code Here


        String ipAddress = request.getRemoteAddr();

        String token = tokenExpression.valueOf(arg0);
        String type = typeExpression.valueOf(arg0);
        type = type.trim();
        User userWS = null;
        try
        {
            userWS = authenticationWS.authenticateToken(ipAddress, token);
        }
        catch (RuntimeException e)
        {
            throw new SOAPException(e.getMessage());
        }
        if (userWS == null)
        {
            throw new RuntimeException("User not found!");
        }

        if (!userWS.isEnabled())
        {
            throw new RuntimeException(
                    "User disabled! Please Contact Admnistrator");
        }
       
View Full Code Here

        String username = usernameExpression.valueOf(arg0);
        String password = passwordExpression.valueOf(arg0);
        String type = typeExpression.valueOf(arg0);
        type = type.trim();
        User userWS = null;
        try
        {
            userWS = authenticationWS.authenticateNormal(username, password);
        }
        catch (RuntimeException e)
        {
            throw new SOAPException(e.getMessage());
        }
        if (userWS == null)
        {
            throw new RuntimeException("User not found!");
        }

        if (!userWS.isEnabled())
        {
            throw new RuntimeException(
                    "User disabled! Please Contact Admnistrator");
        }
       
View Full Code Here

        {
            throw new AuthorizeException(
                    "Only system administrator can access to the functionality");
        }
       
        User userws = (User) super.formBackingObject(request);
        String id = request.getParameter("id");
        if(id!=null && !id.isEmpty()) {
            userws = applicationService.get(User.class, Integer.parseInt(id));
        }
       
        if (userws.getCriteria().isEmpty())
        {
            for (String criteria : objectTypes)
            {
                Criteria newCriteria = new Criteria();
                newCriteria.setCriteria(criteria);
                newCriteria.setFilter("");
                newCriteria.setEnabled(false);
                userws.getCriteria().add(newCriteria);
            }
        }       
        userws.setCriteria(LazyList.decorate(userws.getCriteria(),
                FactoryUtils.instantiateFactory(Criteria.class)));
        return userws;
    }
View Full Code Here

    @Override
    protected ModelAndView onSubmit(HttpServletRequest request,
            HttpServletResponse response, Object command, BindException errors)
            throws Exception
    {
        User object = (User) command;
        applicationService.saveOrUpdate(User.class, object);
        return new ModelAndView(getSuccessView());
    }
View Full Code Here

    private ApplicationService applicationService;

    public User authenticateToken(String ipAddress, String token)
            throws RuntimeException
    {
        User userWS = applicationService.getUserWSByToken(token);
        try
        {
            if (!AddressUtils.checkIsInPattern(userWS.getFromIP(), ipAddress) ||
                    (userWS.getToIP() != null && !AddressUtils.checkIsInRange(userWS.getFromIP(),
                    userWS.getToIP(), ipAddress)))
            {
                throw new RuntimeException(
                        "Invalid token/IP");
            }
        }
View Full Code Here

    }

    public User authenticateNormal(String username, String password)
    {
        User userWS = applicationService.getUserWSByUsernameAndPassword(
                username, password);
        return userWS;
    }
View Full Code Here

       
    protected ModelAndView handleDetails(HttpServletRequest request) {
       
        Map<String, Object> model = new HashMap<String, Object>();
        String id = request.getParameter("id");       
        User user = applicationService.get(User.class, id);      
                       
        model.put("user", user);               
        return new ModelAndView(getDetailsView(), model);

    }
View Full Code Here

TOP

Related Classes of org.dspace.app.cris.model.ws.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.