Generates an unique auth code.

Implementing classes may want to override this function to implement
other auth code generation schemes.

@return
An unique auth code.

@ingroup oauth2_section_4
998
protected function generateAuthorizationCode()
    {
        $tokenLen = 40;
        if (function_exists('random_bytes')) {
            $randomData = random_bytes(100);
        } elseif (function_exists('openssl_random_pseudo_bytes')) {
            $randomData = openssl_random_pseudo_bytes(100);
        } elseif (function_exists('mcrypt_create_iv')) {
            $randomData = mcrypt_create_iv(100, MCRYPT_DEV_URANDOM);
        } elseif (@file_exists('/dev/urandom')) { // Get 100 bytes of random data
            $randomData = file_get_contents('/dev/urandom', false, null, 0, 100) . uniqid(mt_rand(), true);
        } else {
            $randomData = mt_rand() . mt_rand() . mt_rand() . mt_rand() . microtime(true) . uniqid(mt_rand(), true);
        }

        return substr(hash('sha512', $randomData), 0, $tokenLen);
    }
727000
public static String createUniqueIdentifier() {
		String id;
		do {
			id = UUID.randomUUID().toString();
		} while (getSREFromId(id) != null);
		return id;
	}
65121
@Override
    public WebserviceSecurity getWebserviceSecurity() {
        if (delegate == null) {
            return this.webServiceSecurity;
        } else {
            return this.webServiceSecurity == null ? delegate.getWebserviceSecurity() : this.webServiceSecurity;
        }
    }
333799
public String generateResponse() {
	 if (userName == null) {
            System.out.println("DEBUG, DigestClientAuthenticationMethod, generateResponse(): "+
            "ERROR: no userName parameter");
            return null;
         }
	 if (realm == null) {
            System.out.println("DEBUG, DigestClientAuthenticationMethod, generateResponse(): "+
            "ERROR: no realm parameter");
            return  null; 
         }
               
         System.out.println("DEBUG, DigestClientAuthenticationMethod, generateResponse(): "+
         "Trying to generate a response for the user: "+userName+" , with "+
         "the realm: "+ realm);
                
	 if (password == null)  {
            System.out.println("DEBUG, DigestClientAuthenticationMethod, generateResponse(): "+
            "ERROR: no password parameter");
		return null;
         }
         if (method == null)  {
            System.out.println("DEBUG, DigestClientAuthenticationMethod, generateResponse(): "+
            "ERROR: no method parameter");
		return null;
         }     
         if (uri== null)  {
            System.out.println("DEBUG, DigestClientAuthenticationMethod, generateResponse(): "+
            "ERROR: no uri parameter");
		return null;
         }     
         if (nonce== null)  {
            System.out.println("DEBUG, DigestClientAuthenticationMethod, generateResponse(): "+
            "ERROR: no nonce parameter");
		return null;
         }    
         if (messageDigest== null)  {
            System.out.println("DEBUG, DigestClientAuthenticationMethod, generateResponse(): "+
            "ERROR: the algorithm is not set");
		return null;
         }   
	
         
         /*******    GENERATE RESPONSE      ************************************/
         System.out.println("DEBUG, DigestClientAuthenticationMethod, generateResponse(), userName:"+userName+"!");
         System.out.println("DEBUG, DigestClientAuthenticationMethod, generateResponse(), realm:"+realm+"!");
         System.out.println("DEBUG, DigestClientAuthenticationMethod, generateResponse(), password:"+password+"!");
         System.out.println("DEBUG, DigestClientAuthenticationMethod, generateResponse(), uri:"+uri+"!");
         System.out.println("DEBUG, DigestClientAuthenticationMethod, generateResponse(), nonce:"+nonce+"!");
         System.out.println("DEBUG, DigestClientAuthenticationMethod, generateResponse(), method:"+method+"!");
         // A1
         String A1 = userName + ":" + realm+ ":" +   password ;
         byte mdbytes[] = messageDigest.digest(A1.getBytes());
         String HA1 = toHexString(mdbytes);
         System.out.println("DEBUG, DigestClientAuthenticationMethod, generateResponse(), HA1:"+HA1+"!");
         //A2
         String A2 = method.toUpperCase() + ":" + uri ;
         mdbytes = messageDigest.digest(A2.getBytes());
         String HA2 = toHexString(mdbytes);
         System.out.println("DEBUG, DigestClientAuthenticationMethod, generateResponse(), HA2:"+HA2+"!");
         //KD
         String KD = HA1 + ":" + nonce;
         if (cnonce != null) {
             if(cnonce.length()>0) KD += ":" + cnonce;
         }
         KD += ":" + HA2;
         mdbytes = messageDigest.digest(KD.getBytes());
         String response = toHexString(mdbytes);
        
         System.out.println("DEBUG, DigestClientAlgorithm, generateResponse():"+
         " response generated: "+response);
         
         return response;
    }
678971
public function generateAuthKey()
    {
        try {
            $this->auth_key = Yii::$app->security->generateRandomString(32);
        } catch (Exception $e) {
            throw $e;
        }
    }
1145726
public com.google.protobuf.ByteString
      getAuthDomainBytes() {
    java.lang.Object ref = authDomain_;
    if (ref instanceof java.lang.String) {
      com.google.protobuf.ByteString b = 
          com.google.protobuf.ByteString.copyFromUtf8(
              (java.lang.String) ref);
      authDomain_ = b;
      return b;
    } else {
      return (com.google.protobuf.ByteString) ref;
    }
  }
1310805
public function createAuthCode()
	{
		$authParams = Authorizer::getAuthCodeRequestParams();
		$formParams = array_except($authParams,'client');
		$formParams['client_id'] = $authParams['client']->getId();

		$scope_collection = new \Illuminate\Database\Eloquent\Collection();
		foreach($authParams['scopes'] as $scope)
		{
			$scope_collection->add(Scope::findOrFail($scope->getId()));
		}
		return view('oauth.authorization-form')
			->with('params', $formParams)
			->with('client', $authParams['client'])
			->with('scopes', $scope_collection);
	}
368839
@Override
	public String getUniqueId() {
		final String sourceMethod = "getUniqueId"; //$NON-NLS-1$
		boolean isTraceLogging = log.isLoggable(Level.FINER);
		if (isTraceLogging) {
			log.entering(AggregatorExtension.class.getName(), sourceMethod);
			log.exiting(AggregatorExtension.class.getName(), sourceMethod, uniqueId);
		}
		return uniqueId;
	}
471353
public String generarIdentificador( ) {
        String UUID = Long.toHexString(System.currentTimeMillis());
        UUID = UUID.concat(obtenerDireccionIP());
        UUID = UUID.concat(identityHashCode);
        UUID = UUID.concat(Integer.toHexString(_oAleatorioSeguro.nextInt()));
        return UUID;
    }
888168
public static UniqueNameGenerator forLocalVariables() {
    UniqueNameGenerator generator = new UniqueNameGenerator(DANGEROUS_CHARACTERS, "$$");
    generator.reserve(JsSrcUtils.JS_LITERALS);
    generator.reserve(JsSrcUtils.JS_RESERVED_WORDS);
    return generator;
  }
533651
public String generateNewTag() {
    // This scheme of using random numbers to generate a
    // unique tag has a small probability of
    // causing duplicate tags.
    // TODO at some point, we may want to change it.

    int r = parent.getRandom().nextInt();
    r = (r < 0) ? 0 - r : r; // generate a positive number

    // incorporate registration/session ID (myRegistrationId) into all tags
    // from this
    // client? (for jiplet call identification purposes)

    return Integer.toString(r);
  }
943200
public static byte[] generateKey() {
        CipherKeyGenerator cipherKeyGenerator = new CipherKeyGenerator();
        cipherKeyGenerator.init(new KeyGenerationParameters(new SecureRandom(), 128));
        return cipherKeyGenerator.generateKey();
    }
1211281
public KeyPair generateKeyPair() {
        KeyPair keyPair = null;
        try {
            KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance(ALGORITHM);
            keyPairGenerator.initialize(KEYLENGTH);
            keyPair = keyPairGenerator.generateKeyPair();
        } catch (NoSuchAlgorithmException e) {
            LOG.error("Failed to create publi/private key pair", e);
        }
        
        return keyPair;
    }
382923
public OAuthGetAccessToken new10aTokenRequest(OAuthCredentialsResponse temporaryCredentials,
            String verifierCode) {
        OAuthGetAccessToken request = new OAuthGetAccessToken(getTokenServerEncodedUrl());
        request.temporaryToken = temporaryCredentials.token;
        request.transport = getTransport();

        OAuthHmacSigner signer = new OAuthHmacSigner();
        ClientParametersAuthentication clientAuthentication = (ClientParametersAuthentication) getClientAuthentication();
        signer.clientSharedSecret = clientAuthentication.getClientSecret();
        signer.tokenSharedSecret = temporaryCredentials.tokenSecret;

        request.signer = signer;
        request.consumerKey = clientAuthentication.getClientId();
        request.verifier = verifierCode;
        return request;
    }
1188816
public function getUniqueToken()
    {
        $tries = 0;
        $candidate = $this->cretateToken();
        // give up and throw an exception if it seems impossible to create a unique token
        while ($tries++ < 5 && in_array($candidate, $this->generated)) {
            $candidate = $this->cretateToken();
        }
        if (in_array($candidate, $this->generated)) {
            throw new \RuntimeException("failed to create a new unique token");
        }

        $this->generated[] = $candidate;

        return $candidate;
    }
436362
public static String uniquePassword() {
        final String[] passwords = new String[] {
            "ALKJVBPIQYTUIWEBVPQALZVKQRWORTUYOYISHFLKAJMZNXBVMNFGAHKJSDFALAPOQIERIUYTGSFGKMZNXBVJAHGFAKX",
            "1234567890",
            "qpowiealksdjzmxnvbfghsdjtreiuowiruksfhksajmzxncbvlaksjdhgqwetytopskjhfgvbcnmzxalksjdfhgbvzm",
            ".@,-+/()#$%^&*!"
        };
        final StringBuilder result = new StringBuilder();
        final long passwordLength = Math.abs(UUID.randomUUID().getLeastSignificantBits() % MIN_PASSWORD_LENGTH_8)
            + MIN_PASSWORD_LENGTH_8;
        for (int index = 0; index < passwordLength; index += 1) {
            final int passIndex = (int) (passwords.length * (long) index / passwordLength);
            final int charIndex = (int) Math.abs(
                UUID.randomUUID().getLeastSignificantBits() % passwords[passIndex].length());
            result.append(passwords[passIndex].charAt(charIndex));
        }
        return result.toString();
    }
504339
public function generateUuid() {
        if (is_readable(self::UUID_SOURCE)) {
            $uuid = trim(file_get_contents(self::UUID_SOURCE));
        } elseif (function_exists('mt_rand')) {
            /**
             * Taken from stackoverflow answer, possibly not the fastest or
             * strictly standards compliant
             * @link http://stackoverflow.com/a/2040279
             */
            $uuid = sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
                // 32 bits for "time_low"
                mt_rand(0, 0xffff), mt_rand(0, 0xffff),

                // 16 bits for "time_mid"
                mt_rand(0, 0xffff),

                // 16 bits for "time_hi_and_version",
                // four most significant bits holds version number 4
                mt_rand(0, 0x0fff) | 0x4000,

                // 16 bits, 8 bits for "clk_seq_hi_res",
                // 8 bits for "clk_seq_low",
                // two most significant bits holds zero and one for variant DCE1.1
                mt_rand(0, 0x3fff) | 0x8000,

                // 48 bits for "node"
                mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff)
            );
        } else {
            // chosen by dice roll, guaranteed to be random
            $uuid = '4';
        }
        return $uuid;
    }