Search in sources :

Example 6 with CrnParseException

use of com.sequenceiq.cloudbreak.auth.crn.CrnParseException in project cloudbreak by hortonworks.

the class CrnService method getCurrentAccountId.

public String getCurrentAccountId() {
    String userCrn = ThreadBasedUserCrnProvider.getUserCrn();
    Crn crn = null;
    try {
        crn = Crn.fromString(userCrn);
    } catch (NullPointerException e) {
        LOGGER.warn("Crn is not set", e);
        throw new CrnParseException("CRN is not set");
    }
    if (crn != null) {
        return crn.getAccountId();
    } else {
        throw new CrnParseException("Can not parse account ID from CRN");
    }
}
Also used : CrnParseException(com.sequenceiq.cloudbreak.auth.crn.CrnParseException) Crn(com.sequenceiq.cloudbreak.auth.crn.Crn)

Aggregations

Crn (com.sequenceiq.cloudbreak.auth.crn.Crn)6 CrnParseException (com.sequenceiq.cloudbreak.auth.crn.CrnParseException)6 MachineUser (com.cloudera.thunderhead.service.usermanagement.UserManagementProto.MachineUser)1 User (com.cloudera.thunderhead.service.usermanagement.UserManagementProto.User)1 CrnUser (com.sequenceiq.cloudbreak.auth.CrnUser)1 UmsAuthenticationException (com.sequenceiq.cloudbreak.auth.altus.exception.UmsAuthenticationException)1 CloudbreakUser (com.sequenceiq.cloudbreak.common.user.CloudbreakUser)1