| | |
| | | * Portions Copyright 2006-2007 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.controls; |
| | | import org.opends.messages.Message; |
| | | |
| | | |
| | | |
| | |
| | | import static org.opends.server.loggers.debug.DebugLogger.*; |
| | | import org.opends.server.loggers.debug.DebugTracer; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.ProtocolMessages.*; |
| | | import static org.opends.messages.ProtocolMessages.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import static org.opends.server.util.Validator.*; |
| | |
| | | |
| | | if (! control.isCritical()) |
| | | { |
| | | int msgID = MSGID_PROXYAUTH2_CONTROL_NOT_CRITICAL; |
| | | String message = getMessage(msgID); |
| | | throw new LDAPException(LDAPResultCode.PROTOCOL_ERROR, msgID, |
| | | message); |
| | | Message message = ERR_PROXYAUTH2_CONTROL_NOT_CRITICAL.get(); |
| | | throw new LDAPException(LDAPResultCode.PROTOCOL_ERROR, message); |
| | | } |
| | | |
| | | if (! control.hasValue()) |
| | | { |
| | | int msgID = MSGID_PROXYAUTH2_NO_CONTROL_VALUE; |
| | | String message = getMessage(msgID); |
| | | throw new LDAPException(LDAPResultCode.PROTOCOL_ERROR, msgID, message); |
| | | Message message = ERR_PROXYAUTH2_NO_CONTROL_VALUE.get(); |
| | | throw new LDAPException(LDAPResultCode.PROTOCOL_ERROR, message); |
| | | } |
| | | |
| | | ASN1OctetString authorizationID; |
| | |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, ae); |
| | | } |
| | | |
| | | int msgID = MSGID_PROXYAUTH2_CANNOT_DECODE_VALUE; |
| | | String message = getMessage(msgID, getExceptionMessage(ae)); |
| | | throw new LDAPException(LDAPResultCode.PROTOCOL_ERROR, msgID, message, |
| | | Message message = |
| | | ERR_PROXYAUTH2_CANNOT_DECODE_VALUE.get(getExceptionMessage(ae)); |
| | | throw new LDAPException(LDAPResultCode.PROTOCOL_ERROR, message, |
| | | ae); |
| | | } |
| | | } |
| | |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_PROXYAUTH2_CANNOT_DECODE_VALUE; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | throw new LDAPException(LDAPResultCode.PROTOCOL_ERROR, msgID, message, e); |
| | | Message message = |
| | | ERR_PROXYAUTH2_CANNOT_DECODE_VALUE.get(getExceptionMessage(e)); |
| | | throw new LDAPException(LDAPResultCode.PROTOCOL_ERROR, message, e); |
| | | } |
| | | |
| | | return new ProxiedAuthV2Control(control.getOID(), control.isCritical(), |
| | |
| | | |
| | | if (entryLock == null) |
| | | { |
| | | int msgID = MSGID_PROXYAUTH2_CANNOT_LOCK_USER; |
| | | String message = getMessage(msgID, String.valueOf(authzDN)); |
| | | throw new DirectoryException(ResultCode.AUTHORIZATION_DENIED, message, |
| | | msgID); |
| | | Message message = |
| | | ERR_PROXYAUTH2_CANNOT_LOCK_USER.get(String.valueOf(authzDN)); |
| | | throw new DirectoryException( |
| | | ResultCode.AUTHORIZATION_DENIED, message); |
| | | } |
| | | |
| | | try |
| | |
| | | if (userEntry == null) |
| | | { |
| | | // The requested user does not exist. |
| | | int msgID = MSGID_PROXYAUTH2_NO_SUCH_USER; |
| | | String message = getMessage(msgID, authzID); |
| | | Message message = ERR_PROXYAUTH2_NO_SUCH_USER.get(authzID); |
| | | throw new DirectoryException(ResultCode.AUTHORIZATION_DENIED, |
| | | message, msgID); |
| | | message); |
| | | } |
| | | |
| | | // FIXME -- We should provide some mechanism for enabling debug |
| | |
| | | pwpState.lockedDueToMaximumResetAge() || |
| | | pwpState.isPasswordExpired()) |
| | | { |
| | | int msgID = MSGID_PROXYAUTH2_UNUSABLE_ACCOUNT; |
| | | String message = getMessage(msgID, String.valueOf(authzDN)); |
| | | Message message = |
| | | ERR_PROXYAUTH2_UNUSABLE_ACCOUNT.get(String.valueOf(authzDN)); |
| | | throw new DirectoryException(ResultCode.AUTHORIZATION_DENIED, |
| | | message, msgID); |
| | | message); |
| | | } |
| | | |
| | | |
| | |
| | | DirectoryServer.getProxiedAuthorizationIdentityMapper(); |
| | | if (proxyMapper == null) |
| | | { |
| | | int msgID = MSGID_PROXYAUTH2_NO_IDENTITY_MAPPER; |
| | | String message = getMessage(msgID); |
| | | throw new DirectoryException(ResultCode.AUTHORIZATION_DENIED, message, |
| | | msgID); |
| | | Message message = ERR_PROXYAUTH2_NO_IDENTITY_MAPPER.get(); |
| | | throw new DirectoryException(ResultCode.AUTHORIZATION_DENIED, message); |
| | | } |
| | | |
| | | Entry userEntry = proxyMapper.getEntryForID(authzID.substring(2)); |
| | | if (userEntry == null) |
| | | { |
| | | int msgID = MSGID_PROXYAUTH2_NO_SUCH_USER; |
| | | String message = getMessage(msgID, authzID); |
| | | throw new DirectoryException(ResultCode.AUTHORIZATION_DENIED, message, |
| | | msgID); |
| | | Message message = ERR_PROXYAUTH2_NO_SUCH_USER.get(authzID); |
| | | throw new DirectoryException(ResultCode.AUTHORIZATION_DENIED, message); |
| | | } |
| | | else |
| | | { |
| | |
| | | pwpState.lockedDueToMaximumResetAge() || |
| | | pwpState.isPasswordExpired()) |
| | | { |
| | | int msgID = MSGID_PROXYAUTH2_UNUSABLE_ACCOUNT; |
| | | String message = getMessage(msgID, String.valueOf(userEntry.getDN())); |
| | | Message message = ERR_PROXYAUTH2_UNUSABLE_ACCOUNT.get( |
| | | String.valueOf(userEntry.getDN())); |
| | | throw new DirectoryException(ResultCode.AUTHORIZATION_DENIED, |
| | | message, msgID); |
| | | message); |
| | | } |
| | | |
| | | return userEntry; |
| | |
| | | } |
| | | else |
| | | { |
| | | int msgID = MSGID_PROXYAUTH2_INVALID_AUTHZID; |
| | | String message = getMessage(msgID, authzID); |
| | | throw new DirectoryException(ResultCode.PROTOCOL_ERROR, message, msgID); |
| | | Message message = ERR_PROXYAUTH2_INVALID_AUTHZID.get(authzID); |
| | | throw new DirectoryException(ResultCode.PROTOCOL_ERROR, message); |
| | | } |
| | | } |
| | | |