Package com.khs.sherpa.json.service

Examples of com.khs.sherpa.json.service.SessionTokenService


    }
    return this.invokeMethod(target, method)
  }
 
  protected void hasPermission(Class<?> target, String userid, String token) {
    SessionTokenService service = null;
    try {
      service = applicationContext.getManagedBean(SessionTokenService.class);
    } catch (NoSuchManagedBeanExcpetion e) {
      throw new SherpaRuntimeException(e);
    }
   
    // make sure Endpoint Authentication is turned on
    if((Boolean)applicationContext.getAttribute(ApplicationContext.SETTINGS_ENDPOINT_AUTH) == false) {
      return;
    }
   
    Endpoint endpoint = null;
    if(Enhancer.isEnhanced(target)) {
      endpoint = target.getSuperclass().getAnnotation(Endpoint.class);
    } else {
      endpoint = target.getAnnotation(Endpoint.class);
    }
   
    // make sure its authenicated
    if(endpoint.authenticated() && !service.isActive(userid, token).equals(SessionStatus.AUTHENTICATED)) {
      throw new SherpaPermissionExcpetion("User status [" + service.isActive(userid, token) + "]", service.isActive(userid, token).toString());
    }
  }
View Full Code Here


      throw new SherpaPermissionExcpetion("User status [" + service.isActive(userid, token) + "]", service.isActive(userid, token).toString());
    }
  }
 
  protected void hasPermission(Method method, String userid, String token) {
    SessionTokenService service = null;
    try {
      service = applicationContext.getManagedBean(SessionTokenService.class);
    } catch (NoSuchManagedBeanExcpetion e) {
      throw new SherpaRuntimeException(e);
    }

    if(method.isAnnotationPresent(DenyAll.class)) {
      throw new SherpaPermissionExcpetion("method ["+method.getName()+"] in class ["+method.getDeclaringClass().getCanonicalName()+"] has `@DenyAll` annotation", "DENY_ALL");
    }
   
    if(method.isAnnotationPresent(RolesAllowed.class)) {
      boolean fail = true;
      for(String role: method.getAnnotation(RolesAllowed.class).value()) {
        if(service.hasRole(userid, token, role)) {
          fail = false;
        }
      }
      if(fail) {
        throw new SherpaPermissionExcpetion("method ["+method.getName()+"] in class ["+method.getDeclaringClass().getCanonicalName()+"] has `@RolesAllowed` annotation", "DENY_ROLE" );
View Full Code Here

 
  protected Object processValid()  throws SherpaRuntimeException {
    String userid = request.getParameter("userid");
    String token = request.getParameter("token");
   
    SessionTokenService service = null;
    Map<String, Object> resp = new HashMap<String, Object>();
    try {
      service = applicationContext.getManagedBean(SessionTokenService.class);
    } catch (NoSuchManagedBeanExcpetion e) {
      throw new SherpaRuntimeException(e);
    }

    resp.put("userid", userid);
    resp.put("token", token);
    resp.put("status", service.isActive(userid, token));
    return resp;
   
  }
View Full Code Here

TOP

Related Classes of com.khs.sherpa.json.service.SessionTokenService

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.