public Credential[] getCredentials(Identity identity) throws AccessControlException {
Accreditable[] accreditables = identity.getAccreditables();
Credential[] credentials = getCredentials();
Set returnCredential = new LinkedHashSet();
for (int credIndex = 0; credIndex < credentials.length; credIndex++) {
Credential credential = credentials[credIndex];
for (int accrIndex = 0; accrIndex < accreditables.length; accrIndex++) {
Accreditable accreditable = accreditables[accrIndex];
if (credential.getAccreditable().equals(accreditable)) {
returnCredential.add(credential);
}
}
}
return (Credential[]) returnCredential.toArray(new Credential[returnCredential.size()]);