Example usage for javax.servlet.http HttpServletRequest getAttribute

List of usage examples for javax.servlet.http HttpServletRequest getAttribute

Introduction

In this page you can find the example usage for javax.servlet.http HttpServletRequest getAttribute.

Prototype

public Object getAttribute(String name);

Source Link

Document

Returns the value of the named attribute as an Object, or null if no attribute of the given name exists.

Usage

From source file:com.jsmartframework.web.manager.CsrfEncrypter.java

private static Cipher getDecryptCipher(HttpServletRequest request, String key) throws Exception {
    Cipher decryptCipher = (Cipher) request.getAttribute(REQUEST_CSRF_DECRYPT_CIPHER);
    if (decryptCipher == null) {
        decryptCipher = Cipher.getInstance("AES");
        SecretKey secretKey = new SecretKeySpec(key.getBytes("UTF8"), "AES");
        decryptCipher.init(Cipher.DECRYPT_MODE, secretKey);
        request.setAttribute(REQUEST_CSRF_DECRYPT_CIPHER, decryptCipher);
    }/*from  w  w  w.  j  ava2s.  c  o m*/
    return decryptCipher;
}

From source file:de.itsvs.cwtrpc.core.CwtRpcUtils.java

public static boolean isContentRead(HttpServletRequest request) {
    return (request.getAttribute(GWT_RPC_REQUEST_CONTENT_ATTR_NAME) != null);
}

From source file:de.itsvs.cwtrpc.core.CwtRpcUtils.java

public static boolean isRpcSessionInvalidationPolicySet(HttpServletRequest request) {
    return (request.getAttribute(RPC_SESSION_INVALIDATION_POLICY_ATTR_NAME) != null);
}

From source file:com.jsmartframework.web.manager.AuthEncrypter.java

private static Cipher getEncryptCipher(HttpServletRequest request, String key) throws Exception {
    Cipher encryptCipher = (Cipher) request.getAttribute(REQUEST_AUTH_ENCRYPT_CIPHER);
    if (encryptCipher == null) {
        encryptCipher = Cipher.getInstance("AES");
        SecretKey secretKey = new SecretKeySpec(key.getBytes("UTF8"), "AES");
        encryptCipher.init(Cipher.ENCRYPT_MODE, secretKey);
        request.setAttribute(REQUEST_AUTH_ENCRYPT_CIPHER, encryptCipher);
    }/*from  w  ww . ja  v  a2s  .  co m*/
    return encryptCipher;
}

From source file:com.jsmartframework.web.manager.AuthEncrypter.java

private static Cipher getDecryptCipher(HttpServletRequest request, String key) throws Exception {
    Cipher decryptCipher = (Cipher) request.getAttribute(REQUEST_AUTH_DECRYPT_CIPHER);
    if (decryptCipher == null) {
        decryptCipher = Cipher.getInstance("AES");
        SecretKey secretKey = new SecretKeySpec(key.getBytes("UTF8"), "AES");
        decryptCipher.init(Cipher.DECRYPT_MODE, secretKey);
        request.setAttribute(REQUEST_AUTH_DECRYPT_CIPHER, decryptCipher);
    }//from   w  w  w .  j a v a2s.c om
    return decryptCipher;
}

From source file:org.keycloak.example.CustomerDatabaseClient.java

public static IDToken getIDToken(HttpServletRequest req) {
    KeycloakSecurityContext session = (KeycloakSecurityContext) req
            .getAttribute(KeycloakSecurityContext.class.getName());
    return session.getIdToken();

}

From source file:com.vko.core.web.filter.InvocationUtils.java

public static Invocation getInvocation(HttpServletRequest request) {
    if (request == null) {
        return null;
    }//from   ww w.j  a v a2  s . c  o  m
    return (Invocation) request.getAttribute(CoreFilter.INVOCATION_KEY);
}

From source file:net.saga.sync.gameserver.portal.CreatePlayer.java

public static Player createPlayer(HttpServletRequest req) throws UnsupportedEncodingException {
    SkeletonKeySession session = (SkeletonKeySession) req.getAttribute(SkeletonKeySession.class.getName());

    HttpClient client = new HttpClientBuilder().trustStore(session.getMetadata().getTruststore())
            .hostnameVerification(HttpClientBuilder.HostnameVerificationPolicy.ANY).build();
    try {//from w  w  w .j a  v  a2  s  .com
        HttpPost post = new HttpPost("https://localhost:8443/gameserver-database/player");
        post.addHeader("Authorization", "Bearer " + session.getTokenString());
        post.setEntity(new StringEntity("{}"));
        try {
            HttpResponse response = client.execute(post);
            if (response.getStatusLine().getStatusCode() != 200) {
                throw new RuntimeException("" + response.getStatusLine().getStatusCode());
            }
            HttpEntity entity = response.getEntity();
            InputStream is = entity.getContent();
            try {
                return JsonSerialization.readValue(is, Player.class);
            } finally {
                is.close();
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    } finally {
        client.getConnectionManager().shutdown();
    }
}

From source file:com.jsmartframework.web.manager.TagEncrypter.java

private static Cipher getEncryptCipher(HttpServletRequest request) throws Exception {
    Cipher encryptCipher = (Cipher) request.getAttribute(REQUEST_TAG_ENCRYPT_CIPHER);
    if (encryptCipher == null) {
        encryptCipher = Cipher.getInstance("AES");
        encryptCipher.init(Cipher.ENCRYPT_MODE, secretKey);
        request.setAttribute(REQUEST_TAG_ENCRYPT_CIPHER, encryptCipher);
    }//from   w  ww.j  ava  2  s .  c  o  m
    return encryptCipher;
}

From source file:com.jsmartframework.web.manager.TagEncrypter.java

private static Cipher getDecryptCipher(HttpServletRequest request) throws Exception {
    Cipher decryptCipher = (Cipher) request.getAttribute(REQUEST_TAG_DECRYPT_CIPHER);
    if (decryptCipher == null) {
        decryptCipher = Cipher.getInstance("AES");
        decryptCipher.init(Cipher.DECRYPT_MODE, secretKey);
        request.setAttribute(REQUEST_TAG_DECRYPT_CIPHER, decryptCipher);
    }/*from  ww w .  j av a2 s.  c o  m*/
    return decryptCipher;
}