File: FixedMaskGen.java

package info (click to toggle)
jetty8 8.1.16-4
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 19,248 kB
  • ctags: 24,086
  • sloc: java: 202,954; xml: 10,804; sh: 1,125; jsp: 250; makefile: 49; sql: 35
file content (44 lines) | stat: -rw-r--r-- 1,374 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//
//  ========================================================================
//  Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
//  ------------------------------------------------------------------------
//  All rights reserved. This program and the accompanying materials
//  are made available under the terms of the Eclipse Public License v1.0
//  and Apache License v2.0 which accompanies this distribution.
//
//      The Eclipse Public License is available at
//      http://www.eclipse.org/legal/epl-v10.html
//
//      The Apache License v2.0 is available at
//      http://www.opensource.org/licenses/apache2.0.php
//
//  You may elect to redistribute this code under either of these licenses.
//  ========================================================================
//


package org.eclipse.jetty.websocket;


public class FixedMaskGen implements MaskGen
{
    private final byte[] _mask;

    public FixedMaskGen()
    {
        this(new byte[]{(byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff});
    }

    public FixedMaskGen(byte[] mask)
    {
        _mask=new byte[4];
        // Copy to avoid that external code keeps a reference
        // to the array parameter to modify masking on-the-fly
        System.arraycopy(mask, 0, _mask, 0, 4);
    }

    public void genMask(byte[] mask)
    {
        System.arraycopy(_mask, 0, mask, 0, 4);
    }
}