Package com.sun.jna.ptr

Examples of com.sun.jna.ptr.NativeLongByReference


    }

    static public /*synchronized*/ void initContext() throws ScardException {
  if (contextId == 0) {
            NativeLongByReference phContext = new NativeLongByReference();
            phContext.setValue(new NativeLong((long) 0));
            NativeLong status = nimpPcscDll.NimpSCardEstablishContext(SCARD_SCOPE_USER, Pointer.NULL, Pointer.NULL, phContext);
            Runtime.getRuntime().addShutdownHook(new Thread() {
                @Override
                public void run() {
                    if(0!=contextId)
                        nimpPcscDll.NimpSCardReleaseContext(new NativeLong(contextId));
                }
            });
            if (0 != status.longValue()) {
                throw new PcScException(status.intValue());
            }
      contextId = phContext.getValue().longValue();
  }
    }
View Full Code Here


        }
        return phContext.getValue().longValue();
    }*/

    static long SCardConnect(long contextId, String readerName, int shareMode, int preferredProtocols) throws PcScException {
        NativeLongByReference phCard = new NativeLongByReference();
        IntByReference pdwActiveProtocol = new IntByReference();
        NativeLong status = nimpPcscDll.NimpSCardConnectW(new NativeLong(contextId), new WString(readerName), shareMode, preferredProtocols,
                phCard,
                pdwActiveProtocol);
        if (SCARD_S_SUCCESS != status.longValue()) {
            throw new PcScException(status.intValue());
        }
        return phCard.getValue().longValue();
    }
View Full Code Here

        }
        return phCard.getValue().longValue();
    }

    static long SCardReconnect(long cardId, int shareMode, int preferredProtocols, int activationPolicy) throws PcScException {
        NativeLongByReference phCard = new NativeLongByReference();
        IntByReference pdwActiveProtocol = new IntByReference();
        NativeLong status = nimpPcscDll.NimpSCardReconnect(new NativeLong(cardId), shareMode, preferredProtocols,
                activationPolicy,
                pdwActiveProtocol);
        if (SCARD_S_SUCCESS != status.longValue()) {
            throw new PcScException(status.intValue());
        }
        return phCard.getValue().longValue();
    }
View Full Code Here

   *  Server name.
   * @return
   *  An array of domain trusts.
   */
  public static DomainTrust[] getDomainTrusts(String serverName) {
      NativeLongByReference domainCount = new NativeLongByReference();
      PDS_DOMAIN_TRUSTS.ByReference domains = new PDS_DOMAIN_TRUSTS.ByReference();
      int rc = Netapi32.INSTANCE.DsEnumerateDomainTrusts(
          serverName, new NativeLong(DsGetDC.DS_DOMAIN_VALID_FLAGS), domains, domainCount);
      if(W32Errors.NO_ERROR != rc) {
        throw new Win32Exception(rc);
      }
      try {
        int domainCountValue = domainCount.getValue().intValue();
        ArrayList<DomainTrust> trusts = new ArrayList<DomainTrust>(domainCountValue);
        for(DS_DOMAIN_TRUSTS trust : domains.getTrusts(domainCountValue)) {
          DomainTrust t = new DomainTrust();
          t.DnsDomainName = trust.DnsDomainName.toString();
          t.NetbiosDomainName = trust.NetbiosDomainName.toString();
View Full Code Here

        IntByReference iref = new IntByReference();
        lib.incrementInt32ByReference(iref);
        assertEquals("Int argument not modified", 1, iref.getValue());
    }
    public void testNativeLongByReference() {
        NativeLongByReference iref = new NativeLongByReference();
        lib.incrementNativeLongByReference(iref);
        assertEquals("Native long argument not modified",
                     new NativeLong(1), iref.getValue());
    }
View Full Code Here

   
    public void testDsEnumerateDomainTrusts() {
      if (Netapi32Util.getJoinStatus() != LMJoin.NETSETUP_JOIN_STATUS.NetSetupDomainName)
        return;

      NativeLongByReference domainCount = new NativeLongByReference();
      PDS_DOMAIN_TRUSTS.ByReference domains = new PDS_DOMAIN_TRUSTS.ByReference();
      assertEquals(W32Errors.NO_ERROR, Netapi32.INSTANCE.DsEnumerateDomainTrusts(
          null, new NativeLong(DsGetDC.DS_DOMAIN_VALID_FLAGS), domains, domainCount));
     
      assertTrue(domainCount.getValue().intValue() >= 0);
     
      DS_DOMAIN_TRUSTS[] trusts = domains.getTrusts(domainCount.getValue().intValue());
      for(DS_DOMAIN_TRUSTS trust : trusts) {
      assertTrue(trust.NetbiosDomainName.length() > 0);
      assertTrue(trust.DnsDomainName.length() > 0);
      assertTrue(Advapi32.INSTANCE.IsValidSid(trust.DomainSid));
      assertTrue(Advapi32Util.convertSidToStringSid(trust.DomainSid).startsWith("S-"));
View Full Code Here

          null, "Negotiate", new NativeLong(Sspi.SECPKG_CRED_OUTBOUND), null, null, null,
          null, phCredential, ptsExpiry));
      // initialize security context
      CtxtHandle phNewContext = new CtxtHandle();
      SecBufferDesc pbToken = new SecBufferDesc(Sspi.SECBUFFER_TOKEN, Sspi.MAX_TOKEN_SIZE);
      NativeLongByReference pfContextAttr = new NativeLongByReference();
      int rc = Secur32.INSTANCE.InitializeSecurityContext(phCredential, null,
          Advapi32Util.getUserName(), new NativeLong(Sspi.ISC_REQ_CONNECTION), new NativeLong(0),
          new NativeLong(Sspi.SECURITY_NATIVE_DREP), null, new NativeLong(0), phNewContext, pbToken,
          pfContextAttr, null);     
      assertTrue(rc == W32Errors.SEC_I_CONTINUE_NEEDED || rc == W32Errors.SEC_E_OK);
View Full Code Here

      assertEquals(W32Errors.SEC_E_OK, Secur32.INSTANCE.AcquireCredentialsHandle(
          null, "Negotiate", new NativeLong(Sspi.SECPKG_CRED_OUTBOUND), null, null, null,
          null, phClientCredential, ptsClientExpiry));
      // client ----------- security context
      CtxtHandle phClientContext = new CtxtHandle();
      NativeLongByReference pfClientContextAttr = new NativeLongByReference();
    // server ----------- acquire inbound credential handle
      CredHandle phServerCredential = new CredHandle();
      TimeStamp ptsServerExpiry = new TimeStamp();
      assertEquals(W32Errors.SEC_E_OK, Secur32.INSTANCE.AcquireCredentialsHandle(
          null, "Negotiate", new NativeLong(Sspi.SECPKG_CRED_INBOUND), null, null, null,
          null, phServerCredential, ptsServerExpiry));
      // server ----------- security context
    CtxtHandle phServerContext = new CtxtHandle();
      SecBufferDesc pbServerToken = null;
      NativeLongByReference pfServerContextAttr = new NativeLongByReference();
      int clientRc = W32Errors.SEC_I_CONTINUE_NEEDED;
      int serverRc = W32Errors.SEC_I_CONTINUE_NEEDED;
      do {
          // client ----------- initialize security context, produce a client token
        // client token returned is always new
View Full Code Here

      assertEquals(W32Errors.SEC_E_OK, Secur32.INSTANCE.AcquireCredentialsHandle(
          null, "Negotiate", new NativeLong(Sspi.SECPKG_CRED_OUTBOUND), null, null, null,
          null, phClientCredential, ptsClientExpiry));
      // client ----------- security context
      CtxtHandle phClientContext = new CtxtHandle();
      NativeLongByReference pfClientContextAttr = new NativeLongByReference();
    // server ----------- acquire inbound credential handle
      CredHandle phServerCredential = new CredHandle();
      TimeStamp ptsServerExpiry = new TimeStamp();
      assertEquals(W32Errors.SEC_E_OK, Secur32.INSTANCE.AcquireCredentialsHandle(
          null, "Negotiate", new NativeLong(Sspi.SECPKG_CRED_INBOUND), null, null, null,
          null, phServerCredential, ptsServerExpiry));
      // server ----------- security context
    CtxtHandle phServerContext = new CtxtHandle();
      SecBufferDesc pbServerToken = null;
      NativeLongByReference pfServerContextAttr = new NativeLongByReference();
      int clientRc = W32Errors.SEC_I_CONTINUE_NEEDED;
      int serverRc = W32Errors.SEC_I_CONTINUE_NEEDED;
      do {
          // client ----------- initialize security context, produce a client token
        // client token returned is always new
View Full Code Here

      assertEquals(W32Errors.SEC_E_OK, Secur32.INSTANCE.AcquireCredentialsHandle(
          null, "Negotiate", new NativeLong(Sspi.SECPKG_CRED_OUTBOUND), null, null, null,
          null, phClientCredential, ptsClientExpiry));
      // client ----------- security context
      CtxtHandle phClientContext = new CtxtHandle();
      NativeLongByReference pfClientContextAttr = new NativeLongByReference();
    // server ----------- acquire inbound credential handle
      CredHandle phServerCredential = new CredHandle();
      TimeStamp ptsServerExpiry = new TimeStamp();
      assertEquals(W32Errors.SEC_E_OK, Secur32.INSTANCE.AcquireCredentialsHandle(
          null, "Negotiate", new NativeLong(Sspi.SECPKG_CRED_INBOUND), null, null, null,
          null, phServerCredential, ptsServerExpiry));
      // server ----------- security context
    CtxtHandle phServerContext = new CtxtHandle();
      SecBufferDesc pbServerToken = new SecBufferDesc(Sspi.SECBUFFER_TOKEN, Sspi.MAX_TOKEN_SIZE);
      NativeLongByReference pfServerContextAttr = new NativeLongByReference();
      int clientRc = W32Errors.SEC_I_CONTINUE_NEEDED;
      int serverRc = W32Errors.SEC_I_CONTINUE_NEEDED;
      do {
        // client token returned is always new
          SecBufferDesc pbClientToken = new SecBufferDesc(Sspi.SECBUFFER_TOKEN, Sspi.MAX_TOKEN_SIZE);
View Full Code Here

TOP

Related Classes of com.sun.jna.ptr.NativeLongByReference

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.