Get any bound DT or create a new one.

@return a delegation token.
@throws IOException if one cannot be created
189740
@SuppressWarnings("OptionalGetWithoutIsPresent")
  public Token<DelegationTokenIdentifier> getBoundOrNewDT(String renewer) throws IOException {
    logger.atFine().log("Delegation token requested");
    if (isBoundToDT()) {
      // the FS was created on startup with a token, so return it.
      logger.atFine().log("Returning current token");
      return getBoundDT();
    }

    // not bound to a token, so create a new one.
    // issued DTs are not cached so that long-lived filesystems can
    // reliably issue session/role tokens.
    return tokenBinding.createDelegationToken(renewer);
  }
896697
public K getSavedId() {
        if (dbObjects.length == 0) {
            throw new MongoException("No objects to return");
        }
        if (dbObjects[0] instanceof JacksonDBObject) {
            throw new UnsupportedOperationException("Generated _id retrieval not supported when using stream serialization");
        }
        return jacksonDBCollection.convertFromDbId(dbObjects[0].get("_id"));
    }
399719
@ManyToOne(targetEntity = org.openprovenance.prov.sql.QualifiedName.class, cascade = {
        CascadeType.ALL
    })
    @JoinColumn(name = "DELEGATE")
    public org.openprovenance.prov.model.QualifiedName getDelegate() {
        return delegate;
    }
979492
public String getDelegationToken(String owner, String renewer) throws HiveSQLException {
    if (saslServer == null) {
      throw new HiveSQLException(
          "Delegation token only supported over kerberos authentication", "08S01");
    }

    try {
      String tokenStr = saslServer.getDelegationTokenWithService(owner, renewer, HS2_CLIENT_TOKEN);
      if (tokenStr == null || tokenStr.isEmpty()) {
        throw new HiveSQLException(
            "Received empty retrieving delegation token for user " + owner, "08S01");
      }
      return tokenStr;
    } catch (IOException e) {
      throw new HiveSQLException(
          "Error retrieving delegation token for user " + owner, "08S01", e);
    } catch (InterruptedException e) {
      throw new HiveSQLException("delegation token retrieval interrupted", "08S01", e);
    }
  }
442409
public X509Certificate createCertificate(InputStream certRequestInputStream, X509Certificate cert,
        PrivateKey privateKey, int lifetime, int delegationMode, X509ExtensionSet extSet) throws IOException,
        GeneralSecurityException {
        return createCertificate(certRequestInputStream, cert, privateKey, lifetime, delegationMode, extSet, null);
    }
593972
private void visit_OP_GET_DELEGATION_TOKEN() throws IOException {
    visitTxId();
    
    v.visitByte(EditsElement.T_VERSION);
    v.visitStringText(EditsElement.T_OWNER);
    v.visitStringText(EditsElement.T_RENEWER);
    v.visitStringText(EditsElement.T_REAL_USER);
    v.visitVLong(EditsElement.T_ISSUE_DATE);
    v.visitVLong(EditsElement.T_MAX_DATE);
    v.visitVInt(EditsElement.T_SEQUENCE_NUMBER);
    v.visitVInt(EditsElement.T_MASTER_KEY_ID);
    if (LayoutVersion.supports(Feature.EDITLOG_OP_OPTIMIZATION, editsVersion)) {
      v.visitLong(EditsElement.T_EXPIRY_TIME);
    } else {
      v.visitStringUTF8(EditsElement.T_EXPIRY_TIME);
    }
  }
732507
private void initializeDelegationTokenSupport(Configuration config, URI path) throws IOException {
    logger.atFine().log("GHFS.initializeDelegationTokenSupport");
    // Load delegation token binding, if support is configured
    GcsDelegationTokens dts = new GcsDelegationTokens();
    Text service = new Text(getScheme() + "://" + path.getAuthority());
    dts.bindToFileSystem(this, service);
    try {
      dts.init(config);
      delegationTokens = dts;
      if (delegationTokens.isBoundToDT()) {
        logger.atFine().log(
            "GHFS.initializeDelegationTokenSupport: Using existing delegation token.");
      }
    } catch (IllegalStateException e) {
      logger.atInfo().log("GHFS.initializeDelegationTokenSupport: %s", e.getMessage());
    }
  }
1256050
@Override
  Tokenizer.Token visit(Tokenizer.Token value) throws IOException {
    // count the opCodes
    if(value.getEditsElement() == EditsElement.OPCODE) {
      if(value instanceof Tokenizer.ByteToken) {
        incrementOpCodeCount(((Tokenizer.ByteToken)value).value);
      } else {
        throw new IOException("Token for EditsElement.OPCODE should be " +
          "of type Tokenizer.ByteToken, not " + value.getClass());
      }
    }
    return value;
  }
856413
public Token get(Object key,
                     Transaction transaction)
                    throws ObjectManagerException
    {
        try {
            for (Iterator iterator = entrySet().iterator();;) {
                Entry entry = (Entry) iterator.next(transaction);
                Object entryKey = entry.getKey();
                if (key == entryKey || key.equals(entryKey)) {
                    return entry.getValue();

                }
            }
        } catch (java.util.NoSuchElementException exception) {
            // No FFDC code needed, just exited search.
            return null;
        } // try.
    }
771517
public synchronized DTMIterator getInstanceOrThrow()
    throws CloneNotSupportedException
  {
    // Check if the pool is empty.
    if (m_freeStack.isEmpty())
    {

      // Create a new object if so.
      return (DTMIterator)m_orig.clone();
    }
    else
    {
      // Remove object from end of free pool.
      DTMIterator result = (DTMIterator)m_freeStack.remove(m_freeStack.size() - 1);
      return result;
    }
  }
91790
public UNode toDoc() {
        // The root node is a MAP whose name is the alias name. We set its tag name to
        // "alias" for XML.
        UNode statNode = UNode.createMapNode(m_aliasName, "alias");
        
        // Add the expression parameter always, marked as an attribute.
        statNode.addValueNode("expression", getExpression(), true);
        return statNode;
    }
1204589
@FFDCIgnore({ Exception.class })
    public ProviderAuthenticationResult createResultWithJose4J(String responseState,
            Map<String, String> tokens,
            ConvergedClientConfig clientConfig,
            OidcClientRequest oidcClientRequest) {
        //oidcClientRequest.setTokenType(OidcClientRequest.TYPE_); // decided by the caller
        // This is for ID Token only at the writing time
        ProviderAuthenticationResult oidcResult = null;
        String tokenStr = getIdToken(tokens, clientConfig);
        String accessToken = tokens.get(Constants.ACCESS_TOKEN);
        String refreshToken = tokens.get(Constants.REFRESH_TOKEN);
        String clientId = clientConfig.getClientId();
        try {
            if (tokenStr == null) {
                // This is for ID Token only
                Tr.error(tc, "OIDC_CLIENT_IDTOKEN_REQUEST_FAILURE", new Object[] { clientId, clientConfig.getTokenEndpointUrl() });
                return new ProviderAuthenticationResult(AuthResult.SEND_401, HttpServletResponse.SC_UNAUTHORIZED);
            }

            JwtContext jwtContext = parseJwtWithoutValidation(tokenStr);
            JwtClaims jwtClaims = parseJwtWithValidation(clientConfig, tokenStr, jwtContext, oidcClientRequest);
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "post jwtClaims: " + jwtClaims + " firstPass jwtClaims=" + jwtContext.getJwtClaims());
            }
            OidcTokenImplBase idToken = new OidcTokenImplBase(jwtClaims, accessToken, refreshToken, clientId, oidcClientRequest.getTokenTypeNoSpace());

            if (idToken.getSubject() == null) {
                return new ProviderAuthenticationResult(AuthResult.SEND_401, HttpServletResponse.SC_UNAUTHORIZED);
            }
            AttributeToSubject attributeToSubject = new AttributeToSubject(clientConfig, idToken);
            if (attributeToSubject.checkUserNameForNull()) {
                return new ProviderAuthenticationResult(AuthResult.SEND_401, HttpServletResponse.SC_UNAUTHORIZED);
            }

            boolean isImplicit = Constants.IMPLICIT.equals(clientConfig.getGrantType());
            // verify nonce when nonce is enabled
            // this id for ID Token only
            if (clientConfig.isNonceEnabled() || isImplicit) {
                String nonceInIDToken = idToken.getNonce();
                boolean bNonceVerified = OidcUtil.verifyNonce(oidcClientRequest, nonceInIDToken, clientConfig, responseState);
                if (!bNonceVerified) {
                    // Error handling
                    Tr.error(tc, "OIDC_CLIENT_REQUEST_NONCE_FAILED", new Object[] { clientId, nonceInIDToken });
                    return new ProviderAuthenticationResult(AuthResult.SEND_401, HttpServletResponse.SC_UNAUTHORIZED);
                }
            }

            // if social login flow, put tokens and anything else social might want
            // into PAR props here and return it. Social will build the subject.
            if (clientConfig.isSocial()) {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "social login flow, storing id token in result");
                }
                Hashtable<String, Object> props = new Hashtable<String, Object>();
                props.put(Constants.ID_TOKEN, tokenStr);
                props.put(Constants.ACCESS_TOKEN, accessToken);
                if (idToken != null) {
                    props.put(Constants.ID_TOKEN_OBJECT, idToken);
                }
                oidcResult = new ProviderAuthenticationResult(AuthResult.SUCCESS, HttpServletResponse.SC_OK, null, null, props, null);
                return oidcResult;
            }

            Hashtable<String, Object> customProperties = new Hashtable<String, Object>();
            if (clientConfig.isIncludeCustomCacheKeyInSubject() || clientConfig.isDisableLtpaCookie()) {
                long storingTime = new Date().getTime();
                String customCacheKey = oidcClientRequest.getAndSetCustomCacheKeyValue(); //username + tokenStr.toString().hashCode();
                customProperties.put(ClientConstants.CREDENTIAL_STORING_TIME_MILLISECONDS, Long.valueOf(storingTime));
                customProperties.put(AttributeNameConstants.WSCREDENTIAL_CACHE_KEY, customCacheKey);
                customProperties.put(AuthenticationConstants.INTERNAL_ASSERTION_KEY, Boolean.TRUE); // TODO checking?
            }
            Subject subject = null;
            if (clientConfig.isIncludeIdTokenInSubject()) {
                subject = new Subject();
                subject.getPrivateCredentials().add(idToken); // add the external IDToken
                customProperties.putAll(tokens); // add ALL tokens to props.
            } else {
                if (refreshToken != null) {
                    customProperties.put(Constants.REFRESH_TOKEN, refreshToken);
                }
                if (accessToken != null) {
                    customProperties.put(Constants.ACCESS_TOKEN, accessToken);
                }
            }
            if (idToken != null) {
                customProperties.put(Constants.ID_TOKEN_OBJECT, idToken); // pass back to authenticator
            }

            //addJWTTokenToSubject(customProperties, idToken, clientConfig);

            //doIdAssertion(customProperties, payload, clientConfig);
            oidcResult = attributeToSubject.doMapping(customProperties, subject);
            //oidcResult = new ProviderAuthenticationResult(AuthResult.SUCCESS, HttpServletResponse.SC_OK, username, subject, customProperties, null);

        } catch (Exception e) {
            Tr.error(tc, "OIDC_CLIENT_IDTOKEN_VERIFY_ERR", new Object[] { e.getLocalizedMessage(), clientId });
            oidcResult = new ProviderAuthenticationResult(AuthResult.SEND_401, HttpServletResponse.SC_UNAUTHORIZED);
        }

        return oidcResult;
    }
268550
public static MtasTokenString getToken(IndexInput inObject, IndexInput inTerm,
      Long ref) throws IOException {
    MtasTokenString token = null;
    try {
      inObject.seek(ref);
      token = new MtasTokenString(null, "");
      token.setId(inObject.readVInt());
      token.setTokenRef(ref);
      int objectFlags = inObject.readVInt();
      int[] positions = null;
      if ((objectFlags & MTAS_OBJECT_HAS_PARENT) == MTAS_OBJECT_HAS_PARENT) {
        int parentId = inObject.readVInt();
        token.setParentId(parentId);
      }
      if ((objectFlags
          & MTAS_OBJECT_HAS_POSITION_RANGE) == MTAS_OBJECT_HAS_POSITION_RANGE) {
        int positionStart = inObject.readVInt();
        int positionEnd = positionStart + inObject.readVInt();
        token.addPositionRange(positionStart, positionEnd);
      } else if ((objectFlags
          & MTAS_OBJECT_HAS_POSITION_SET) == MTAS_OBJECT_HAS_POSITION_SET) {
        int size = inObject.readVInt();
        int tmpPrevious = 0;
        positions = new int[size];
        for (int t = 0; t < size; t++) {
          int position = tmpPrevious + inObject.readVInt();
          tmpPrevious = position;
          positions[t] = position;
        }
        token.addPositions(positions);
      } else {
        int position = inObject.readVInt();
        token.addPosition(position);
      }
      if ((objectFlags & MTAS_OBJECT_HAS_OFFSET) == MTAS_OBJECT_HAS_OFFSET) {
        int offsetStart = inObject.readVInt();
        int offsetEnd = offsetStart + inObject.readVInt();
        token.setOffset(offsetStart, offsetEnd);
      }
      if ((objectFlags
          & MTAS_OBJECT_HAS_REALOFFSET) == MTAS_OBJECT_HAS_REALOFFSET) {
        int realOffsetStart = inObject.readVInt();
        int realOffsetEnd = realOffsetStart + inObject.readVInt();
        token.setRealOffset(realOffsetStart, realOffsetEnd);
      }
      if ((objectFlags & MTAS_OBJECT_HAS_PAYLOAD) == MTAS_OBJECT_HAS_PAYLOAD) {
        int length = inObject.readVInt();
        byte[] mtasPayload = new byte[length];
        inObject.readBytes(mtasPayload, 0, length);
        token.setPayload(new BytesRef(mtasPayload));
      }
      Long termRef = inObject.readVLong();
      inTerm.seek(termRef);
      token.setTermRef(termRef);
      token.setValue(inTerm.readString());
    } catch (Exception e) {
      throw new IOException(e);
    }
    return token;
  }
733943
public synchronized Token peekToken() throws IOException {
        if (mLookahead.empty()) {
            return mLookahead.push(scanToken());
        }
        else {
            return mLookahead.peek();
        }
    }
923743
public DeltaCRLIndicatorExtension getDeltaCRLIndicatorExtension()
        throws IOException {

        Object obj = getExtension(PKIXExtensions.DeltaCRLIndicator_Id);
        return (DeltaCRLIndicatorExtension)obj;
    }
643207
public WsFederationCredential createCredentialFromToken(final Assertion assertion) {
        val retrievedOn = ZonedDateTime.now(ZoneOffset.UTC);
        LOGGER.debug("Retrieved on [{}]", retrievedOn);
        val credential = new WsFederationCredential();
        credential.setRetrievedOn(retrievedOn);
        credential.setId(assertion.getID());
        credential.setIssuer(assertion.getIssuer());
        credential.setIssuedOn(ZonedDateTime.parse(assertion.getIssueInstant().toDateTimeISO().toString()));
        val conditions = assertion.getConditions();
        if (conditions != null) {
            credential.setNotBefore(ZonedDateTime.parse(conditions.getNotBefore().toDateTimeISO().toString()));
            credential.setNotOnOrAfter(ZonedDateTime.parse(conditions.getNotOnOrAfter().toDateTimeISO().toString()));
            if (!conditions.getAudienceRestrictionConditions().isEmpty()) {
                credential.setAudience(conditions.getAudienceRestrictionConditions().get(0).getAudiences().get(0).getUri());
            }
        }
        if (!assertion.getAuthenticationStatements().isEmpty()) {
            credential.setAuthenticationMethod(assertion.getAuthenticationStatements().get(0).getAuthenticationMethod());
        }
        //retrieve an attributes from the assertion
        val attributes = new HashMap<String, List<Object>>();
        assertion.getAttributeStatements().stream().flatMap(attributeStatement -> attributeStatement.getAttributes().stream()).forEach(item -> {
            LOGGER.debug("Processed attribute: [{}]", item.getAttributeName());
            final List<Object> itemList = item.getAttributeValues().stream()
                .map(xmlObject -> ((XSAny) xmlObject).getTextContent())
                .collect(Collectors.toList());
            if (!itemList.isEmpty()) {
                attributes.put(item.getAttributeName(), itemList);
            }
        });
        credential.setAttributes(attributes);
        LOGGER.debug("Credential: [{}]", credential);
        return credential;
    }
865146
public static DataReader get() throws IOException {
    if (!instance.initialized) {
      long start = System.currentTimeMillis();
      instance.init();
      long elapsed = System.currentTimeMillis() - start;
      System.out.printf("Loaded CLDR data in %d ms.\n", elapsed);
    }
    return instance;
  }