示例#1
0
JNIEXPORT jobject JNICALL Java_jpwr_rt_RtSecurity_checkUser
  (JNIEnv *env , jclass object, jstring jsystemgroup, jstring juser, 
	jstring jpassword)
{
  int sts;
  const char *systemgroup;
  char *csystemgroup;
  const char *user;
  char *cuser;
  const char *password;
  char *cpassword;
  jclass cdhrInt_id;
  jmethodID cdhrInt_cid;
  jobject return_obj;
  unsigned int priv;
  jint jsts;
  jint jpriv;
  pwr_tObjid	oid;
  pwr_sSecurity	sec;	
  pwr_tAttrRef aref;

  cdhrInt_id = (*env)->FindClass( env, "jpwr/rt/CdhrInt");
  cdhrInt_cid = (*env)->GetMethodID( env, cdhrInt_id,
    	"<init>", "(II)V");

  systemgroup = (*env)->GetStringUTFChars( env, jsystemgroup, 0);
  csystemgroup = (char *)systemgroup;
  user = (*env)->GetStringUTFChars( env, juser, 0);
  cuser = (char *)user;
  password = (*env)->GetStringUTFChars( env, jpassword, 0);
  cpassword = (char *)password;

  sts = gdh_GetClassList ( pwr_eClass_Security, &oid);
  if (ODD(sts)) {
    aref = cdh_ObjidToAref( oid);
    sts = gdh_GetObjectInfoAttrref( &aref, &sec, sizeof(sec));
    if ( ODD(sts)){
      sts = user_CheckUser( sec.WebSystemGroup, cuser, cpassword, &priv);
    }
  }
  (*env)->ReleaseStringUTFChars( env, jsystemgroup, csystemgroup);
  (*env)->ReleaseStringUTFChars( env, juser, cuser);
  (*env)->ReleaseStringUTFChars( env, jpassword, cpassword);

  jsts = (jint) sts;
  if ( sts % 2 == 0)
    priv = pwr_mPrv_RtRead;
  jpriv = priv;
  return_obj = (*env)->NewObject( env, cdhrInt_id,
  	cdhrInt_cid, jpriv, jsts);
  return return_obj; 
}
示例#2
0
//
//	Check username and password and insert login infomation.
//
pwr_tStatus CoLogin::user_check( const char *groupname, const char *username, const char *password)
{
  pwr_tStatus		sts;
  unsigned int		priv;
  unsigned long		attr = 0;
  char			cpassword[40];
  
  strcpy( cpassword, UserList::pwcrypt( password));
  sts = user_CheckUser( groupname, username, cpassword, &priv);
  if ( EVEN(sts)) return sts;

  insert_login_info( groupname, cpassword, username, priv, attr);
  strcpy( m_ucpassword, password);
  return LOGIN__SUCCESS;
}
示例#3
0
static int	xtttbl_login_func(	void		*client_data,
					void		*client_flag)
{
  XttTbl *xtttbl = (XttTbl *)client_data;
  int	sts;
  char	arg1_str[80];
  char	arg2_str[80];
  char	systemgroup[80];
  unsigned int	priv;
  char	msg[80];
	
  // sts = gdh_GetObjectInfo ( "pwrNode-System.SystemGroup", &systemgroup, 
  //		sizeof(systemgroup));
  // if ( EVEN(sts)) return sts;
  sts = xtttbl->read_bootfile( 0, systemgroup);

  if ( EVEN( dcli_get_qualifier( "dcli_arg1", arg1_str, sizeof(arg1_str))))
  {
    xtttbl->cologin = xtttbl->login_new( "PwR Login", systemgroup, xtttbl_login_success_bc, 
				     xtttbl_login_cancel_bc, &sts);

    return 1;
  }
  if ( EVEN( dcli_get_qualifier( "dcli_arg2", arg2_str, sizeof(arg2_str))))
  {
    xtttbl->message('E',"Syntax error");
    return 1;
  }

  cdh_ToLower( arg1_str, arg1_str);
  cdh_ToLower( arg2_str, arg2_str);
  sts = user_CheckUser( systemgroup, arg1_str, UserList::pwcrypt(arg2_str), &priv);
  if ( EVEN(sts))
    xtttbl->message('E',"Login failure");
  else
  {
    strcpy( xtttbl->user, arg1_str);
    xtttbl->priv = priv;
    sprintf( msg, "User %s logged in", arg1_str);
    xtttbl->message('I', msg);
  }
  return sts;
}