Delegate credentials to a MyProxy server.

@param  credential
The GSI credentials to use.
@param  params
The parameters for the put operation.
@exception MyProxyException
If an error occurred during the operation.
358251
public void put(GSSCredential credential,
                    InitParams params)
        throws MyProxyException {

        if (credential == null) {
            throw new IllegalArgumentException("credential == null");
        }

        if (params == null) {
            throw new IllegalArgumentException("params == null");
        }

        if (!(credential instanceof GlobusGSSCredentialImpl)) {
            throw new IllegalArgumentException("wrong type of credentials");
        }

        String msg = params.makeRequest();

        Socket gsiSocket = null;
        OutputStream out = null;
        InputStream  in  = null;

        try {
            gsiSocket = getSocket(credential);

            out = gsiSocket.getOutputStream();
            in  = gsiSocket.getInputStream();

            if (!((GssSocket)gsiSocket).getContext().getConfState())
                throw new Exception("Confidentiality requested but not available");

            // send message
            out.write(msg.getBytes());
            out.flush();

            if (logger.isDebugEnabled()) {
                logger.debug("Req sent:" + params);
            }

            handleReply(in);

            BouncyCastleCertProcessingFactory certFactory =
                BouncyCastleCertProcessingFactory.getDefault();

            GlobusGSSCredentialImpl pkiCred =
                (GlobusGSSCredentialImpl)credential;

            X509Certificate [] certs = pkiCred.getCertificateChain();

            // read in the cert request from socket and
            // generate a certificate to be sent back to the server
            X509Certificate cert =
                certFactory.createCertificate(in,
                                              certs[0],
                                              pkiCred.getPrivateKey(),
                                              -1,
                     BouncyCastleCertProcessingFactory.decideProxyType(certs[0],
                                             GSIConstants.DelegationType.FULL));

            // write the new cert we've generated to the socket to send it back
            // to the server

            // must put everything into one message
            ByteArrayOutputStream buffer = new ByteArrayOutputStream(2048);

            buffer.write( (byte)(certs.length+1) );

            // write signed ceritifcate
            buffer.write(cert.getEncoded());

            for (int i=0;i<certs.length;i++) {
                buffer.write( certs[i].getEncoded() );

                // DEBUG: print out subject name of sent certificate
                if (logger.isDebugEnabled()) {
                    logger.debug("Sent cert: " + certs[i].getSubjectDN());
                }

            }

            out.write(buffer.toByteArray());
            out.flush();

            handleReply(in);

        } catch(Exception e) {
            throw new MyProxyException("MyProxy put failed.", e);
        } finally {
            // close socket
            close(out, in, gsiSocket);
        }
    }
648785
protected static void put(String resource, RequestParams params, ResponseHandler responseHandler) {
        requestAuthenticated(new Request(WonderPushConfiguration.getUserId(), HttpMethod.PUT, resource, params, responseHandler));
    }
842430
public void readCredentials(ConfigParams credentials) {
		synchronized (_lock) {
			_items.clear();
			for (Map.Entry<String, String> entry : credentials.entrySet())
				_items.put(entry.getKey(), CredentialParams.fromString(entry.getValue()));
		}
	}
725848
public static Credential decode(Object encoded, Resource rolesDir) throws PageException {
	String dec;
	try {
	    dec = Base64Coder.decodeToString(Caster.toString(encoded), "UTF-8");
	}
	catch (Exception e) {
	    throw Caster.toPageException(e);
	}

	Array arr = ListUtil.listToArray(dec, "" + ONE);
	int len = arr.size();
	if (len == 3) {
	    String str = Caster.toString(arr.get(3, ""));
	    if (str.startsWith("md5:")) {
		if (!rolesDir.exists()) rolesDir.mkdirs();
		str = str.substring(4);
		Resource md5 = rolesDir.getRealResource(str);
		try {
		    str = IOUtil.toString(md5, "utf-8");
		}
		catch (IOException e) {
		    str = "";
		}
	    }

	    return new CredentialImpl(Caster.toString(arr.get(1, "")), Caster.toString(arr.get(2, "")), str, rolesDir);
	}
	if (len == 2) return new CredentialImpl(Caster.toString(arr.get(1, "")), Caster.toString(arr.get(2, "")), rolesDir);
	if (len == 1) return new CredentialImpl(Caster.toString(arr.get(1, "")), rolesDir);

	return null;
    }
433257
protected function setCredential($credential_id)
    {
        if (is_numeric($credential_id)) {
            $this->data_credential = $this->credential->get($credential_id);
            if (empty($this->data_credential)) {
                $this->outputHttpStatus(404);
            }
        }
    }
1254292
public void put(URI uri, String mimetype, byte[] content,
			Credentials credentials) throws IOException {
		put(uri, mimetype, content, null, credentials);
	}
1196501
public SdkClientBuilder proxyCredentials(String user, String password) {
        this.proxyCredentials = new UsernamePasswordCredentials(user, password);
        return this;
    }
276687
def credential_share_simulate(self, cred_id, *user_ids):
        
        return self.raw_query("credential", "shareSimulate", data={
            'id': cred_id,
            'users': [{'id': i} for i in user_ids],
        })
959887
@SuppressWarnings("unchecked")
    protected Credentials getCredentials(Map<String, String> credentials) {
        Credentials credential = null;
        if (credentials != null && credentials.containsKey(getCredentialKey())) {
            try {
                byte[] credBytes = DatatypeConverter.parseBase64Binary(credentials.get(getCredentialKey()));
                ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(credBytes));

                credential = new Credentials();
                credential.readFields(in);
            } catch (Exception e) {
                LOG.error("Could not obtain credentials from credentials map.", e);
            }
        }
        return credential;
    }
476912
public void setSingleSignOn(HttpRequest request,
                                HttpResponse response,
                                Principal principal,
                                Credential credential)
    {
        if (_ssoRealm!=null)
            _ssoRealm.setSingleSignOn(request,response,principal,credential);
    }
1077377
public void updateParamsForAuth(String[] authNames, List<Pair> queryParams, Map<String, String> headerParams) {
        for (String authName : authNames) {
            Authentication auth = authentications.get(authName);
            if (auth == null) throw new RuntimeException("Authentication undefined: " + authName);
            auth.applyToParams(queryParams, headerParams);
        }
    }
340652
public static void main(String[] args) {
    Credentials cred = new Credentials(System.getProperty("user.name"), "Heslo123");
    String url = start(args, cred, "https://localhost:54321/", false);
    System.out.println("Proxy started on " + url + " " + cred.toDebugString());
  }
213577
public static Credentials copy(Credentials credentials) {
        if (credentials == null) {
            return null;
        }
        return new Credentials(credentials.login, credentials.password);
    }
640679
public OvhCredential api_credential_credentialId_GET(Long credentialId) throws IOException {
		String qPath = "/me/api/credential/{credentialId}";
		StringBuilder sb = path(qPath, credentialId);
		String resp = exec(qPath, "GET", sb.toString(), null);
		return convertTo(resp, OvhCredential.class);
	}
1023288
public void put(URI uri, String mimetype, String content,
			Header[] additionalRequestHeaders, Credentials credentials) {
		ra.getExecutorService().execute(
				new AsyncPutStringContentHandler(ra, handle, uri, mimetype,
						content, additionalRequestHeaders, credentials));
	}
514227
public void map(final UserResource user, final Principal p,
                    final Credential credential) {
        user.setUserName(p.getId());
        if (credential instanceof UsernamePasswordCredential) {
            user.setPassword(UsernamePasswordCredential.class.cast(credential).getPassword());
        }
        user.setActive(Boolean.TRUE);

        user.setNickName(getPrincipalAttributeValue(p, "nickName"));
        user.setDisplayName(getPrincipalAttributeValue(p, "displayName"));

        val name = new Name();
        name.setGivenName(getPrincipalAttributeValue(p, "givenName"));
        name.setFamilyName(getPrincipalAttributeValue(p, "familyName"));
        name.setMiddleName(getPrincipalAttributeValue(p, "middleName"));

        user.setName(name);

        val email = new Email();
        email.setPrimary(Boolean.TRUE);
        email.setValue(getPrincipalAttributeValue(p, "email"));
        user.setEmails(CollectionUtils.wrap(email));

        val phone = new PhoneNumber();
        phone.setPrimary(Boolean.TRUE);
        phone.setValue(getPrincipalAttributeValue(p, "phoneNumber"));
        user.setPhoneNumbers(CollectionUtils.wrap(phone));
    }
824692
private static CredentialsProvider buildCredentialProvider(
      CredentialOptions credentialOptions) throws IOException {
    try {
      final Credentials credentials = CredentialFactory.getCredentials(credentialOptions);
      if (credentials == null) {
        LOG.info("Enabling the use of null credentials. This should not be used in production.");
        return NoCredentialsProvider.create();
      }

      return FixedCredentialsProvider.create(credentials);
    } catch (GeneralSecurityException exception) {
      throw new IOException("Could not initialize credentials.", exception);
    }
  }