1 /******************************************************************************* 2 * Copyright (c) 2011 Intalio, Inc. 3 * ====================================================================== 4 * All rights reserved. This program and the accompanying materials 5 * are made available under the terms of the Eclipse Public License v1.0 6 * and Apache License v2.0 which accompanies this distribution. 7 * 8 * The Eclipse Public License is available at 9 * http://www.eclipse.org/legal/epl-v10.html 10 * 11 * The Apache License v2.0 is available at 12 * http://www.opensource.org/licenses/apache2.0.php 13 * 14 * You may elect to redistribute this code under either of these licenses. 15 *******************************************************************************/ 16 package org.eclipse.jetty.websocket; 17 18 19 public class FixedMaskGen implements MaskGen 20 { 21 private final byte[] _mask; 22 23 public FixedMaskGen() 24 { 25 this(new byte[]{(byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff}); 26 } 27 28 public FixedMaskGen(byte[] mask) 29 { 30 _mask=new byte[4]; 31 // Copy to avoid that external code keeps a reference 32 // to the array parameter to modify masking on-the-fly 33 System.arraycopy(mask, 0, _mask, 0, 4); 34 } 35 36 public void genMask(byte[] mask) 37 { 38 System.arraycopy(_mask, 0, mask, 0, 4); 39 } 40 }