javax.security.auth.login.CredentialNotFoundException Java Examples

The following examples show how to use javax.security.auth.login.CredentialNotFoundException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AWSClientFactory.java    From awseb-deployment-plugin with Apache License 2.0 6 votes vote down vote up
private static AmazonWebServicesCredentials lookupNamedCredential(String credentialsId)
        throws CredentialNotFoundException {
    final Jenkins jenkins = Jenkins.getInstanceOrNull();

    if (jenkins == null)
        throw new RuntimeException("Missing Jenkins Instance");

    List<AmazonWebServicesCredentials> credentialList =
            CredentialsProvider.lookupCredentials(
                    AmazonWebServicesCredentials.class, jenkins, ACL.SYSTEM,
                    Collections.<DomainRequirement>emptyList());

    AmazonWebServicesCredentials cred =
            CredentialsMatchers.firstOrNull(credentialList,
                    CredentialsMatchers.allOf(
                            CredentialsMatchers.withId(credentialsId)));

    if (cred == null) {
        throw new CredentialNotFoundException(credentialsId);
    }
    return cred;
}
 
Example #2
Source File: TomcatSecurityService.java    From tomee with Apache License 2.0 5 votes vote down vote up
public UUID login(final String realmName, final String username, final String password) throws LoginException {
    final Realm realm = findRealm(realmName);
    if (realm == null) {
        throw new LoginException("No Tomcat realm available");
    }

    final Principal principal = realm.authenticate(username, password);
    if (principal == null) {
        throw new CredentialNotFoundException(username);
    }

    final Subject subject = createSubject(realm, principal);
    return registerSubject(subject);
}
 
Example #3
Source File: AWSClientFactory.java    From awseb-deployment-plugin with Apache License 2.0 5 votes vote down vote up
public static AWSClientFactory getClientFactory(String credentialsId, String awsRegion)
        throws CredentialNotFoundException {
    AWSCredentialsProvider provider = new DefaultAWSCredentialsProviderChain();

    if (isNotBlank(credentialsId)) {
        provider = lookupNamedCredential(credentialsId);
    }

    return getClientFactory(provider, awsRegion);
}