Tabnine Logo
Principal
Code IndexAdd Tabnine to your IDE (free)

How to use
Principal
in
cn.dreampie.security

Best Java code snippets using cn.dreampie.security.Principal (Showing top 9 results out of 315)

origin: Dreampie/Resty

/**
 * @param client={"key":"xx","scopeIds":[xx,xx]}
 * @param response_type
 * @param state
 * @return
 */
@POST
public HttpResult getCode(Client client, String response_type, String state) {
 String redirectParam = "?key=" + client.get("key") + "&response_type=" + response_type + "&state=" + state;
 if (!response_type.equals("code")) {
  return new HttpResult(HttpStatus.FOUND, Maper.<String, String>of("location", Constant.oauthErrorUrl + redirectParam + "&error=response_type_not_match"));
 }
 Client oldClient = Client.DAO.findFirstBy("key=?", client.get("key"));
 if (oldClient == null) {
  return new HttpResult(HttpStatus.FOUND, Maper.<String, String>of("location", Constant.oauthErrorUrl + redirectParam + "&error=client_not_found"));
 } else {
  Set<Scope> scopes = new HashSet<Scope>();
  for (Scope scope : oldClient.getScopes()) {
   if (scope.<Integer>get("selected") == 1 || Arrays.asList(client.getScopeIds()).contains(scope.<Integer>get("id"))) {
    scopes.add(scope);
   }
  }
  Entity<?> user = Subject.getPrincipal().getModel();
  int userId = user.<Integer>get("id");
  Code code = new Code(UUID.randomUUID().toString().replaceAll("-", ""), oldClient.<Integer>get("id"), userId, Constant.oauthExpires, scopes);
  Authorizes.addCode(code);//cache code
  return new HttpResult(HttpStatus.FOUND, Maper.<String, String>of("location", oldClient.get("redirect_uri") + "?code=" + code.getCode() + "&state=" + state));
 }
}
origin: Dreampie/Resty

String salt = principal.getSalt();
if (salt != null && !salt.isEmpty()) {
 match = passwordService.match(password, principal.getPassword(), salt);
} else {
 match = passwordService.match(password, principal.getPassword());
origin: Dreampie/Resty

public static void logout() {
 //add cache
 Principal principal = getPrincipal();
 if (principal != null) {
  logger.debug("Session leave authentication " + principal.getUsername());
 }
 //清理用户
 clearPrincipal();
}
origin: Dreampie/Resty

/**
 * 判断是否有当前api权限
 *
 * @param httpMethod httpMethod
 * @param path       path
 * @return boolean
 */
public static boolean has(String httpMethod, String path) {
 String needCredential = need(httpMethod, path);
 if (needCredential != null) {
  Principal principal = getPrincipal();
  if (principal != null) {
   if (principal.hasCredential(needCredential)) {
    return true;
   }
  }
 } else {
  return true;
 }
 return false;
}
origin: Dreampie/Resty

/**
 * 权限
 *
 * @param httpMethod httpMethod
 * @param path       path
 */
public static void check(String httpMethod, String path) {
 String needCredential = need(httpMethod, path);
 logger.debug(httpMethod + " " + path + " need credential " + needCredential);
 if (needCredential != null) {
  Principal principal = getPrincipal();
  if (principal != null) {
   if (!principal.hasCredential(needCredential)) {
    throw new HttpException(HttpMessage.FORBIDDEN);
   }
  } else {
   throw new HttpException(HttpMessage.UNAUTHORIZED);
  }
 }
}
origin: cn.dreampie/resty-security

String salt = principal.getSalt();
if (salt != null && !salt.isEmpty()) {
 match = passwordService.match(password, principal.getPassword(), salt);
} else {
 match = passwordService.match(password, principal.getPassword());
origin: cn.dreampie/resty-security

/**
 * 判断是否有当前api权限
 *
 * @param httpMethod httpMethod
 * @param path       path
 * @return boolean
 */
public static boolean has(String httpMethod, String path) {
 String needCredential = need(httpMethod, path);
 if (needCredential != null) {
  Principal principal = getPrincipal();
  if (principal != null) {
   if (principal.hasCredential(needCredential)) {
    return true;
   }
  }
 } else {
  return true;
 }
 return false;
}
origin: cn.dreampie/resty-security

public static void logout() {
 //add cache
 Principal principal = getPrincipal();
 if (principal != null) {
  logger.debug("Session leave authentication " + principal.getUsername());
 }
 //清理用户
 clearPrincipal();
}
origin: cn.dreampie/resty-security

/**
 * 权限
 *
 * @param httpMethod httpMethod
 * @param path       path
 */
public static void check(String httpMethod, String path) {
 String needCredential = need(httpMethod, path);
 logger.debug(httpMethod + " " + path + " need credential " + needCredential);
 if (needCredential != null) {
  Principal principal = getPrincipal();
  if (principal != null) {
   if (!principal.hasCredential(needCredential)) {
    throw new HttpException(HttpMessage.FORBIDDEN);
   }
  } else {
   throw new HttpException(HttpMessage.UNAUTHORIZED);
  }
 }
}
cn.dreampie.securityPrincipal

Javadoc

Date: 1/30/13 Time: 6:30 PM

Most used methods

  • getModel
  • getPassword
  • getSalt
  • getUsername
  • hasCredential

Popular in Java

  • Reactive rest calls using spring rest template
  • setRequestProperty (URLConnection)
  • getResourceAsStream (ClassLoader)
  • runOnUiThread (Activity)
  • IOException (java.io)
    Signals a general, I/O-related error. Error details may be specified when calling the constructor, a
  • RandomAccessFile (java.io)
    Allows reading from and writing to a file in a random-access manner. This is different from the uni-
  • String (java.lang)
  • ConcurrentHashMap (java.util.concurrent)
    A plug-in replacement for JDK1.5 java.util.concurrent.ConcurrentHashMap. This version is based on or
  • JarFile (java.util.jar)
    JarFile is used to read jar entries and their associated data from jar files.
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • Top 25 Plugins for Webstorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now