Java Code Examples for sun.security.util.BitArray#get()

The following examples show how to use sun.security.util.BitArray#get() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ZeroMatrixImpl.java    From cs-review with MIT License 6 votes vote down vote up
@Override
public void setZero(int[][] matrix) {
    final BitArray rows = new BitArray(matrix.length);
    final BitArray cols = new BitArray(matrix[0].length);
    for (int i = 0; i < matrix.length; i++) {
        for (int j = 0; j < matrix[i].length; j++) {
            final int item = matrix[i][j];
            rows.set(i, rows.get(i) || item == 0);
            cols.set(j, cols.get(j) || item == 0);
        }
    }
    for (int i = 0; i < rows.length(); i++) {
        for (int j = 0; j < cols.length(); j++) {
            if (rows.get(i) || cols.get(j)) {
                matrix[i][j] = 0;
            }
        }
    }
}
 
Example 2
Source File: SpnegoReqFlags.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
void go() throws Exception {
    Context c = Context.fromJAAS("client");
    c.startAsClient(OneKDC.SERVER, GSSUtil.GSS_SPNEGO_MECH_OID);

    byte[] token = c.doAs(new Action() {
        @Override
        public byte[] run(Context me, byte[] input) throws Exception {
            me.x().requestCredDeleg(true);
            me.x().requestReplayDet(false);
            me.x().requestSequenceDet(false);
            return me.x().initSecContext(new byte[0], 0, 0);
        }
    }, null);

    DerValue d = new DerValue(token);   // GSSToken
    DerInputStream ins = d.data;        // OID + mech token
    d.data.getDerValue();               // skip OID
    d = d.data.getDerValue();           // NegTokenInit
    d = d.data.getDerValue();           // The SEQUENCE inside

    boolean found = false;

    // Go through all fields inside NegTokenInit. The reqFlags field
    // is optional. It's even not recommended in RFC 4178.
    while (d.data.available() > 0) {
        DerValue d2 = d.data.getDerValue();
        if (d2.isContextSpecific((byte)1)) {
            found = true;
            System.out.println("regFlags field located.");
            BitArray ba = d2.data.getUnalignedBitString();
            if (ba.length() != 7) {
                throw new Exception("reqFlags should contain 7 bits");
            }
            if (!ba.get(0)) {
                throw new Exception("delegFlag should be true");
            }
            if (ba.get(2) || ba.get(3)) {
                throw new Exception("replay/sequenceFlag should be false");
            }
        }
    }

    if (!found) {
        System.out.println("Warning: regFlags field not found, too new?");
    }
    c.dispose();
}
 
Example 3
Source File: SpnegoReqFlags.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
void go() throws Exception {
    Context c = Context.fromJAAS("client");
    c.startAsClient(OneKDC.SERVER, GSSUtil.GSS_SPNEGO_MECH_OID);

    byte[] token = c.doAs(new Action() {
        @Override
        public byte[] run(Context me, byte[] input) throws Exception {
            me.x().requestCredDeleg(true);
            me.x().requestReplayDet(false);
            me.x().requestSequenceDet(false);
            return me.x().initSecContext(new byte[0], 0, 0);
        }
    }, null);

    DerValue d = new DerValue(token);   // GSSToken
    DerInputStream ins = d.data;        // OID + mech token
    d.data.getDerValue();               // skip OID
    d = d.data.getDerValue();           // NegTokenInit
    d = d.data.getDerValue();           // The SEQUENCE inside

    boolean found = false;

    // Go through all fields inside NegTokenInit. The reqFlags field
    // is optional. It's even not recommended in RFC 4178.
    while (d.data.available() > 0) {
        DerValue d2 = d.data.getDerValue();
        if (d2.isContextSpecific((byte)1)) {
            found = true;
            System.out.println("regFlags field located.");
            BitArray ba = d2.data.getUnalignedBitString();
            if (ba.length() != 7) {
                throw new Exception("reqFlags should contain 7 bits");
            }
            if (!ba.get(0)) {
                throw new Exception("delegFlag should be true");
            }
            if (ba.get(2) || ba.get(3)) {
                throw new Exception("replay/sequenceFlag should be false");
            }
        }
    }

    if (!found) {
        System.out.println("Warning: regFlags field not found, too new?");
    }
    c.dispose();
}
 
Example 4
Source File: SpnegoReqFlags.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
void go() throws Exception {
    Context c = Context.fromJAAS("client");
    c.startAsClient(OneKDC.SERVER, GSSUtil.GSS_SPNEGO_MECH_OID);

    byte[] token = c.doAs(new Action() {
        @Override
        public byte[] run(Context me, byte[] input) throws Exception {
            me.x().requestCredDeleg(true);
            me.x().requestReplayDet(false);
            me.x().requestSequenceDet(false);
            return me.x().initSecContext(new byte[0], 0, 0);
        }
    }, null);

    DerValue d = new DerValue(token);   // GSSToken
    DerInputStream ins = d.data;        // OID + mech token
    d.data.getDerValue();               // skip OID
    d = d.data.getDerValue();           // NegTokenInit
    d = d.data.getDerValue();           // The SEQUENCE inside

    boolean found = false;

    // Go through all fields inside NegTokenInit. The reqFlags field
    // is optional. It's even not recommended in RFC 4178.
    while (d.data.available() > 0) {
        DerValue d2 = d.data.getDerValue();
        if (d2.isContextSpecific((byte)1)) {
            found = true;
            System.out.println("regFlags field located.");
            BitArray ba = d2.data.getUnalignedBitString();
            if (ba.length() != 7) {
                throw new Exception("reqFlags should contain 7 bits");
            }
            if (!ba.get(0)) {
                throw new Exception("delegFlag should be true");
            }
            if (ba.get(2) || ba.get(3)) {
                throw new Exception("replay/sequenceFlag should be false");
            }
        }
    }

    if (!found) {
        System.out.println("Warning: regFlags field not found, too new?");
    }
    c.dispose();
}
 
Example 5
Source File: SpnegoReqFlags.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
void go() throws Exception {
    Context c = Context.fromJAAS("client");
    c.startAsClient(OneKDC.SERVER, GSSUtil.GSS_SPNEGO_MECH_OID);

    byte[] token = c.doAs(new Action() {
        @Override
        public byte[] run(Context me, byte[] input) throws Exception {
            me.x().requestCredDeleg(true);
            me.x().requestReplayDet(false);
            me.x().requestSequenceDet(false);
            return me.x().initSecContext(new byte[0], 0, 0);
        }
    }, null);

    DerValue d = new DerValue(token);   // GSSToken
    DerInputStream ins = d.data;        // OID + mech token
    d.data.getDerValue();               // skip OID
    d = d.data.getDerValue();           // NegTokenInit
    d = d.data.getDerValue();           // The SEQUENCE inside

    boolean found = false;

    // Go through all fields inside NegTokenInit. The reqFlags field
    // is optional. It's even not recommended in RFC 4178.
    while (d.data.available() > 0) {
        DerValue d2 = d.data.getDerValue();
        if (d2.isContextSpecific((byte)1)) {
            found = true;
            System.out.println("regFlags field located.");
            BitArray ba = d2.data.getUnalignedBitString();
            if (ba.length() != 7) {
                throw new Exception("reqFlags should contain 7 bits");
            }
            if (!ba.get(0)) {
                throw new Exception("delegFlag should be true");
            }
            if (ba.get(2) || ba.get(3)) {
                throw new Exception("replay/sequenceFlag should be false");
            }
        }
    }

    if (!found) {
        System.out.println("Warning: regFlags field not found, too new?");
    }
    c.dispose();
}
 
Example 6
Source File: SpnegoReqFlags.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
void go() throws Exception {
    Context c = Context.fromJAAS("client");
    c.startAsClient(OneKDC.SERVER, GSSUtil.GSS_SPNEGO_MECH_OID);

    byte[] token = c.doAs(new Action() {
        @Override
        public byte[] run(Context me, byte[] input) throws Exception {
            me.x().requestCredDeleg(true);
            me.x().requestReplayDet(false);
            me.x().requestSequenceDet(false);
            return me.x().initSecContext(new byte[0], 0, 0);
        }
    }, null);

    DerValue d = new DerValue(token);   // GSSToken
    DerInputStream ins = d.data;        // OID + mech token
    d.data.getDerValue();               // skip OID
    d = d.data.getDerValue();           // NegTokenInit
    d = d.data.getDerValue();           // The SEQUENCE inside

    boolean found = false;

    // Go through all fields inside NegTokenInit. The reqFlags field
    // is optional. It's even not recommended in RFC 4178.
    while (d.data.available() > 0) {
        DerValue d2 = d.data.getDerValue();
        if (d2.isContextSpecific((byte)1)) {
            found = true;
            System.out.println("regFlags field located.");
            BitArray ba = d2.data.getUnalignedBitString();
            if (ba.length() != 7) {
                throw new Exception("reqFlags should contain 7 bits");
            }
            if (!ba.get(0)) {
                throw new Exception("delegFlag should be true");
            }
            if (ba.get(2) || ba.get(3)) {
                throw new Exception("replay/sequenceFlag should be false");
            }
        }
    }

    if (!found) {
        System.out.println("Warning: regFlags field not found, too new?");
    }
    c.dispose();
}
 
Example 7
Source File: SpnegoReqFlags.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
void go() throws Exception {
    Context c = Context.fromJAAS("client");
    c.startAsClient(OneKDC.SERVER, GSSUtil.GSS_SPNEGO_MECH_OID);

    byte[] token = c.doAs(new Action() {
        @Override
        public byte[] run(Context me, byte[] input) throws Exception {
            me.x().requestCredDeleg(true);
            me.x().requestReplayDet(false);
            me.x().requestSequenceDet(false);
            return me.x().initSecContext(new byte[0], 0, 0);
        }
    }, null);

    DerValue d = new DerValue(token);   // GSSToken
    DerInputStream ins = d.data;        // OID + mech token
    d.data.getDerValue();               // skip OID
    d = d.data.getDerValue();           // NegTokenInit
    d = d.data.getDerValue();           // The SEQUENCE inside

    boolean found = false;

    // Go through all fields inside NegTokenInit. The reqFlags field
    // is optional. It's even not recommended in RFC 4178.
    while (d.data.available() > 0) {
        DerValue d2 = d.data.getDerValue();
        if (d2.isContextSpecific((byte)1)) {
            found = true;
            System.out.println("regFlags field located.");
            BitArray ba = d2.data.getUnalignedBitString();
            if (ba.length() != 7) {
                throw new Exception("reqFlags should contain 7 bits");
            }
            if (!ba.get(0)) {
                throw new Exception("delegFlag should be true");
            }
            if (ba.get(2) || ba.get(3)) {
                throw new Exception("replay/sequenceFlag should be false");
            }
        }
    }

    if (!found) {
        System.out.println("Warning: regFlags field not found, too new?");
    }
    c.dispose();
}
 
Example 8
Source File: SpnegoReqFlags.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
void go() throws Exception {
    Context c = Context.fromJAAS("client");
    c.startAsClient(OneKDC.SERVER, GSSUtil.GSS_SPNEGO_MECH_OID);

    byte[] token = c.doAs(new Action() {
        @Override
        public byte[] run(Context me, byte[] input) throws Exception {
            me.x().requestCredDeleg(true);
            me.x().requestReplayDet(false);
            me.x().requestSequenceDet(false);
            return me.x().initSecContext(new byte[0], 0, 0);
        }
    }, null);

    DerValue d = new DerValue(token);   // GSSToken
    DerInputStream ins = d.data;        // OID + mech token
    d.data.getDerValue();               // skip OID
    d = d.data.getDerValue();           // NegTokenInit
    d = d.data.getDerValue();           // The SEQUENCE inside

    boolean found = false;

    // Go through all fields inside NegTokenInit. The reqFlags field
    // is optional. It's even not recommended in RFC 4178.
    while (d.data.available() > 0) {
        DerValue d2 = d.data.getDerValue();
        if (d2.isContextSpecific((byte)1)) {
            found = true;
            System.out.println("regFlags field located.");
            BitArray ba = d2.data.getUnalignedBitString();
            if (ba.length() != 7) {
                throw new Exception("reqFlags should contain 7 bits");
            }
            if (!ba.get(0)) {
                throw new Exception("delegFlag should be true");
            }
            if (ba.get(2) || ba.get(3)) {
                throw new Exception("replay/sequenceFlag should be false");
            }
        }
    }

    if (!found) {
        System.out.println("Warning: regFlags field not found, too new?");
    }
    c.dispose();
}
 
Example 9
Source File: SpnegoReqFlags.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
void go() throws Exception {
    Context c = Context.fromJAAS("client");
    c.startAsClient(OneKDC.SERVER, GSSUtil.GSS_SPNEGO_MECH_OID);

    byte[] token = c.doAs(new Action() {
        @Override
        public byte[] run(Context me, byte[] input) throws Exception {
            me.x().requestCredDeleg(true);
            me.x().requestReplayDet(false);
            me.x().requestSequenceDet(false);
            return me.x().initSecContext(new byte[0], 0, 0);
        }
    }, null);

    DerValue d = new DerValue(token);   // GSSToken
    DerInputStream ins = d.data;        // OID + mech token
    d.data.getDerValue();               // skip OID
    d = d.data.getDerValue();           // NegTokenInit
    d = d.data.getDerValue();           // The SEQUENCE inside

    boolean found = false;

    // Go through all fields inside NegTokenInit. The reqFlags field
    // is optional. It's even not recommended in RFC 4178.
    while (d.data.available() > 0) {
        DerValue d2 = d.data.getDerValue();
        if (d2.isContextSpecific((byte)1)) {
            found = true;
            System.out.println("regFlags field located.");
            BitArray ba = d2.data.getUnalignedBitString();
            if (ba.length() != 7) {
                throw new Exception("reqFlags should contain 7 bits");
            }
            if (!ba.get(0)) {
                throw new Exception("delegFlag should be true");
            }
            if (ba.get(2) || ba.get(3)) {
                throw new Exception("replay/sequenceFlag should be false");
            }
        }
    }

    if (!found) {
        System.out.println("Warning: regFlags field not found, too new?");
    }
    c.dispose();
}
 
Example 10
Source File: SpnegoReqFlags.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
void go() throws Exception {
    Context c = Context.fromJAAS("client");
    c.startAsClient(OneKDC.SERVER, GSSUtil.GSS_SPNEGO_MECH_OID);

    byte[] token = c.doAs(new Action() {
        @Override
        public byte[] run(Context me, byte[] input) throws Exception {
            me.x().requestCredDeleg(true);
            me.x().requestReplayDet(false);
            me.x().requestSequenceDet(false);
            return me.x().initSecContext(new byte[0], 0, 0);
        }
    }, null);

    DerValue d = new DerValue(token);   // GSSToken
    DerInputStream ins = d.data;        // OID + mech token
    d.data.getDerValue();               // skip OID
    d = d.data.getDerValue();           // NegTokenInit
    d = d.data.getDerValue();           // The SEQUENCE inside

    boolean found = false;

    // Go through all fields inside NegTokenInit. The reqFlags field
    // is optional. It's even not recommended in RFC 4178.
    while (d.data.available() > 0) {
        DerValue d2 = d.data.getDerValue();
        if (d2.isContextSpecific((byte)1)) {
            found = true;
            System.out.println("regFlags field located.");
            BitArray ba = d2.data.getUnalignedBitString();
            if (ba.length() != 7) {
                throw new Exception("reqFlags should contain 7 bits");
            }
            if (!ba.get(0)) {
                throw new Exception("delegFlag should be true");
            }
            if (ba.get(2) || ba.get(3)) {
                throw new Exception("replay/sequenceFlag should be false");
            }
        }
    }

    if (!found) {
        System.out.println("Warning: regFlags field not found, too new?");
    }
    c.dispose();
}
 
Example 11
Source File: SpnegoReqFlags.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
void go() throws Exception {
    Context c = Context.fromJAAS("client");
    c.startAsClient(OneKDC.SERVER, GSSUtil.GSS_SPNEGO_MECH_OID);

    byte[] token = c.doAs(new Action() {
        @Override
        public byte[] run(Context me, byte[] input) throws Exception {
            me.x().requestCredDeleg(true);
            me.x().requestReplayDet(false);
            me.x().requestSequenceDet(false);
            return me.x().initSecContext(new byte[0], 0, 0);
        }
    }, null);

    DerValue d = new DerValue(token);   // GSSToken
    DerInputStream ins = d.data;        // OID + mech token
    d.data.getDerValue();               // skip OID
    d = d.data.getDerValue();           // NegTokenInit
    d = d.data.getDerValue();           // The SEQUENCE inside

    boolean found = false;

    // Go through all fields inside NegTokenInit. The reqFlags field
    // is optional. It's even not recommended in RFC 4178.
    while (d.data.available() > 0) {
        DerValue d2 = d.data.getDerValue();
        if (d2.isContextSpecific((byte)1)) {
            found = true;
            System.out.println("regFlags field located.");
            BitArray ba = d2.data.getUnalignedBitString();
            if (ba.length() != 7) {
                throw new Exception("reqFlags should contain 7 bits");
            }
            if (!ba.get(0)) {
                throw new Exception("delegFlag should be true");
            }
            if (ba.get(2) || ba.get(3)) {
                throw new Exception("replay/sequenceFlag should be false");
            }
        }
    }

    if (!found) {
        System.out.println("Warning: regFlags field not found, too new?");
    }
    c.dispose();
}
 
Example 12
Source File: SpnegoReqFlags.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
void go() throws Exception {
    Context c = Context.fromJAAS("client");
    c.startAsClient(OneKDC.SERVER, GSSUtil.GSS_SPNEGO_MECH_OID);

    byte[] token = c.doAs(new Action() {
        @Override
        public byte[] run(Context me, byte[] input) throws Exception {
            me.x().requestCredDeleg(true);
            me.x().requestReplayDet(false);
            me.x().requestSequenceDet(false);
            return me.x().initSecContext(new byte[0], 0, 0);
        }
    }, null);

    DerValue d = new DerValue(token);   // GSSToken
    DerInputStream ins = d.data;        // OID + mech token
    d.data.getDerValue();               // skip OID
    d = d.data.getDerValue();           // NegTokenInit
    d = d.data.getDerValue();           // The SEQUENCE inside

    boolean found = false;

    // Go through all fields inside NegTokenInit. The reqFlags field
    // is optional. It's even not recommended in RFC 4178.
    while (d.data.available() > 0) {
        DerValue d2 = d.data.getDerValue();
        if (d2.isContextSpecific((byte)1)) {
            found = true;
            System.out.println("regFlags field located.");
            BitArray ba = d2.data.getUnalignedBitString();
            if (ba.length() != 7) {
                throw new Exception("reqFlags should contain 7 bits");
            }
            if (!ba.get(0)) {
                throw new Exception("delegFlag should be true");
            }
            if (ba.get(2) || ba.get(3)) {
                throw new Exception("replay/sequenceFlag should be false");
            }
        }
    }

    if (!found) {
        System.out.println("Warning: regFlags field not found, too new?");
    }
    c.dispose();
}
 
Example 13
Source File: SpnegoReqFlags.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
void go() throws Exception {
    Context c = Context.fromJAAS("client");
    c.startAsClient(OneKDC.SERVER, GSSUtil.GSS_SPNEGO_MECH_OID);

    byte[] token = c.doAs(new Action() {
        @Override
        public byte[] run(Context me, byte[] input) throws Exception {
            me.x().requestCredDeleg(true);
            me.x().requestReplayDet(false);
            me.x().requestSequenceDet(false);
            return me.x().initSecContext(new byte[0], 0, 0);
        }
    }, null);

    DerValue d = new DerValue(token);   // GSSToken
    DerInputStream ins = d.data;        // OID + mech token
    d.data.getDerValue();               // skip OID
    d = d.data.getDerValue();           // NegTokenInit
    d = d.data.getDerValue();           // The SEQUENCE inside

    boolean found = false;

    // Go through all fields inside NegTokenInit. The reqFlags field
    // is optional. It's even not recommended in RFC 4178.
    while (d.data.available() > 0) {
        DerValue d2 = d.data.getDerValue();
        if (d2.isContextSpecific((byte)1)) {
            found = true;
            System.out.println("regFlags field located.");
            BitArray ba = d2.data.getUnalignedBitString();
            if (ba.length() != 7) {
                throw new Exception("reqFlags should contain 7 bits");
            }
            if (!ba.get(0)) {
                throw new Exception("delegFlag should be true");
            }
            if (ba.get(2) || ba.get(3)) {
                throw new Exception("replay/sequenceFlag should be false");
            }
        }
    }

    if (!found) {
        System.out.println("Warning: regFlags field not found, too new?");
    }
    c.dispose();
}
 
Example 14
Source File: SpnegoReqFlags.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
void go() throws Exception {
    Context c = Context.fromJAAS("client");
    c.startAsClient(OneKDC.SERVER, GSSUtil.GSS_SPNEGO_MECH_OID);

    byte[] token = c.doAs(new Action() {
        @Override
        public byte[] run(Context me, byte[] input) throws Exception {
            me.x().requestCredDeleg(true);
            me.x().requestReplayDet(false);
            me.x().requestSequenceDet(false);
            return me.x().initSecContext(new byte[0], 0, 0);
        }
    }, null);

    DerValue d = new DerValue(token);   // GSSToken
    DerInputStream ins = d.data;        // OID + mech token
    d.data.getDerValue();               // skip OID
    d = d.data.getDerValue();           // NegTokenInit
    d = d.data.getDerValue();           // The SEQUENCE inside

    boolean found = false;

    // Go through all fields inside NegTokenInit. The reqFlags field
    // is optional. It's even not recommended in RFC 4178.
    while (d.data.available() > 0) {
        DerValue d2 = d.data.getDerValue();
        if (d2.isContextSpecific((byte)1)) {
            found = true;
            System.out.println("regFlags field located.");
            BitArray ba = d2.data.getUnalignedBitString();
            if (ba.length() != 7) {
                throw new Exception("reqFlags should contain 7 bits");
            }
            if (!ba.get(0)) {
                throw new Exception("delegFlag should be true");
            }
            if (ba.get(2) || ba.get(3)) {
                throw new Exception("replay/sequenceFlag should be false");
            }
        }
    }

    if (!found) {
        System.out.println("Warning: regFlags field not found, too new?");
    }
    c.dispose();
}