/** * Returns a basic <tt>Authorization</tt> header value for the given * {@link UsernamePasswordCredentials} and charset. * * @param credentials The credentials to encode. * @param charset The charset to use for encoding the credentials * * @return a basic authorization string * * @since 3.0 */ public static String authenticate(UsernamePasswordCredentials credentials, String charset) { LOG.trace("enter BasicScheme.authenticate(UsernamePasswordCredentials, String)"); if (credentials == null) { throw new IllegalArgumentException("Credentials may not be null"); } if (charset == null || charset.length() == 0) { throw new IllegalArgumentException("charset may not be null or empty"); } StringBuffer buffer = new StringBuffer(); buffer.append(credentials.getUserName()); buffer.append(":"); buffer.append(credentials.getPassword()); return "Basic " + EncodingUtil.getAsciiString( Base64.encodeBase64(EncodingUtil.getBytes(buffer.toString(), charset))); }
getParameters().put("uri", uri); String digest = createDigest( usernamepassword.getUserName(), usernamepassword.getPassword()); return "Digest " + createDigestHeader(usernamepassword.getUserName(), digest);
usernamepassword.getUserName(), usernamepassword.getPassword()); return "Digest " + createDigestHeader(usernamepassword.getUserName(), digest);
/** * @param pageURL the URL of the page to go to after logging in. * @return URL to accomplish login and goto. */ public String getURLToLoginAsSuperAdminAndGotoPage(final String pageURL) { return getURLToLoginAndGotoPage(SUPER_ADMIN_CREDENTIALS.getUserName(), SUPER_ADMIN_CREDENTIALS.getPassword(), pageURL); }
public void loginAsAdmin() { login(ADMIN_CREDENTIALS.getUserName(), ADMIN_CREDENTIALS.getPassword()); }
public void loginAsAdminAndGotoPage(String pageURL) { loginAndGotoPage(ADMIN_CREDENTIALS.getUserName(), ADMIN_CREDENTIALS.getPassword(), pageURL); }
public String getURLToLoginAsAdmin() { return getURLToLoginAs(ADMIN_CREDENTIALS.getUserName(), ADMIN_CREDENTIALS.getPassword()); }
public String getURLToLoginAsSuperAdmin() { return getURLToLoginAs(SUPER_ADMIN_CREDENTIALS.getUserName(), SUPER_ADMIN_CREDENTIALS.getPassword()); }
public String getURLToLoginAsSuperAdmin() { return getURLToLoginAs(SUPER_ADMIN_CREDENTIALS.getUserName(), SUPER_ADMIN_CREDENTIALS.getPassword()); }
/** * @param pageURL the URL of the page to go to after logging in. * @return URL to accomplish login and goto. */ public String getURLToLoginAsAdminAndGotoPage(final String pageURL) { return getURLToLoginAndGotoPage(ADMIN_CREDENTIALS.getUserName(), ADMIN_CREDENTIALS.getPassword(), pageURL); }
/** * @param pageURL the URL of the page to go to after logging in. * @return URL to accomplish login and goto. */ public String getURLToLoginAsSuperAdminAndGotoPage(final String pageURL) { return getURLToLoginAndGotoPage(SUPER_ADMIN_CREDENTIALS.getUserName(), SUPER_ADMIN_CREDENTIALS.getPassword(), pageURL); }
public void loginAsAdmin() { loginAs(TestUtils.ADMIN_CREDENTIALS.getUserName(), TestUtils.ADMIN_CREDENTIALS.getPassword(), true); }
/** * @param pageURL the URL of the page to go to after logging in. * @return URL to accomplish login and goto. */ public String getURLToLoginAsAdminAndGotoPage(final String pageURL) { return getURLToLoginAndGotoPage(ADMIN_CREDENTIALS.getUserName(), ADMIN_CREDENTIALS.getPassword(), pageURL); }
public String getURLToLoginAsAdmin() { return getURLToLoginAs(ADMIN_CREDENTIALS.getUserName(), ADMIN_CREDENTIALS.getPassword()); }
public void loginAsSuperAdmin() { login(SUPER_ADMIN_CREDENTIALS.getUserName(), SUPER_ADMIN_CREDENTIALS.getPassword()); }
public void loginAsSuperAdminAndGotoPage(String pageURL) { loginAndGotoPage(SUPER_ADMIN_CREDENTIALS.getUserName(), SUPER_ADMIN_CREDENTIALS.getPassword(), pageURL); }
private String createPackageBintrayUrl(UsernamePasswordCredentials creds, String repository){ OpenmrsBintray bintray = new OpenmrsBintray(creds.getUserName(), creds.getPassword()); BintrayPackage bintrayPackage = bintray.getPackageMetadata(repository, mavenProject.getArtifactId()); if(bintrayPackage == null){ bintray.createPackage(mavenProject, repository); } return String.format(BINTRAY_MAVEN_REPO_URL_TMPL, OpenmrsBintray.OPENMRS_USERNAME, repository, mavenProject.getArtifactId()); }
public String authenticate(Credentials credentials, HttpMethod method) throws AuthenticationException { String auth = null; if (credentials instanceof UsernamePasswordCredentials) { UsernamePasswordCredentials usercreds = (UsernamePasswordCredentials)credentials; String id = usercreds.getUserName(); String pwd = usercreds.getPassword(); auth = getAuth(id, pwd); } else if (credentials instanceof GoogleLoginAuthCredentials) { GoogleLoginAuthCredentials gcreds = (GoogleLoginAuthCredentials)credentials; service = gcreds.getService(); auth = gcreds.getAuth(); } else { throw new AuthenticationException("Cannot use credentials for GoogleLogin authentication"); } StringBuffer buf = new StringBuffer("GoogleLogin "); buf.append(auth); return buf.toString(); }
/** * Retrieve the username and password previously set by setUsernameAndPassword. * * @return An array of two Strings. The first element is the username (or null) * and the second element is the password (or null). */ public String[] getUsernameAndPassword() { String[] res = new String[2]; // WARNING: The call to getCredentials will throw an IllegalArgumentException of credentials have not previously // been set with a call to setUsernameAndPassword UsernamePasswordCredentials cred = (UsernamePasswordCredentials) httpClient.getState().getCredentials(authScope); res[0] = cred.getUserName(); res[1] = cred.getPassword(); return res; }
private void deployOmod(UsernamePasswordCredentials credentials, File omodDir) { String omodName = mavenProject.getArtifactId()+"-"+releaseVersion+".omod"; wizard.showMessage("Omod submodule detected..."); File omodFile = new File(omodDir, "target"+File.separator+omodName); OpenmrsBintray openmrsBintray = new OpenmrsBintray(credentials.getUserName(), credentials.getPassword()); BintrayPackage bintrayPackage = openmrsBintray.getPackageMetadata(OpenmrsBintray.OPENMRS_OMOD_REPO, mavenProject.getArtifactId()); if(bintrayPackage == null){ bintrayPackage = openmrsBintray.createPackage(mavenProject, OpenmrsBintray.OPENMRS_OMOD_REPO); } wizard.showMessage("Deploying "+omodName+" to Bintray OpenMRS Omod repository..."); openmrsBintray.uploadOmod(bintrayPackage, omodName, omodFile, releaseVersion); wizard.showMessage(omodName+" deployed"); }