MapElement descriptor = (MapElement) getDescriptor();
if (descriptor==null) {
throw new RuntimeException("Cannot set info on null descriptor");
}
if (newDescriptor instanceof Principal) {
Principal principal = (Principal) newDescriptor;
if (principal.getValue(Principal.CREDENTIAL)==null) {
descriptor.addPrincipal(principal);
} else {
descriptor.setBackendPrincipal(true);
descriptor.setAttributeValue(MapElement.BACKEND_PRINCIPAL, Principal.USER_NAME, principal.getValue(Principal.USER_NAME));
descriptor.setAttributeValue(MapElement.BACKEND_PRINCIPAL, Principal.PASSWORD, principal.getValue(Principal.PASSWORD));
descriptor.setAttributeValue(MapElement.BACKEND_PRINCIPAL, Principal.CREDENTIAL, principal.getValue(Principal.CREDENTIAL));
}
}
}