Tabnine Logo
UserSession.getEncryptedContentKey
Code IndexAdd Tabnine to your IDE (free)

How to use
getEncryptedContentKey
method
in
com.oberasoftware.jasdb.api.security.UserSession

Best Java code snippets using com.oberasoftware.jasdb.api.security.UserSession.getEncryptedContentKey (Showing top 5 results out of 315)

origin: oberasoftware/jasdb

private void checkToken(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, FilterChain filterChain) throws IOException, ServletException {
  try {
    String token = httpServletRequest.getHeader("oauth_token");
    String sessionId = httpServletRequest.getHeader("sessionid");
    LOG.debug("Token: {} for session: {}", token, sessionId);
    if(StringUtils.stringNotEmpty(token) && StringUtils.stringNotEmpty(sessionId)) {
      UserSession session = sessionManager.getSession(sessionId);
      if(session != null) {
        CryptoEngine cryptoEngine = CryptoFactory.getEngine();
        String expectedTokenHash = cryptoEngine.hash(sessionId, token);
        if (expectedTokenHash.equals(session.getAccessToken())) {
          httpServletRequest.setAttribute("session", new UserSessionImpl(sessionId, token, session.getEncryptedContentKey(), session.getUser()));
          filterChain.doFilter(httpServletRequest, httpServletResponse);
        } else {
          handleErrorResponse(httpServletResponse, UNAUTHORIZED_CODE, "Invalid token");
        }
      } else {
        handleErrorResponse(httpServletResponse, UNAUTHORIZED_CODE, "Invalid token");
      }
    } else {
      handleErrorResponse(httpServletResponse, UNAUTHORIZED_CODE, "No token");
    }
  } catch(JasDBStorageException e) {
    LOG.error("Unknown error happened when processing token", e);
    handleErrorResponse(httpServletResponse, 500, "Unknown error");
  }
}
origin: oberasoftware/jasdb

public SecureUserSession(UserSession userSession) {
  this.sessionId = userSession.getSessionId();
  this.user = userSession.getUser();
  this.encryptedContentKey = userSession.getEncryptedContentKey();
  try {
    CryptoEngine cryptoEngine = CryptoFactory.getEngine();
    accessTokenHash = cryptoEngine.hash(sessionId, userSession.getAccessToken());
  } catch(JasDBSecurityException e) {
    throw new RuntimeJasDBException("Unable to hash token", e);
  }
}
origin: oberasoftware/jasdb

@Override
public User addUser(UserSession currentSession, String userName, String allowedHost, String password) throws JasDBStorageException {
  authorize(currentSession, "/Users", AccessMode.WRITE);
  User currentUser = currentSession.getUser();
  CryptoEngine cryptoEngine = CryptoFactory.getEngine();
  String contentKey = cryptoEngine.decrypt(currentUser.getPasswordSalt(), currentSession.getAccessToken(), currentSession.getEncryptedContentKey());
  return credentialsProvider.addUser(userName, allowedHost, contentKey, password);
}
origin: oberasoftware/jasdb

private GrantObject decrypt(UserSession session, EncryptedGrants encryptedGrants) throws JasDBStorageException {
  CryptoEngine contentCryptoEngine = CryptoFactory.getEngine();
  String contentKey = contentCryptoEngine.decrypt(session.getUser().getPasswordSalt(), session.getAccessToken(), session.getEncryptedContentKey());
  CryptoEngine cryptoEngine = CryptoFactory.getEngine(encryptedGrants.getEncryptionEngine());
  String decryptedData = cryptoEngine.decrypt(encryptedGrants.getSalt(), contentKey, encryptedGrants.getEncryptedData());
  return GrantObjectMeta.fromEntity(SimpleEntity.fromJson(decryptedData));
}
origin: oberasoftware/jasdb

private EncryptedGrants encryptGrants(GrantObject grantObject, UserSession userSession) throws JasDBStorageException {
  CryptoEngine cryptoEngine = CryptoFactory.getEngine();
  String contentKey = CryptoFactory.getEngine().decrypt(userSession.getUser().getPasswordSalt(), userSession.getAccessToken(), userSession.getEncryptedContentKey());
  String salt = cryptoEngine.generateSalt();
  String unencryptedData = SimpleEntity.toJson(GrantObjectMeta.toEntity(grantObject));
  String encryptedData = cryptoEngine.encrypt(salt, contentKey, unencryptedData);
  return new EncryptedGrants(grantObject.getObjectName(), encryptedData, salt, cryptoEngine.getDescriptor());
}
com.oberasoftware.jasdb.api.securityUserSessiongetEncryptedContentKey

Popular methods of UserSession

  • getSessionId
  • getAccessToken
  • getUser

Popular in Java

  • Making http post requests using okhttp
  • compareTo (BigDecimal)
  • getContentResolver (Context)
  • requestLocationUpdates (LocationManager)
  • ResourceBundle (java.util)
    ResourceBundle is an abstract class which is the superclass of classes which provide Locale-specifi
  • Scanner (java.util)
    A parser that parses a text string of primitive types and strings with the help of regular expressio
  • Stack (java.util)
    Stack is a Last-In/First-Out(LIFO) data structure which represents a stack of objects. It enables u
  • TimerTask (java.util)
    The TimerTask class represents a task to run at a specified time. The task may be run once or repeat
  • JOptionPane (javax.swing)
  • Logger (org.slf4j)
    The org.slf4j.Logger interface is the main user entry point of SLF4J API. It is expected that loggin
  • Top PhpStorm plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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